matrix-ds
v1.0.0
Published
a sample matrix dsa in js
Downloads
2
Readme
Matrix in JavaScript
This a simple Data Structure of a Matrix using Javascript
Work for to create the matrix, modify values in the matrix and
print on terminal.
npm i matrix-ds
How to create a matrix with this package?
const matrixInit = require('matrix-ds');
// length_row and length_column -> can be anything integer
let matrix = matrixInit(length_row, length_column);
For length_row = 4 and length_column = 4
Output:
0 0 0 0
0 0 0 0
0 0 0 0
Modify Values
matrix.values[index_row][index_column] = value;
let matrix = require('matrix-ds');
matrix = matrix(3, 4);
for (let i = 0; i < 3; i++) {
for (let j = 0; j < 4; j++) {
matrix.values[i][j] = i + j * 2;
}
}
Print output
matrix.printMatrix();