Maintained npm package

@stackline/ndarray-ops

The complete historical ndarray operation surface, implemented without runtime string compilation or production dependencies.

Start here

Install the scoped package

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.

CommonJS

const ops = require('@stackline/ndarray-ops')
ops.assign(destination, source)

ES modules

import ops, { add, sum } from '@stackline/ndarray-ops'
add(out, left, right)

Compatibility

Static implementation, historical behavior

150 operations

Export names, insertion order, arities, function names, mutation, return values, scalar and reversed-operand families match [email protected].

Layout fidelity

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.

Strict CSP

No eval or new Function is used. Loading and execution work when string code generation is prohibited.

Malformed-input hardening

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

The complete fixed API

Public operation families and examples
FamilyOperationsVariants
Arithmeticadd sub mul div modeq, s, seq
Bitwiseband bor bxor lshift rshift rrshifteq, s, seq
Logic and comparisonand or eq neq lt gt leq geqarray, scalar and in-place
Mathabs acos asin atan ceil cos exp floor log round sin sqrt tan max min atan2 powarray, scalar, in-place and reversed forms
Reductionany all sum prod norm2squared norm2 norminf norm1 sup infscalar result
Utilityargmin argmax random assign assigns equalsindices, 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

Keep the historical import key

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

What the package gate covers

Verification guide · Full compatibility contract · Migration guide · Security policy

Independent maintenance and attribution

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.