A single include for various useful ndarray packages
This module packages up
ndarray and other related modules into a single include. The goal is to be a single-stop ndarray-based module (similar to SciPy).
Browserify scans for every module that is
require()d, so Browserify-ing the larger bundle ends up packaging up a bunch of things you don't need.
This module also includes code-generation, so you can generate your own version of the bundle that only includes the modules you need. This means you can work with the comprehensive bundle during dev, but swap it out for a compatible, minimal bundle when you know which modules you need.
When included as a Node module, the result is based on the
var ndarray = require'ndarray-bundle';var arr1 = ndarray100 10 10;
However, other modules are included and added to this bundle, e.g.:
var matrix = ndarrayzeros4 4; // included from the "zeros" modulendarrayfillnd1 // included from "ndarray-fill"return i + j;;
Some of the modules are grouped together by functionality:
assertndarraysignalsfft; // included from the "ndarray-fft" moduleassertndarraysignalsconvolve; // included from the "ndarray-convolve" module
The structure of the included modules is defined in
When bundling up using a tool like Browserify, you don't want to
require() modules that you're not using.
As such, you can generate code that just includes the modules you need. You'll probably do this as part of your build script (so
ndarray-bundle is only a dev-dependency):
var codeGen = require'ndarray-bundle/generate';codeGengenerateFile'./ndarray-bundle.js'; // writes to file, including all known modules by defaultvar jsCode = codeGengenerateString; // or get as string
To select certain packages, you can specify the packages you need by supplying an object argument:
codeGengenerateFile'./ndarray-bundle.js'ops: truecomplex: truesignal: true;
The structure of this argument is recursive. If you want to pick and choose from sub-groups, then you can supply an object instead of
codeGengenerateFile'./ndarray-bundle.js'ops: truecomplex: truesignal:fft: true;
You can also enhance this structure with other modules, by providing a string:
codeGengenerateFile'./my-ndarray-bundle.js'ops: truemyCustomModule: 'ndarray-my-custom-module';
The resulting code only references the modules you want, but it maintains the same data structure. This means that if you only reference
my-ndarray-bundle.js, then Browserify will only package up the modules you need.