@Test public void testLU() { System.out.println("LU"); double[][] A = { {0.9000, 0.4000, 0.7000f}, {0.4000, 0.5000, 0.3000f}, {0.7000, 0.3000, 0.8000f} }; double[] b = {0.5, 0.5, 0.5f}; double[] x = {-0.2027027, 0.8783784, 0.4729730f}; Matrix a = new Matrix(A); Matrix.LU lu = a.lu(); double[] x2 = lu.solve(b); assertEquals(x.length, x2.length); for (int i = 0; i < x.length; i++) { assertEquals(x[i], x2[i], 1E-7f); } double[][] B = { {0.5, 0.2f}, {0.5, 0.8f}, {0.5, 0.3f} }; double[][] X = { {-0.2027027, -1.2837838f}, { 0.8783784, 2.2297297f}, { 0.4729730, 0.6621622f} }; Matrix X2 = new Matrix(B); lu.solve(X2); assertEquals(X.length, X2.nrows()); assertEquals(X[0].length, X2.ncols()); for (int i = 0; i < X.length; i++) { for (int j = 0; j < X[i].length; j++) { assertEquals(X[i][j], X2.get(i, j), 1E-7f); } } }
public LU lu() { return lu(false); }
Matrix extends DMatrix { public LU lu() { return lu(false); } }
Matrix extends DMatrix { public LU lu() { return lu(false); } Matrix(int m, int n);  Matrix(int m, int n, double a);  Matrix(int m, int n, double[][] A);  Matrix(double[][] A);  Matrix(double[] A);  Matrix(double[] A, int offset, int length);  Matrix(int m, int n, int ld, DoubleBuffer A); }
Matrix extends DMatrix { public LU lu() { return lu(false); } Matrix(int m, int n);  Matrix(int m, int n, double a);  Matrix(int m, int n, double[][] A);  Matrix(double[][] A);  Matrix(double[] A);  Matrix(double[] A, int offset, int length);  Matrix(int m, int n, int ld, DoubleBuffer A); static Matrix of(Layout layout, int m, int n); static Matrix of(Layout layout, int m, int n, int ld, DoubleBuffer A); static Matrix eye(int n); static Matrix eye(int m, int n); static Matrix randn(int m, int n); static Matrix rand(int m, int n, Distribution distribution); static Matrix rand(int m, int n, double lo, double hi); static Matrix diag(double[] diag); static Matrix toeplitz(double[] a); static Matrix toeplitz(double[] kl, double[] ku); @Override int nrows(); @Override int ncols(); @Override long size(); Layout layout(); int ld(); boolean isSubmatrix(); boolean isSymmetric(); Matrix uplo(UPLO uplo); UPLO uplo(); Matrix triangular(Diag diag); Diag triangular(); @Override Matrix clone(); double[][] toArray(); Matrix submatrix(int i, int j, int k, int l); void fill(double x); Matrix transpose(); @Override boolean equals(Object o); boolean equals(Matrix o, double eps); @Override double get(int i, int j); @Override Matrix set(int i, int j, double x); Matrix set(int i, int j, Matrix B); double add(int i, int j, double b); double sub(int i, int j, double b); double mul(int i, int j, double b); double div(int i, int j, double b); Matrix add(double b); Matrix sub(double b); Matrix mul(double b); Matrix div(double b); Matrix add(int i, int j, double alpha, Matrix B); Matrix sub(int i, int j, double alpha, Matrix B); Matrix mul(int i, int j, double alpha, Matrix B); Matrix div(int i, int j, double alpha, Matrix B); Matrix add(double alpha, Matrix B); Matrix sub(double alpha, Matrix B); Matrix mul(double alpha, Matrix B); Matrix div(double alpha, Matrix B); Matrix add(double alpha, Matrix A, double beta, Matrix B); Matrix sub(double alpha, Matrix A, double beta, Matrix B); Matrix mul(double alpha, Matrix A, Matrix B); Matrix div(double alpha, Matrix A, Matrix B); double add(int i, int j, double alpha, double beta); Matrix add(int i, int j, double alpha, double beta, Matrix B); Matrix add(double alpha, double beta, Matrix B); Matrix add(double alpha, double[] x, double[] y); Matrix replaceNaN(double x); double sum(); double norm1(); double norm2(); double norm(); double normInf(); double normFro(); double xAx(double[] x); double[] rowSums(); double[] rowMeans(); double[] rowSds(); double[] colSums(); double[] colMeans(); double[] colSds(); Matrix scale(); Matrix scale(double[] center, double[] scale); Matrix inverse(); void mv(Transpose trans, double alpha, DoubleBuffer x, double beta, DoubleBuffer y); @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); void mm(Transpose transA, Transpose transB, double alpha, Matrix B, double beta, Matrix C); Matrix ata(); Matrix aat(); Matrix adb(Transpose transA, Transpose transB, Matrix B, double[] diag); Matrix mm(Matrix B); Matrix mt(Matrix B); Matrix tm(Matrix B); Matrix tt(Matrix B); LU lu(); LU lu(boolean overwrite); Cholesky cholesky(); Cholesky cholesky(boolean overwrite); QR qr(); QR qr(boolean overwrite); SVD svd(); SVD svd(boolean vectors, boolean overwrite); EVD eigen(); EVD eigen(boolean vl, boolean vr, boolean overwrite); }
Matrix extends DMatrix { public LU lu() { return lu(false); } Matrix(int m, int n);  Matrix(int m, int n, double a);  Matrix(int m, int n, double[][] A);  Matrix(double[][] A);  Matrix(double[] A);  Matrix(double[] A, int offset, int length);  Matrix(int m, int n, int ld, DoubleBuffer A); static Matrix of(Layout layout, int m, int n); static Matrix of(Layout layout, int m, int n, int ld, DoubleBuffer A); static Matrix eye(int n); static Matrix eye(int m, int n); static Matrix randn(int m, int n); static Matrix rand(int m, int n, Distribution distribution); static Matrix rand(int m, int n, double lo, double hi); static Matrix diag(double[] diag); static Matrix toeplitz(double[] a); static Matrix toeplitz(double[] kl, double[] ku); @Override int nrows(); @Override int ncols(); @Override long size(); Layout layout(); int ld(); boolean isSubmatrix(); boolean isSymmetric(); Matrix uplo(UPLO uplo); UPLO uplo(); Matrix triangular(Diag diag); Diag triangular(); @Override Matrix clone(); double[][] toArray(); Matrix submatrix(int i, int j, int k, int l); void fill(double x); Matrix transpose(); @Override boolean equals(Object o); boolean equals(Matrix o, double eps); @Override double get(int i, int j); @Override Matrix set(int i, int j, double x); Matrix set(int i, int j, Matrix B); double add(int i, int j, double b); double sub(int i, int j, double b); double mul(int i, int j, double b); double div(int i, int j, double b); Matrix add(double b); Matrix sub(double b); Matrix mul(double b); Matrix div(double b); Matrix add(int i, int j, double alpha, Matrix B); Matrix sub(int i, int j, double alpha, Matrix B); Matrix mul(int i, int j, double alpha, Matrix B); Matrix div(int i, int j, double alpha, Matrix B); Matrix add(double alpha, Matrix B); Matrix sub(double alpha, Matrix B); Matrix mul(double alpha, Matrix B); Matrix div(double alpha, Matrix B); Matrix add(double alpha, Matrix A, double beta, Matrix B); Matrix sub(double alpha, Matrix A, double beta, Matrix B); Matrix mul(double alpha, Matrix A, Matrix B); Matrix div(double alpha, Matrix A, Matrix B); double add(int i, int j, double alpha, double beta); Matrix add(int i, int j, double alpha, double beta, Matrix B); Matrix add(double alpha, double beta, Matrix B); Matrix add(double alpha, double[] x, double[] y); Matrix replaceNaN(double x); double sum(); double norm1(); double norm2(); double norm(); double normInf(); double normFro(); double xAx(double[] x); double[] rowSums(); double[] rowMeans(); double[] rowSds(); double[] colSums(); double[] colMeans(); double[] colSds(); Matrix scale(); Matrix scale(double[] center, double[] scale); Matrix inverse(); void mv(Transpose trans, double alpha, DoubleBuffer x, double beta, DoubleBuffer y); @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); void mm(Transpose transA, Transpose transB, double alpha, Matrix B, double beta, Matrix C); Matrix ata(); Matrix aat(); Matrix adb(Transpose transA, Transpose transB, Matrix B, double[] diag); Matrix mm(Matrix B); Matrix mt(Matrix B); Matrix tm(Matrix B); Matrix tt(Matrix B); LU lu(); LU lu(boolean overwrite); Cholesky cholesky(); Cholesky cholesky(boolean overwrite); QR qr(); QR qr(boolean overwrite); SVD svd(); SVD svd(boolean vectors, boolean overwrite); EVD eigen(); EVD eigen(boolean vl, boolean vr, boolean overwrite);  }