@Test public void testSubmatrix() { Matrix sub = matrix.submatrix(0, 1, 2, 2); assertEquals(false, matrix.isSubmatrix()); assertEquals(true, sub.isSubmatrix()); assertEquals(3, sub.nrows()); assertEquals(2, sub.ncols()); assertEquals(0.4, sub.get(0,0), 1E-7f); assertEquals(0.8, sub.get(2,1), 1E-7f); Matrix sub2 = sub.submatrix(0, 0, 1, 1); assertEquals(true, sub2.isSubmatrix()); assertEquals(2, sub2.nrows()); assertEquals(2, sub2.ncols()); assertEquals(0.4, sub.get(0,0), 1E-7f); assertEquals(0.3, sub.get(1,1), 1E-7f); }
public Matrix submatrix(int i, int j, int k, int l) { if (i < 0 || i >= m || k < i || k >= m || j < 0 || j >= n || l < j || l >= n) { throw new IllegalArgumentException(String.format("Invalid submatrix range (%d:%d, %d:%d) of %d x %d", i, k, j, l, m, n)); } int offset = index(i, j); int length = index(k, l) - offset + 1; DoubleBuffer B = DoubleBuffer.wrap(A.array(), offset, length); return of(layout(),k - i + 1, l - j + 1, ld, B); }
Matrix extends DMatrix { public Matrix submatrix(int i, int j, int k, int l) { if (i < 0 || i >= m || k < i || k >= m || j < 0 || j >= n || l < j || l >= n) { throw new IllegalArgumentException(String.format("Invalid submatrix range (%d:%d, %d:%d) of %d x %d", i, k, j, l, m, n)); } int offset = index(i, j); int length = index(k, l) - offset + 1; DoubleBuffer B = DoubleBuffer.wrap(A.array(), offset, length); return of(layout(),k - i + 1, l - j + 1, ld, B); } }
Matrix extends DMatrix { public Matrix submatrix(int i, int j, int k, int l) { if (i < 0 || i >= m || k < i || k >= m || j < 0 || j >= n || l < j || l >= n) { throw new IllegalArgumentException(String.format("Invalid submatrix range (%d:%d, %d:%d) of %d x %d", i, k, j, l, m, n)); } int offset = index(i, j); int length = index(k, l) - offset + 1; DoubleBuffer B = DoubleBuffer.wrap(A.array(), offset, length); return of(layout(),k - i + 1, l - j + 1, ld, B); } 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 Matrix submatrix(int i, int j, int k, int l) { if (i < 0 || i >= m || k < i || k >= m || j < 0 || j >= n || l < j || l >= n) { throw new IllegalArgumentException(String.format("Invalid submatrix range (%d:%d, %d:%d) of %d x %d", i, k, j, l, m, n)); } int offset = index(i, j); int length = index(k, l) - offset + 1; DoubleBuffer B = DoubleBuffer.wrap(A.array(), offset, length); return of(layout(),k - i + 1, l - j + 1, ld, B); } 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 Matrix submatrix(int i, int j, int k, int l) { if (i < 0 || i >= m || k < i || k >= m || j < 0 || j >= n || l < j || l >= n) { throw new IllegalArgumentException(String.format("Invalid submatrix range (%d:%d, %d:%d) of %d x %d", i, k, j, l, m, n)); } int offset = index(i, j); int length = index(k, l) - offset + 1; DoubleBuffer B = DoubleBuffer.wrap(A.array(), offset, length); return of(layout(),k - i + 1, l - j + 1, ld, B); } 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);  }