@Test public void testAdd() { VectorN vec1 = VectorN.from(2, 1, 5); VectorN vec2 = VectorN.from(3, 4, 7); vec1.add(vec2); assertEquals(VectorN.from(5, 5, 12), vec1); vec1 = VectorN.from(-2, 0, -42); vec1.add(vec2); assertEquals(VectorN.from(1, 4, -35), vec1); vec1 = VectorN.from(-2, -3, 13); vec2 = VectorN.from(-1, 5, -7); vec1.add(vec2); assertEquals(VectorN.from(-3, 2, 6), vec1); }
public VectorN add(final IVector vector) { checkDimension(vector.getNumDimensions()); for (int i = 0; i < getNumDimensions(); i++) { data[i] += vector.get(i); } return this; }
VectorN extends AVectorN { public VectorN add(final IVector vector) { checkDimension(vector.getNumDimensions()); for (int i = 0; i < getNumDimensions(); i++) { data[i] += vector.get(i); } return this; } }
VectorN extends AVectorN { public VectorN add(final IVector vector) { checkDimension(vector.getNumDimensions()); for (int i = 0; i < getNumDimensions(); i++) { data[i] += vector.get(i); } return this; } private  VectorN(final int dim); private  VectorN(final double... data); private  VectorN(final IVector vector); }
VectorN extends AVectorN { public VectorN add(final IVector vector) { checkDimension(vector.getNumDimensions()); for (int i = 0; i < getNumDimensions(); i++) { data[i] += vector.get(i); } return this; } private  VectorN(final int dim); private  VectorN(final double... data); private  VectorN(final IVector vector); static VectorN zero(final int dim); static VectorN empty(); static VectorN from(final double... data); static VectorN copy(final IVector vector); static VectorN fromReal(final RealVector rv); void set(final int i, final double value); VectorN add(final IVector vector); VectorN subtract(final IVector vector); VectorN multiply(final double factor); VectorN apply(final Function<Double, Double> function); @Override double x(); @Override double y(); @Override double get(final int i); @Override int getNumDimensions(); }
VectorN extends AVectorN { public VectorN add(final IVector vector) { checkDimension(vector.getNumDimensions()); for (int i = 0; i < getNumDimensions(); i++) { data[i] += vector.get(i); } return this; } private  VectorN(final int dim); private  VectorN(final double... data); private  VectorN(final IVector vector); static VectorN zero(final int dim); static VectorN empty(); static VectorN from(final double... data); static VectorN copy(final IVector vector); static VectorN fromReal(final RealVector rv); void set(final int i, final double value); VectorN add(final IVector vector); VectorN subtract(final IVector vector); VectorN multiply(final double factor); VectorN apply(final Function<Double, Double> function); @Override double x(); @Override double y(); @Override double get(final int i); @Override int getNumDimensions();  }