1.0.2 • Published 9 years ago

ndarray-cartesian-product v1.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
9 years ago

ndarray-cartesian-product

Take any number of nd arrays and generate an nd array that is the cartesian product

#example:

var ndarray = require('ndarray');
var cartesian = require('narray-cartesian-product');
var a1 = ndarray([0,1]);
var a2 = ndarray([2,3,4]);
var a3 = ndarray([5,6,7,8]);
var ct = cartesian(a1, a2, a3);

ct will be a new 2d ndarray, where each row contains every possible permutation of an element from each array.

cartesian expects the arrays to be 1d, and that each array has an identical format. You cannot, for example, take a cartesian of an ndarray constructed from a Uint8Array and a regular javascript Array. Any attempt to do so will result in unhappy times.

#Methods: cartesian(args)

Computes the cartesian product from any number of ndarrays. You can either pass any number of ndarrays, or you can pass a single javascript array of ndarrays.

LICENSE: MIT