MatVecOp { public static Vector minus(Vector vec1, Vector vec2) { return vec1.minus(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 testMinus() throws Exception { Vector minusResult1 = MatVecOp.minus(dv, sv); Vector minusResult2 = MatVecOp.minus(sv, dv); Vector minusResult3 = MatVecOp.minus(sv, sv); Vector minusResult4 = MatVecOp.minus(dv, dv); Assert.assertTrue(minusResult1 instanceof DenseVector); Assert.assertTrue(minusResult2 instanceof DenseVector); Assert.assertTrue(minusResult3 instanceof SparseVector); Assert.assertTrue(minusResult4 instanceof DenseVector); Assert.assertArrayEquals(((DenseVector) minusResult1).getData(), new double[]{0, 2, 2, 4}, TOL); Assert.assertArrayEquals(((DenseVector) minusResult2).getData(), new double[]{0, -2, -2, -4}, TOL); Assert.assertArrayEquals(((SparseVector) minusResult3).getIndices(), new int[]{0, 2}); Assert.assertArrayEquals(((SparseVector) minusResult3).getValues(), new double[]{0., 0.}, TOL); Assert.assertArrayEquals(((DenseVector) minusResult4).getData(), new double[]{0, 0, 0, 0}, TOL); }