DblMult implements FieldMultiplication<Double> { @Override public Double inverse(final Double elt) { if (Double.valueOf(0).equals(elt)) { throw new IllegalArgumentException("Division by zero"); } return 1. / elt; }  @Override Double multiply(final Double operand, final Double second); @Override Double neutral(); @Override Double inverse(final Double elt);  }
@Test public void calculatesMultiplicationInverse() { final double epsilon = 1.e-6; final double first = Math.random() + epsilon; MatcherAssert.assertThat( new DblMult().inverse(first), Matchers.closeTo(1 / first, epsilon) ); }
@Test public void errorsWhenZeroMultInverse() { this.thrown.expect(IllegalArgumentException.class); new DblMult().inverse(0.); }