MatVecOp { public static Vector plus(Vector vec1, Vector vec2) { return vec1.plus(vec2); }  static Vector plus(Vector vec1, Vector vec2); static Vector minus(Vector vec1, Vector vec2); static double dot(Vector vec1, Vector vec2); static double sumAbsDiff(Vector vec1, Vector vec2); static double sumSquaredDiff(Vector vec1, Vector vec2); static void apply(DenseMatrix x, DenseMatrix y, Function<Double, Double> func); static void apply(DenseMatrix x1, DenseMatrix x2, DenseMatrix y,
                             BiFunction<Double, Double, Double> func); static void apply(DenseVector x, DenseVector y, Function<Double, Double> func); static void apply(DenseVector x1, DenseVector x2, DenseVector y,
                             BiFunction<Double, Double, Double> func); static SparseVector apply(SparseVector x1, SparseVector x2, BiFunction<Double, Double, Double> func); static double applySum(DenseVector x1, DenseVector x2, BiFunction<Double, Double, Double> func); static double applySum(SparseVector x1, SparseVector x2, BiFunction<Double, Double, Double> func); static double applySum(DenseVector x1, SparseVector x2, BiFunction<Double, Double, Double> func); static double applySum(SparseVector x1, DenseVector x2, BiFunction<Double, Double, Double> func); static double applySum(DenseMatrix x1, DenseMatrix x2, BiFunction<Double, Double, Double> func); static void appendVectorToMatrix(DenseMatrix matrix, boolean trans, int index, Vector vector);  }
@Test public void testPlus() throws Exception { Vector plusResult1 = MatVecOp.plus(dv, sv); Vector plusResult2 = MatVecOp.plus(sv, dv); Vector plusResult3 = MatVecOp.plus(sv, sv); Vector plusResult4 = MatVecOp.plus(dv, dv); Assert.assertTrue(plusResult1 instanceof DenseVector); Assert.assertTrue(plusResult2 instanceof DenseVector); Assert.assertTrue(plusResult3 instanceof SparseVector); Assert.assertTrue(plusResult4 instanceof DenseVector); Assert.assertArrayEquals(((DenseVector) plusResult1).getData(), new double[]{2, 2, 4, 4}, TOL); Assert.assertArrayEquals(((DenseVector) plusResult2).getData(), new double[]{2, 2, 4, 4}, TOL); Assert.assertArrayEquals(((SparseVector) plusResult3).getIndices(), new int[]{0, 2}); Assert.assertArrayEquals(((SparseVector) plusResult3).getValues(), new double[]{2., 2.}, TOL); Assert.assertArrayEquals(((DenseVector) plusResult4).getData(), new double[]{2, 4, 6, 8}, TOL); }