
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
typed-array-ops
Advanced tools
Typed Array Operators
This package creates a number of usefull operator functions for ndarray data. Many of the funcitons provided by the ndarray-ops package and those provided Numeric Javascript are available.
npm install typed-array-function
npm install typed-array-ops
Example Usage
//First, import libraries
var typed = require("typed-array-function");
typed = typed.extend(typed, require("typed-array-ops"));
//Next, create some arrays
var a = ndarray(new Float32Array(128*128))
, b = ndarray(new Float32Array(128*128))
, c = ndarray(new Float32Array(128*128))
//Initialize b with some random numbers:
typed.random(b)
//Set c to a constant 1
typed.assign(c, 1.0)
//Add b and c, store result in a:
typed.add(a, b, c)
//Multiply a by 0.5 in place
typed.mulseq(a, 0.5)
//Print some statistics about a:
console.log(
"inf(a) = ", typed.inf(a),
"sup(a) = ", typed.sup(a))
Conventions
This library implements component-wise operations for all of the operators and Math.* functions in JS, along with a few commonly used aggregate operations. Most of the functions in the library work by applying some symmetric binary operator to a pair of arrays. You call them like this:
typed.add(dest, arg1, arg2)
Which translates into code that works (approximately) like this:
for(var i=0; i<dest.shape[0]; ++i) {
dest[i] = arg1[i] + arg2[i]
}
This library will create new arrays for you as is the convention in Numeric Javascript, but you might wish to avoid this expensive allocation for intermediate results by providing destination arrays where apropriate. When supplying a binary operator function with 3 arguments, the first argument will be used as the result. If the call has only 2 arguments then a result array will be allocated.
Scaler variations of the operators, suffixed with 's', are provided for compatibility with ndarray-ops, but are unnecessary. These functions are aliases for thier array versions.
The following operators follow this rule:
Assignment
The assignment operator:
Nullary operators
Nullary operators only take one argument for the array they are assigning to, and don't have any variations. Currently there is only one of these:
Unary operators
Unary operators have three forms, they can be written as either:
Typed-array-ops exposes the following unary operators:
Non-symmetric binary operators
There are two non-symmetric binary operators:
Map-reduce (aggregate) operators
Finally, there are aggregate operators that take an array as input and compute some aggregate result or summary. These functions don't have any special suffixes and all of them take a single array as input.
Credits
(c) 2014 John B Roll
Inspired by ndarray-ops by Mikola Lysenko. This README is cribbed directly from ndarray-ops.
MIT License
FAQs
Element wise operator functions for ndarray data.
The npm package typed-array-ops receives a total of 0 weekly downloads. As such, typed-array-ops popularity was classified as not popular.
We found that typed-array-ops demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.