scijs/ndarray
📈 Multidimensional arrays for JavaScript
What it solves
JavaScript lacks a native, efficient way to handle multidimensional data structures like matrices or image buffers. ndarray solves this by providing a way to represent and manipulate multidimensional data using simple 1D arrays as the underlying storage, avoiding the need to copy data when performing common operations.
How it works
It creates a "view" of a 1D array (such as a Float64Array or standard array) by defining a shape, stride, and offset. Because these views are just mathematical projections onto the original data, operations like transposing, slicing, or flipping axes happen in constant time without duplicating the underlying memory. You can access or modify specific elements using .get() and .set() methods.
Who it’s for
This library is designed for developers building data-heavy applications in JavaScript or Node.js, such as those working with images, audio processing, volume graphics, or scientific computing, who need performance similar to tools like NumPy or MATLAB.
Highlights
- Constant-time operations for transposing, shearing, flipping, and slicing.
- Supports both row-major and column-major memory layouts.
- Compatible with standard typed arrays and generic JavaScript arrays.
- Lightweight and modular, designed to work in both Node.js and browser environments (via browserify).
Related
- Project
- Project
- Project
- Project