@Test public void testGemmDenseDenseDense() { double alpha = 1.0; DenseMatrix a = new DenseMatrix(new double[][] {{10.0, 11.0}, {0.0, 1.0}}); DenseMatrix b = new DenseMatrix(new double[][] {{1.0, 0.3}, {0.0, 1.0}}); double beta = 0.0; DenseMatrix c = new DenseMatrix(new double[][] {{1.0, 2.0}, {2.0, 3.0}}); DenseMatrix exp = (DenseMatrix)a.times(b); Blas.gemm(alpha, a, b, beta, c); Assert.assertEquals(exp, c); }
public static void gemm(double alpha, Matrix a, Matrix b, double beta, Matrix c) { if (alpha == 0.0 && beta == 1.0) return; else if (alpha == 0.0) scal(c, beta); else { double[] fA = a.getStorage().data(); double[] fB = b.getStorage().data(); double[] fC = c.getStorage().data(); assert fA != null; nativeBlas.dgemm("N", "N", a.rowSize(), b.columnSize(), a.columnSize(), alpha, fA, a.rowSize(), fB, b.rowSize(), beta, fC, c.rowSize()); if (c instanceof SparseMatrix) MatrixUtil.unflatten(fC, c); } }
Blas { public static void gemm(double alpha, Matrix a, Matrix b, double beta, Matrix c) { if (alpha == 0.0 && beta == 1.0) return; else if (alpha == 0.0) scal(c, beta); else { double[] fA = a.getStorage().data(); double[] fB = b.getStorage().data(); double[] fC = c.getStorage().data(); assert fA != null; nativeBlas.dgemm("N", "N", a.rowSize(), b.columnSize(), a.columnSize(), alpha, fA, a.rowSize(), fB, b.rowSize(), beta, fC, c.rowSize()); if (c instanceof SparseMatrix) MatrixUtil.unflatten(fC, c); } } }
Blas { public static void gemm(double alpha, Matrix a, Matrix b, double beta, Matrix c) { if (alpha == 0.0 && beta == 1.0) return; else if (alpha == 0.0) scal(c, beta); else { double[] fA = a.getStorage().data(); double[] fB = b.getStorage().data(); double[] fC = c.getStorage().data(); assert fA != null; nativeBlas.dgemm("N", "N", a.rowSize(), b.columnSize(), a.columnSize(), alpha, fA, a.rowSize(), fB, b.rowSize(), beta, fC, c.rowSize()); if (c instanceof SparseMatrix) MatrixUtil.unflatten(fC, c); } }  }
Blas { public static void gemm(double alpha, Matrix a, Matrix b, double beta, Matrix c) { if (alpha == 0.0 && beta == 1.0) return; else if (alpha == 0.0) scal(c, beta); else { double[] fA = a.getStorage().data(); double[] fB = b.getStorage().data(); double[] fC = c.getStorage().data(); assert fA != null; nativeBlas.dgemm("N", "N", a.rowSize(), b.columnSize(), a.columnSize(), alpha, fA, a.rowSize(), fB, b.rowSize(), beta, fC, c.rowSize()); if (c instanceof SparseMatrix) MatrixUtil.unflatten(fC, c); } }  static void axpy(Double a, Vector x, Vector y); static Double dot(Vector x, Vector y); void copy(Vector x, Vector y); static void scal(Double a, Vector x); static void spr(Double alpha, DenseVector v, DenseVector u); static void spr(Double alpha, SparseVector v, DenseVector u); static void syr(Double alpha, SparseVector x, DenseMatrix a); static void gemm(double alpha, Matrix a, Matrix b, double beta, Matrix c); static void gemv(double alpha, Matrix a, Vector x, double beta, Vector y); static void checkCardinality(Matrix a, Vector v); }
Blas { public static void gemm(double alpha, Matrix a, Matrix b, double beta, Matrix c) { if (alpha == 0.0 && beta == 1.0) return; else if (alpha == 0.0) scal(c, beta); else { double[] fA = a.getStorage().data(); double[] fB = b.getStorage().data(); double[] fC = c.getStorage().data(); assert fA != null; nativeBlas.dgemm("N", "N", a.rowSize(), b.columnSize(), a.columnSize(), alpha, fA, a.rowSize(), fB, b.rowSize(), beta, fC, c.rowSize()); if (c instanceof SparseMatrix) MatrixUtil.unflatten(fC, c); } }  static void axpy(Double a, Vector x, Vector y); static Double dot(Vector x, Vector y); void copy(Vector x, Vector y); static void scal(Double a, Vector x); static void spr(Double alpha, DenseVector v, DenseVector u); static void spr(Double alpha, SparseVector v, DenseVector u); static void syr(Double alpha, SparseVector x, DenseMatrix a); static void gemm(double alpha, Matrix a, Matrix b, double beta, Matrix c); static void gemv(double alpha, Matrix a, Vector x, double beta, Vector y); static void checkCardinality(Matrix a, Vector v);  }