@Test public void testAx() { System.out.println("ax"); double[] d = new double[matrix.nrows()]; matrix.ax(b, d); assertEquals(0.65, d[0], 1E-7); assertEquals(0.60, d[1], 1E-7); assertEquals(0.55, d[2], 1E-7); }
@Override public double[] ax(double[] x, double[] y) { int m = nrows(); int n = ncols(); INDArray ndx = Nd4j.create(x, new int[]{n, 1}); INDArray ndy = Nd4j.create(m, 1); Nd4j.getBlasWrapper().level2().gemv(ColOrder, NoTranspose, 1.0, A, ndx, 0.0, ndy); for (int i = 0; i < m; i++) { y[i] = ndy.getDouble(i); } return y; }
NDMatrix implements DenseMatrix, Cloneable { @Override public double[] ax(double[] x, double[] y) { int m = nrows(); int n = ncols(); INDArray ndx = Nd4j.create(x, new int[]{n, 1}); INDArray ndy = Nd4j.create(m, 1); Nd4j.getBlasWrapper().level2().gemv(ColOrder, NoTranspose, 1.0, A, ndx, 0.0, ndy); for (int i = 0; i < m; i++) { y[i] = ndy.getDouble(i); } return y; } }
NDMatrix implements DenseMatrix, Cloneable { @Override public double[] ax(double[] x, double[] y) { int m = nrows(); int n = ncols(); INDArray ndx = Nd4j.create(x, new int[]{n, 1}); INDArray ndy = Nd4j.create(m, 1); Nd4j.getBlasWrapper().level2().gemv(ColOrder, NoTranspose, 1.0, A, ndx, 0.0, ndy); for (int i = 0; i < m; i++) { y[i] = ndy.getDouble(i); } return y; } NDMatrix(double[][] A);  NDMatrix(double[] A);  NDMatrix(INDArray A);  NDMatrix(int rows, int cols);  NDMatrix(int rows, int cols, double value); }
NDMatrix implements DenseMatrix, Cloneable { @Override public double[] ax(double[] x, double[] y) { int m = nrows(); int n = ncols(); INDArray ndx = Nd4j.create(x, new int[]{n, 1}); INDArray ndy = Nd4j.create(m, 1); Nd4j.getBlasWrapper().level2().gemv(ColOrder, NoTranspose, 1.0, A, ndx, 0.0, ndy); for (int i = 0; i < m; i++) { y[i] = ndy.getDouble(i); } return y; } NDMatrix(double[][] A);  NDMatrix(double[] A);  NDMatrix(INDArray A);  NDMatrix(int rows, int cols);  NDMatrix(int rows, int cols, double value); static NDMatrix eye(int n); @Override void fill(double x); @Override String toString(); @Override boolean isSymmetric(); @Override void setSymmetric(boolean symmetric); @Override NDMatrix clone(); @Override double[] data(); @Override int nrows(); @Override int ncols(); @Override double get(int i, int j); @Override double set(int i, int j, double x); @Override LU lu(); @Override Cholesky cholesky(); @Override QR qr(); @Override SVD svd(); @Override double[] eig(); @Override EVD eigen(); @Override double[] ax(double[] x, double[] y); @Override double[] axpy(double[] x, double[] y); @Override double[] axpy(double[] x, double[] y, double b); @Override double[] atx(double[] x, double[] y); @Override double[] atxpy(double[] x, double[] y); @Override double[] atxpy(double[] x, double[] y, double b); @Override NDMatrix ata(); @Override NDMatrix aat(); @Override double add(int i, int j, double x); @Override double sub(int i, int j, double x); @Override double mul(int i, int j, double x); @Override double div(int i, int j, double x); @Override NDMatrix abmm(DenseMatrix B); @Override NDMatrix abtmm(DenseMatrix B); @Override NDMatrix atbmm(DenseMatrix B); @Override NDMatrix atbtmm(DenseMatrix B); @Override NDMatrix add(DenseMatrix b); NDMatrix add(NDMatrix b); @Override DenseMatrix add(DenseMatrix b, DenseMatrix c); NDMatrix add(NDMatrix b, NDMatrix c); @Override NDMatrix sub(DenseMatrix b); NDMatrix sub(NDMatrix b); @Override DenseMatrix sub(DenseMatrix b, DenseMatrix c); NDMatrix sub(NDMatrix b, NDMatrix c); @Override NDMatrix mul(DenseMatrix b); NDMatrix mul(NDMatrix b); @Override DenseMatrix mul(DenseMatrix b, DenseMatrix c); NDMatrix mul(NDMatrix b, NDMatrix c); @Override NDMatrix div(DenseMatrix b); NDMatrix div(NDMatrix b); @Override DenseMatrix div(DenseMatrix b, DenseMatrix c); NDMatrix div(NDMatrix b, NDMatrix c); @Override NDMatrix add(double x); @Override DenseMatrix add(double x, DenseMatrix c); NDMatrix add(double x, NDMatrix c); @Override NDMatrix sub(double x); @Override DenseMatrix sub(double x, DenseMatrix c); NDMatrix sub(double x, NDMatrix c); @Override NDMatrix mul(double x); @Override DenseMatrix mul(double x, DenseMatrix c); NDMatrix mul(double x, NDMatrix c); @Override NDMatrix div(double x); @Override DenseMatrix div(double x, DenseMatrix c); NDMatrix div(double x, NDMatrix c); @Override double sum(); @Override NDMatrix transpose(); @Override NDMatrix inverse(); @Override NDMatrix inverse(boolean inPlace); }
NDMatrix implements DenseMatrix, Cloneable { @Override public double[] ax(double[] x, double[] y) { int m = nrows(); int n = ncols(); INDArray ndx = Nd4j.create(x, new int[]{n, 1}); INDArray ndy = Nd4j.create(m, 1); Nd4j.getBlasWrapper().level2().gemv(ColOrder, NoTranspose, 1.0, A, ndx, 0.0, ndy); for (int i = 0; i < m; i++) { y[i] = ndy.getDouble(i); } return y; } NDMatrix(double[][] A);  NDMatrix(double[] A);  NDMatrix(INDArray A);  NDMatrix(int rows, int cols);  NDMatrix(int rows, int cols, double value); static NDMatrix eye(int n); @Override void fill(double x); @Override String toString(); @Override boolean isSymmetric(); @Override void setSymmetric(boolean symmetric); @Override NDMatrix clone(); @Override double[] data(); @Override int nrows(); @Override int ncols(); @Override double get(int i, int j); @Override double set(int i, int j, double x); @Override LU lu(); @Override Cholesky cholesky(); @Override QR qr(); @Override SVD svd(); @Override double[] eig(); @Override EVD eigen(); @Override double[] ax(double[] x, double[] y); @Override double[] axpy(double[] x, double[] y); @Override double[] axpy(double[] x, double[] y, double b); @Override double[] atx(double[] x, double[] y); @Override double[] atxpy(double[] x, double[] y); @Override double[] atxpy(double[] x, double[] y, double b); @Override NDMatrix ata(); @Override NDMatrix aat(); @Override double add(int i, int j, double x); @Override double sub(int i, int j, double x); @Override double mul(int i, int j, double x); @Override double div(int i, int j, double x); @Override NDMatrix abmm(DenseMatrix B); @Override NDMatrix abtmm(DenseMatrix B); @Override NDMatrix atbmm(DenseMatrix B); @Override NDMatrix atbtmm(DenseMatrix B); @Override NDMatrix add(DenseMatrix b); NDMatrix add(NDMatrix b); @Override DenseMatrix add(DenseMatrix b, DenseMatrix c); NDMatrix add(NDMatrix b, NDMatrix c); @Override NDMatrix sub(DenseMatrix b); NDMatrix sub(NDMatrix b); @Override DenseMatrix sub(DenseMatrix b, DenseMatrix c); NDMatrix sub(NDMatrix b, NDMatrix c); @Override NDMatrix mul(DenseMatrix b); NDMatrix mul(NDMatrix b); @Override DenseMatrix mul(DenseMatrix b, DenseMatrix c); NDMatrix mul(NDMatrix b, NDMatrix c); @Override NDMatrix div(DenseMatrix b); NDMatrix div(NDMatrix b); @Override DenseMatrix div(DenseMatrix b, DenseMatrix c); NDMatrix div(NDMatrix b, NDMatrix c); @Override NDMatrix add(double x); @Override DenseMatrix add(double x, DenseMatrix c); NDMatrix add(double x, NDMatrix c); @Override NDMatrix sub(double x); @Override DenseMatrix sub(double x, DenseMatrix c); NDMatrix sub(double x, NDMatrix c); @Override NDMatrix mul(double x); @Override DenseMatrix mul(double x, DenseMatrix c); NDMatrix mul(double x, NDMatrix c); @Override NDMatrix div(double x); @Override DenseMatrix div(double x, DenseMatrix c); NDMatrix div(double x, NDMatrix c); @Override double sum(); @Override NDMatrix transpose(); @Override NDMatrix inverse(); @Override NDMatrix inverse(boolean inPlace);  }