Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ndarray-ops

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ndarray-ops

Common operations for ndarray arrays

  • 1.2.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
156K
decreased by-4.06%
Maintainers
1
Weekly downloads
 
Created

What is ndarray-ops?

The ndarray-ops npm package provides a collection of high-performance operations for manipulating ndarrays (N-dimensional arrays). It is designed to work efficiently with large datasets and supports a variety of mathematical and logical operations.

What are ndarray-ops's main functionalities?

Element-wise Operations

This feature allows you to perform element-wise operations such as addition, subtraction, multiplication, and division on ndarrays. The code sample demonstrates how to add two 2x2 matrices element-wise.

const ndarray = require('ndarray');
const ops = require('ndarray-ops');

let a = ndarray(new Float32Array([1, 2, 3, 4]), [2, 2]);
let b = ndarray(new Float32Array([5, 6, 7, 8]), [2, 2]);
let c = ndarray(new Float32Array(4), [2, 2]);

ops.add(c, a, b);
console.log(c.data); // Output: Float32Array [ 6, 8, 10, 12 ]

Scalar Operations

This feature allows you to perform operations involving a scalar value and an ndarray. The code sample demonstrates how to multiply each element of a 2x2 matrix by a scalar value (2).

const ndarray = require('ndarray');
const ops = require('ndarray-ops');

let a = ndarray(new Float32Array([1, 2, 3, 4]), [2, 2]);

ops.mulseq(a, 2);
console.log(a.data); // Output: Float32Array [ 2, 4, 6, 8 ]

Logical Operations

This feature allows you to perform logical operations such as less than, greater than, and equal to on ndarrays. The code sample demonstrates how to compare two 2x2 matrices element-wise to check if elements in the first matrix are less than those in the second matrix.

const ndarray = require('ndarray');
const ops = require('ndarray-ops');

let a = ndarray(new Float32Array([1, 2, 3, 4]), [2, 2]);
let b = ndarray(new Float32Array([4, 3, 2, 1]), [2, 2]);
let c = ndarray(new Float32Array(4), [2, 2]);

ops.lt(c, a, b);
console.log(c.data); // Output: Float32Array [ 1, 1, 0, 0 ]

Other packages similar to ndarray-ops

Keywords

FAQs

Package last updated on 07 May 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc