1.0.0 • Published 8 years ago

2d-mat v1.0.0

Weekly downloads
36
License
MIT
Repository
github
Last release
8 years ago

2d-mat

Create multidimensional matrix with superpower

Install

$ npm install --save 2d-mat

Example

var Matrix = require('2d-mat');

var mat = new Matrix([1, 2], [3, 4]);

console.log(mat.indexAt(0, 1));
// -> 1

console.log(mat.set(0, 1, 100));
// -> [[100, 2], [3, 4]]

console.log(mat.transpose());
// -> [[1, 3], [2, 4]]

console.log(mat.size());
// -> [2, 2]

console.log(mat.createEmpty(2, 2));
// -> [[undefined, undefined], [undefined, undefined]]

mat.print();
// - > [[1, 2],
//      [3, 4]]

API

var Matrix = require('2d-mat');

new Matrix(list, ...);

This will create a matrix object

list

Type: array

Accepts sequence of array where each array is length of row and the size of the array is length columns.

The returned matrix is 0 indexed.

License MIT

© 2016 vikram. MIT License