Dot implements InnerProduct<Double> { @Override public Scalar<Double> product(final Vect<Double> foperand, final Vect<Double> soperand) { final Scalar<Double>[] first = foperand.coords(); final Scalar<Double>[] second = soperand.coords(); final List<Multiplication<Double>> multis = new ArrayList<>(first.length); for (int idx = 0; idx < first.length; ++idx) { multis.add(Dot.mult(first[idx], second[idx])); } return new Add<Double>(multis); }  @Override Scalar<Double> product(final Vect<Double> foperand, final Vect<Double> soperand); @Override Scalar<Double> norm(final Vect<Double> vect); @Override Degrees<Double> angle(final Vect<Double> first, final Vect<Double> second); @Override Vect<Double> rot(final Vect<Double> vect, final Degrees<Double> ang);  }
@Test public void calculatesProduct() { final Double[] coords = DotTest.doubles(DotTest.COORDS_LENGTH); final Vect<Double> vecta = new DblVect(coords); final Vect<Double> vectb = new DblVect(coords); Double result = 0.; for (final Double coord : coords) { result += coord * coord; } MatcherAssert.assertThat( new Equals<>( new Dot().product(vecta, vectb), new Scalar.Default<>(result) ).resolve(new Decimal()), Matchers.equalTo(true) ); }