1.0.0 • Published 5 years ago
nmatrixjs v1.0.0
MatrixJs
MatrixJs is a small Javascript Library use to compute matrix
Usage
MatrixJs can do basic computing of matrix. such as - Finding Determinant, Transponse, Minor, Adjoint and more - Inversing
Tutorials
- First We Import
Matrixfrom MatrixJs
import Matrix from "./MatrixJS";- To Create a Matrix we initate a Matrix class with 2 Dimenstional Array
let MyMatrix = new Matrix([
[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
]);- To access the matrix use
console.log(MyMatrix.matrix);Size of Matrix
returns an array of row, column
let size = MyMatrix.size();
let [row, column] = MyMatrix.size();
console.log(size); // [3, 3]Determinant
let determinant = MyMatrix.det();or without creating a variable for the matrix
let determinant = new Matrix([
[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
]).det();Inverse
let inverse = MyMatrix.inverse();or you can just change the matrix by passing true as a parameter
MyMatrix.inverse(true);Transponse
let transposed = MyArray.transponse();or to change the Matrix itself pass true parameter
MyMatrix.transponse(true);
console.log(MyMatrix.matrix);
/*
[
[1, 4, 7],
[2, 5, 8],
[3, 6, 9]
]
*/Cofactor, Minor
Cofactor and Minor take two arguments row and column
let cofactor = MyMatrix.cofactor(0, 1); // 6
let minor = MyMatrix.minor(0, 0); // -61.0.0
5 years ago