@Test public void testSymmMatrix() { System.out.println("SymmMatrix"); double[][] A = { {0.9000f, 0.4000f, 0.0000f}, {0.4000f, 0.5000f, 0.3000f}, {0.0000f, 0.3000f, 0.8000f} }; double[] b = {0.5f, 0.5f, 0.5f}; Matrix a = new Matrix(A); Matrix.LU lu = a.lu(); double[] x = lu.solve(b); SymmMatrix symm = new SymmMatrix(UPLO.LOWER, A); double[] y = a.mv(x); double[] y2 = symm.mv(x); for (int i = 0; i < y.length; i++) { assertEquals(y[i], y2[i], 1E-7f); } SymmMatrix.BunchKaufman bk = symm.bk(); double[] bkx = bk.solve(b); assertEquals(lu.det(), bk.det(), 1E-7f); assertEquals(x.length, bkx.length); for (int i = 0; i < x.length; i++) { assertEquals(x[i], bkx[i], 1E-7f); } SymmMatrix.Cholesky cholesky = symm.cholesky(); double[] choleskyx = cholesky.solve(b); assertEquals(lu.det(), cholesky.det(), 1E-7f); assertEquals(choleskyx.length, x.length); for (int i = 0; i < x.length; i++) { assertEquals(x[i], choleskyx[i], 1E-6f); } symm = new SymmMatrix(UPLO.UPPER, A); y = a.mv(x); y2 = symm.mv(x); for (int i = 0; i < y.length; i++) { assertEquals(y[i], y2[i], 1E-7f); } bk = symm.bk(); bkx = bk.solve(b); assertEquals(lu.det(), bk.det(), 1E-7f); assertEquals(x.length, bkx.length); for (int i = 0; i < x.length; i++) { assertEquals(x[i], bkx[i], 1E-6f); } cholesky = symm.cholesky(); choleskyx = cholesky.solve(b); assertEquals(lu.det(), cholesky.det(), 1E-7f); assertEquals(choleskyx.length, x.length); for (int i = 0; i < x.length; i++) { assertEquals(x[i], choleskyx[i], 1E-7f); } }
public SymmMatrix(UPLO uplo, int n) { if (uplo == null) { throw new NullPointerException("UPLO is null"); } this.uplo = uplo; this.n = n; this.AP = new double[n * (n+1) / 2]; }
SymmMatrix extends DMatrix { public SymmMatrix(UPLO uplo, int n) { if (uplo == null) { throw new NullPointerException("UPLO is null"); } this.uplo = uplo; this.n = n; this.AP = new double[n * (n+1) / 2]; } }
SymmMatrix extends DMatrix { public SymmMatrix(UPLO uplo, int n) { if (uplo == null) { throw new NullPointerException("UPLO is null"); } this.uplo = uplo; this.n = n; this.AP = new double[n * (n+1) / 2]; } SymmMatrix(UPLO uplo, int n);  SymmMatrix(UPLO uplo, double[][] AP); }
SymmMatrix extends DMatrix { public SymmMatrix(UPLO uplo, int n) { if (uplo == null) { throw new NullPointerException("UPLO is null"); } this.uplo = uplo; this.n = n; this.AP = new double[n * (n+1) / 2]; } SymmMatrix(UPLO uplo, int n);  SymmMatrix(UPLO uplo, double[][] AP); @Override SymmMatrix clone(); @Override int nrows(); @Override int ncols(); @Override long size(); Layout layout(); UPLO uplo(); @Override boolean equals(Object o); boolean equals(SymmMatrix o, double eps); @Override double get(int i, int j); @Override SymmMatrix set(int i, int j, double x); @Override void mv(Transpose trans, double alpha, double[] x, double beta, double[] y); @Override void mv(double[] work, int inputOffset, int outputOffset); @Override void tv(double[] work, int inputOffset, int outputOffset); BunchKaufman bk(); Cholesky cholesky(); }
SymmMatrix extends DMatrix { public SymmMatrix(UPLO uplo, int n) { if (uplo == null) { throw new NullPointerException("UPLO is null"); } this.uplo = uplo; this.n = n; this.AP = new double[n * (n+1) / 2]; } SymmMatrix(UPLO uplo, int n);  SymmMatrix(UPLO uplo, double[][] AP); @Override SymmMatrix clone(); @Override int nrows(); @Override int ncols(); @Override long size(); Layout layout(); UPLO uplo(); @Override boolean equals(Object o); boolean equals(SymmMatrix o, double eps); @Override double get(int i, int j); @Override SymmMatrix set(int i, int j, double x); @Override void mv(Transpose trans, double alpha, double[] x, double beta, double[] y); @Override void mv(double[] work, int inputOffset, int outputOffset); @Override void tv(double[] work, int inputOffset, int outputOffset); BunchKaufman bk(); Cholesky cholesky();  }