CholeskyDecomposition { public Matrix getL() { return L.getBase(); } CholeskyDecomposition(Matrix a);  CholeskyDecomposition(Matrix a, boolean pivot); boolean isPositiveDefinite(); Matrix getL(); PivotedMatrix getPermutedL(); int[] getPivot(); int[] getInversePivot(); Matrix solveLeft(Matrix z); Matrix solveRight(Matrix z);  }
@Test public void rank1() { Matrix x = new DenseMatrix(3, 3); x.viewRow(0).assign(new double[]{1, 2, 3}); x.viewRow(1).assign(new double[]{2, 4, 6}); x.viewRow(2).assign(new double[]{3, 6, 9}); CholeskyDecomposition rr = new CholeskyDecomposition(x.transpose().times(x), false); assertEquals(0, new DenseVector(new double[]{3.741657, 7.483315, 11.22497}).aggregate(rr.getL().transpose().viewRow(0), Functions.PLUS, new DoubleDoubleFunction() { @Override public double apply(double arg1, double arg2) { return Math.abs(arg1) - Math.abs(arg2); } }), 1.0e-5); assertEquals(0, rr.getL().viewPart(0, 3, 1, 2).aggregate(Functions.PLUS, Functions.ABS), 1.0e-9); }
@Test public void test2() { double[][] values = new double[3][]; values[0] = new double[]{1, -1, 1}; values[1] = new double[]{-1, 1, -1}; values[2] = new double[]{1, -1, 2}; Matrix A = new DenseMatrix(values); CholeskyDecomposition cd = new CholeskyDecomposition(A, false); assertEquals(0, cd.getL().times(cd.getL().transpose()).minus(A).aggregate(Functions.PLUS, Functions.ABS), 1.0e-10); cd = new CholeskyDecomposition(A); assertEquals(0, cd.getL().times(cd.getL().transpose()).minus(A).aggregate(Functions.PLUS, Functions.ABS), 1.0e-10); }