matrix/invert

matrix/invert

A library for inverting matrices and pseudo inverse

Methods

(static) invert(self) → {matrix}

Source:

Calculates the inverse of a matrix via Gaussian elimination

Example
// Invert a non-singular matrix 
var M = require('./src/matrix_lib');
var A = new M([[1,2,3],[4,5,6],[7,8,5]]); // non singular matrix
console.log(A.invert().print());
// result: 
//-1.917          1.167           -0.250
//1.833           -1.333          0.500
//-0.250          0.500           -0.250
Parameters:
Name Type Description
self matrix

Adds a scalar/array/matrix to self

Returns:
Type
matrix

(static) pinv(self) → {matrix}

Source:

Calculates the pseudoinverse of a matrix via SVD

Example
// Invert a singular matrix 
var M = require('./src/matrix_lib');
var A = new M([[1,2,3],[4,5,6],[7,8,9]]); // Singular matrix
console.log(A.pinv().print());
// result: 
//-0.639          -0.167          0.306
//-0.056          -0.000          0.056
//0.528           0.167           -0.194
Parameters:
Name Type Description
self matrix

Adds a scalar/array/matrix to self

Returns:
Type
matrix