/** Tests solve Ax = b from A and b. */ public void solveVector() { final CholeskyDecompositionResult result = CDOG.evaluate(A5); double[] b = new double[] {1.0, 2.0, 3.0, 4.0, -1.0}; double[] x = result.solve(b); DoubleMatrix1D ax = (DoubleMatrix1D) ALGEBRA.multiply(A5, new DoubleMatrix1D(x)); ArrayAsserts.assertArrayEquals( "Cholesky decomposition OpenGamma - solve", b, ax.getData(), 1.0E-10); }
/** Tests solve AX = B from A and B. */ public void solveMatrix() { final CholeskyDecompositionResult result = CDOG.evaluate(A5); double[][] b = new double[][] {{1.0, 2.0}, {2.0, 3.0}, {3.0, 4.0}, {4.0, -2.0}, {-1.0, -1.0}}; DoubleMatrix2D x = result.solve(new DoubleMatrix2D(b)); DoubleMatrix2D ax = (DoubleMatrix2D) ALGEBRA.multiply(A5, x); ArrayAsserts.assertArrayEquals( "Cholesky decomposition OpenGamma - solve", b[0], ax.getData()[0], 1.0E-10); ArrayAsserts.assertArrayEquals( "Cholesky decomposition OpenGamma - solve", b[1], ax.getData()[1], 1.0E-10); }
/** Compare results with Common decomposition */ public void compareCommon() { final CholeskyDecompositionResult resultOG = CDOG.evaluate(A3); final CholeskyDecompositionResult resultC = CDC.evaluate(A3); checkEquals(resultC.getL(), resultOG.getL()); checkEquals(ALGEBRA.getTranspose(resultC.getL()), resultOG.getLT()); assertEquals("Determinant", resultC.getDeterminant(), resultOG.getDeterminant(), 1.0E-10); }
/** Tests A = L L^T. */ public void recoverOrginal() { final CholeskyDecompositionResult result = CDOG.evaluate(A3); final DoubleMatrix2D a = (DoubleMatrix2D) ALGEBRA.multiply(result.getL(), result.getLT()); checkEquals(A3, a); }