Opposite implements Vect<T> { @Override public Scalar<T>[] coords() { return new Times<T>( this.vector, new AddInverse<T>(new MultIdentity<T>()) ).coords(); } Opposite(final Vect<T> vector); @Override Scalar<T>[] coords();  }
@Test public void calculatesOpposite() { final Vect<Double> vecta = new FixedVector<>( new Scalars<>(1 + new Random().nextInt(OppositeTest.COORDS_LENGTH)) ); final Scalar<Double>[] sum = new Sum<>( new Opposite<>(vecta), vecta ).coords(); final Decimal field = new Decimal(); for (final Scalar<Double> scalar : sum) { MatcherAssert.assertThat(field.actual(scalar), Matchers.is(0.)); } }