Blas { void syr(Double alpha, Vector x, DenseMatrix a) { int mA = a.rowSize(); int nA = a.columnSize(); if (mA != nA) throw new NonSquareMatrixException(mA, nA); if (mA != x.size()) throw new CardinalityException(x.size(), mA); if (x instanceof DenseVector) syr(alpha, x, a); else if (x instanceof SparseVector) syr(alpha, x, a); else throw new IllegalArgumentException("Operation 'syr' does not support vector [class=" + x.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);  }
@Test public void testSyrDenseDense() { double alpha = 2.0; DenseVector x = new DenseVector(new double[] {1.0, 2.0}); DenseMatrix a = new DenseMatrix(new double[][] {{10.0, 20.0}, {20.0, 10.0}}); DenseMatrix exp = (DenseMatrix)new DenseMatrix(new double[][] { {1.0, 2.0}, {2.0, 4.0}}).times(alpha).plus(a); Blas.syr(alpha, x, a); Assert.assertEquals(exp, a); }
@Test(expected = NonSquareMatrixException.class) public void testSyrNonSquareMatrix() { double alpha = 3.0; DenseMatrix a = new DenseMatrix(new double[][] {{10.0, 11.0, 12.0}, {0.0, 1.0, 2.0}}, 2); Vector x = new DenseVector(new double[] {1.0, 2.0}); new Blas().syr(alpha, x, a); }