@Test(expected = IllegalArgumentException.class) public void testSubtractAbnormal() { double[] arr1 = new double[] {1, 2, 3}; double[] arr2 = new double[] {4, 5}; DoubleVector vec1 = new DenseDoubleVector(arr1); DoubleVector vec2 = new DenseDoubleVector(arr2); vec1.subtract(vec2); }
@Test(expected = IllegalArgumentException.class) public void testSubtractWithException() { double[] vals1 = {1, 2, 3, 4, 5, 6, 7, 8}; double[] vals2 = {8, 7, 6, 5, 4, 3, 2, 1, 0}; DoubleVector vec1 = new DenseDoubleVector(vals1); DoubleVector vec2 = new DenseDoubleVector(vals2); vec1.subtract(vec2); }
@Test public void testSubtractNormal() { double[] arr1 = new double[] {1, 2, 3}; double[] arr2 = new double[] {4, 5, 6}; DoubleVector vec1 = new DenseDoubleVector(arr1); DoubleVector vec2 = new DenseDoubleVector(arr2); double[] arrExp = new double[] {-3, -3, -3}; assertArrayEquals(arrExp, vec1.subtract(vec2).toArray(), 0.000001); }