@Test public void testGemvSparseSparseDense() { double alpha = 3.0; DenseMatrix a = new DenseMatrix(new double[][] {{10.0, 11.0}, {0.0, 1.0}}, 2); SparseVector x = sparseFromArray(new double[] {1.0, 2.0}); double beta = 2.0; DenseVector y = new DenseVector(new double[] {3.0, 4.0}); DenseVector exp = (DenseVector)y.times(beta).plus(a.times(x).times(alpha)); Blas.gemv(alpha, a, x, beta, y); Assert.assertEquals(exp, y); }
public static void gemv(double alpha, Matrix a, Vector x, double beta, Vector y) { checkCardinality(a, x); if (a.rowSize() != y.size()) throw new CardinalityException(a.columnSize(), y.size()); if (alpha == 0.0 && beta == 1.0) return; if (alpha == 0.0) { scal(y, beta); return; } double[] fA = a.getStorage().data(); double[] fX = x.getStorage().data(); double[] fY = y.getStorage().data(); nativeBlas.dgemv("N", a.rowSize(), a.columnSize(), alpha, fA, a.rowSize(), fX, 1, beta, fY, 1); if (y instanceof SparseVector) y.assign(fY); }
Blas { public static void gemv(double alpha, Matrix a, Vector x, double beta, Vector y) { checkCardinality(a, x); if (a.rowSize() != y.size()) throw new CardinalityException(a.columnSize(), y.size()); if (alpha == 0.0 && beta == 1.0) return; if (alpha == 0.0) { scal(y, beta); return; } double[] fA = a.getStorage().data(); double[] fX = x.getStorage().data(); double[] fY = y.getStorage().data(); nativeBlas.dgemv("N", a.rowSize(), a.columnSize(), alpha, fA, a.rowSize(), fX, 1, beta, fY, 1); if (y instanceof SparseVector) y.assign(fY); } }
Blas { public static void gemv(double alpha, Matrix a, Vector x, double beta, Vector y) { checkCardinality(a, x); if (a.rowSize() != y.size()) throw new CardinalityException(a.columnSize(), y.size()); if (alpha == 0.0 && beta == 1.0) return; if (alpha == 0.0) { scal(y, beta); return; } double[] fA = a.getStorage().data(); double[] fX = x.getStorage().data(); double[] fY = y.getStorage().data(); nativeBlas.dgemv("N", a.rowSize(), a.columnSize(), alpha, fA, a.rowSize(), fX, 1, beta, fY, 1); if (y instanceof SparseVector) y.assign(fY); }  }
Blas { public static void gemv(double alpha, Matrix a, Vector x, double beta, Vector y) { checkCardinality(a, x); if (a.rowSize() != y.size()) throw new CardinalityException(a.columnSize(), y.size()); if (alpha == 0.0 && beta == 1.0) return; if (alpha == 0.0) { scal(y, beta); return; } double[] fA = a.getStorage().data(); double[] fX = x.getStorage().data(); double[] fY = y.getStorage().data(); nativeBlas.dgemv("N", a.rowSize(), a.columnSize(), alpha, fA, a.rowSize(), fX, 1, beta, fY, 1); if (y instanceof SparseVector) y.assign(fY); }  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 gemv(double alpha, Matrix a, Vector x, double beta, Vector y) { checkCardinality(a, x); if (a.rowSize() != y.size()) throw new CardinalityException(a.columnSize(), y.size()); if (alpha == 0.0 && beta == 1.0) return; if (alpha == 0.0) { scal(y, beta); return; } double[] fA = a.getStorage().data(); double[] fX = x.getStorage().data(); double[] fY = y.getStorage().data(); nativeBlas.dgemv("N", a.rowSize(), a.columnSize(), alpha, fA, a.rowSize(), fX, 1, beta, fY, 1); if (y instanceof SparseVector) y.assign(fY); }  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);  }