2d-mat 中文文档教程
2d-mat
创建具有超能力的多维矩阵
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, …]);
这将创建一个矩阵对象
list
类型:array
接受序列数组,其中每个数组是行的长度,数组的大小是列的长度。
The returned matrix is 0 indexed.
License MIT
© 2016 维克拉姆。 麻省理工执照
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