### Question:
Vector extends Tensor<Vector> { @Override public Vector add(Vector b) { if (length() != b.length()) { throw new ArithmeticException(formatWithLocale( "Vector lengths must be equal, got %d + %d lengths", length(), b.length() )); } Vector sum = zeros(); for (int i = 0; i < length(); ++i) { sum.data[i] = data[i] + b.data[i]; } return sum; } Vector(double[] data); static Vector fill(double v, int length); @Override Vector zeros(); @Override Vector copy(); @Override Vector add(Vector b);  }### Answer:
@Test void addsVector() { Vector vector = new Vector(new double[] { 3D, 2D, 1D}); Vector vectorToAdd = new Vector(new double[] { 4D, 6D, 8D}); Vector sum = vector.add(vectorToAdd); assertNotSame(vector, sum); assertNotSame(vectorToAdd, sum); assertArrayEquals(new double[]{7D, 8D, 9D}, sum.data); }
@Test void failsOnDimensionsMismatch() { Vector vector = new Vector(new double[] { 3D, 2D, 1D}); Vector vectorToAdd = new Vector(new double[] { 4D }); assertThrows(ArithmeticException.class, () -> vector.add(vectorToAdd)); }