public static double [ ] [ ] pseudoInverse ( double [ ] [ ] matrix ) { if ( isSolverUseApacheCommonsMath ) { // Use LU from common math SingularValueDecomposition svd = new SingularValueDecomposition ( new Array2DRowRealMatrix ( matrix ) ) ; double [ ] [ ] matrixInverse = svd . getSolver ( ) . getInverse ( ) . getData ( ) ; return matrixInverse ; } else { return org . jblas . Solve . pinv ( new org . jblas . DoubleMatrix ( matrix ) ) . toArray2 ( ) ; } }
Pseudo - Inverse of a matrix calculated in the least square sense .