2d-mat

Create 2d matrices with superpower

Usage no npm install needed!

<script type="module">
  import dMat from 'https://cdn.skypack.dev/2d-mat';
</script>

README

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