SymmetricMatrix { public static void lsolve(Matrix S, SubMatrix B, boolean clone) { Matrix Q = S; if (clone) { Q = Q.clone(); } lcholesky(Q); LowerTriangularMatrix.rsolve(Q, B.transpose()); LowerTriangularMatrix.lsolve(Q, B); } private  SymmetricMatrix(); static void fromLower(final Matrix m); static void fromLower(final SubMatrix m); static void fromUpper(final Matrix m); static void fromUpper(final SubMatrix m); static Matrix inverse(final Matrix s); static boolean isDPos(Matrix m, boolean useM); static boolean isSymmetric(Matrix m, double eps); static void lcholesky(final Matrix m); static void lcholesky(final Matrix m, double Zero); static Matrix LLt(final Matrix lower); static double quadraticForm(final Matrix S, final DataBlock x); static double quadraticForm(final Matrix s, final double[] x); static Matrix quadraticForm(final Matrix s, final Matrix x); static double quadraticForm(final SubMatrix M, final DataBlock x); static Matrix quadraticForm(final SubMatrix s, final SubMatrix x); static void quadraticForm(final SubMatrix s, final SubMatrix x,
            final SubMatrix xtsx); static Matrix quadraticFormT(final Matrix s, final Matrix x); static Matrix quadraticFormT(final SubMatrix s, final SubMatrix x); static void quadraticFormT(final SubMatrix s, final SubMatrix x,
            final SubMatrix xsxt); static void rcumul(Matrix m); static void rcumul(Matrix m, double delta); static void rcumul(Matrix m, double delta, int lag); static void rcumul(Matrix m, int lag); static void reinforceSymmetry(final Matrix m); static void reinforceSymmetry(final SubMatrix m); static void ucholesky(final Matrix s); static Matrix UtU(final Matrix upper); static Matrix XpXt(final Matrix x); static void XpXt(final SubMatrix m, final SubMatrix o); static Matrix XtX(final Matrix x); static void XtX(final SubMatrix x, final SubMatrix m); static Matrix XXt(final Matrix x); static void XXt(final SubMatrix x, final SubMatrix m); static void addXaXt(Matrix S, double a, DataBlock x); static void rsolve(Matrix S, SubMatrix B, boolean clone); static void lsolve(Matrix S, SubMatrix B, boolean clone); static void solve(Matrix S, DataBlock b, boolean clone); static void rsolve(Matrix S, DataBlock b, boolean clone); static Matrix CCt(DataBlock x);  }
@Test public void testLSolve() { Matrix X = new Matrix(5, 8); X.randomize(); Matrix S = SymmetricMatrix.XXt(X); Matrix A = new Matrix(3, 5); A.randomize(); Matrix B1 = A.clone(); Matrix B2 = Matrix.lsolve(S.subMatrix(), A.subMatrix()); SymmetricMatrix.lsolve(S, B1.subMatrix(), true); Matrix D = B1.minus(B2); assertTrue(D.nrm2() < 1e-9); }