CommonJS
const ops = require('@stackline/ndarray-ops')
ops.assign(destination, source)
Maintained npm package
The complete historical ndarray operation surface, implemented without runtime string compilation or production dependencies.
Start here
npm install @stackline/[email protected]
CommonJS, the historical deep entry, ESM default and named exports, AMD, and the classic globalThis.ndarrayOps browser surface are included.
const ops = require('@stackline/ndarray-ops')
ops.assign(destination, source)
import ops, { add, sum } from '@stackline/ndarray-ops'
add(out, left, right)
Compatibility
Export names, insertion order, arities, function names, mutation, return values, scalar and reversed-operand families match [email protected].
Arbitrary rank, offsets, positive, negative and zero strides, mixed orders with 64-cell reverse blocking, rank-zero views, empty arrays, aliases, and generic storage preserve observable traversal.
No eval or new Function is used. Loading and execution work when string code generation is prohibited.
Non-finite or out-of-range metadata and invalid order permutations fail synchronously instead of compiling invalid code, wrapping addresses, or hanging.
Valid metadata uses non-negative signed-32-bit integer shape extents, signed-32-bit integer strides and offsets, a complete order permutation, a string dtype, and compatible storage. NaN and Infinity remain valid data values.
Operation inventory
| Family | Operations | Variants |
|---|---|---|
| Arithmetic | add sub mul div mod | eq, s, seq |
| Bitwise | band bor bxor lshift rshift rrshift | eq, s, seq |
| Logic and comparison | and or eq neq lt gt leq geq | array, scalar and in-place |
| Math | abs acos asin atan ceil cos exp floor log round sin sqrt tan max min atan2 pow | array, scalar, in-place and reversed forms |
| Reduction | any all sum prod norm2squared norm2 norminf norm1 sup inf | scalar result |
| Utility | argmin argmax random assign assigns equals | indices, mutation or comparison |
import ndarray from 'ndarray'
import { add, sum } from '@stackline/ndarray-ops'
const left = ndarray(new Float64Array([1, 2, 3, 4]), [2, 2])
const right = ndarray(new Float64Array([4, 3, 2, 1]), [2, 2])
const out = ndarray(new Float64Array(4), [2, 2])
add(out, left, right)
console.log(sum(out)) // 20
Adoption
An exact npm alias lets existing require('ndarray-ops'), import ... from 'ndarray-ops', and deep-entry imports remain unchanged.
{
"dependencies": {
"ndarray-ops": "npm:@stackline/[email protected]"
}
}
Run the downstream's own install, test, type, lint, build and layout-specific smoke gates. Invalid view metadata is the intentional compatibility boundary; valid operation behavior remains the migration contract.
Release evidence
Verification guide · Full compatibility contract · Migration guide · Security policy
This package is independently maintained and is not affiliated with or endorsed by Mikola Lysenko, the scijs organization, or DefinitelyTyped. The original runtime and declaration attribution is preserved under the MIT license.