@Test public void testAxpySparseArray() { DenseVector y = new DenseVector(new double[] {1.0, 2.0}); double a = 2.0; SparseVector x = sparseFromArray(new double[] {1.0, 2.0}); SparseVector exp = (SparseVector)x.times(a).plus(y); Blas.axpy(a, x, y); Assert.assertTrue(elementsEqual(exp, y)); }
public static void axpy(Double a, Vector x, Vector y) { if (x.size() != y.size()) throw new CardinalityException(x.size(), y.size()); if (x.isArrayBased() && y.isArrayBased()) axpy(a, x.getStorage().data(), y.getStorage().data()); else if (x instanceof SparseVector && y.isArrayBased()) axpy(a, (SparseVector)x, y.getStorage().data()); else throw new MathIllegalArgumentException("Operation 'axpy' doesn't support this combination of parameters [x=" + x.getClass().getName() + ", y=" + y.getClass().getName() + "]."); }
Blas { public static void axpy(Double a, Vector x, Vector y) { if (x.size() != y.size()) throw new CardinalityException(x.size(), y.size()); if (x.isArrayBased() && y.isArrayBased()) axpy(a, x.getStorage().data(), y.getStorage().data()); else if (x instanceof SparseVector && y.isArrayBased()) axpy(a, (SparseVector)x, y.getStorage().data()); else throw new MathIllegalArgumentException("Operation 'axpy' doesn't support this combination of parameters [x=" + x.getClass().getName() + ", y=" + y.getClass().getName() + "]."); } }
Blas { public static void axpy(Double a, Vector x, Vector y) { if (x.size() != y.size()) throw new CardinalityException(x.size(), y.size()); if (x.isArrayBased() && y.isArrayBased()) axpy(a, x.getStorage().data(), y.getStorage().data()); else if (x instanceof SparseVector && y.isArrayBased()) axpy(a, (SparseVector)x, y.getStorage().data()); else throw new MathIllegalArgumentException("Operation 'axpy' doesn't support this combination of parameters [x=" + x.getClass().getName() + ", y=" + y.getClass().getName() + "]."); }  }
Blas { public static void axpy(Double a, Vector x, Vector y) { if (x.size() != y.size()) throw new CardinalityException(x.size(), y.size()); if (x.isArrayBased() && y.isArrayBased()) axpy(a, x.getStorage().data(), y.getStorage().data()); else if (x instanceof SparseVector && y.isArrayBased()) axpy(a, (SparseVector)x, y.getStorage().data()); else throw new MathIllegalArgumentException("Operation 'axpy' doesn't support this combination of parameters [x=" + x.getClass().getName() + ", y=" + y.getClass().getName() + "]."); }  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 axpy(Double a, Vector x, Vector y) { if (x.size() != y.size()) throw new CardinalityException(x.size(), y.size()); if (x.isArrayBased() && y.isArrayBased()) axpy(a, x.getStorage().data(), y.getStorage().data()); else if (x instanceof SparseVector && y.isArrayBased()) axpy(a, (SparseVector)x, y.getStorage().data()); else throw new MathIllegalArgumentException("Operation 'axpy' doesn't support this combination of parameters [x=" + x.getClass().getName() + ", y=" + y.getClass().getName() + "]."); }  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);  }