Remove reciprocal().
This is not a ISO C99 method and is easily implemented using
Complex.ONE.divide(z).
diff --git a/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java b/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java
index 4302a89..f492988 100644
--- a/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java
+++ b/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java
@@ -730,26 +730,6 @@
}
/**
- * Returns the multiplicative inverse of this instance \( z \).
- * \[ \frac{1}{z} = \frac{1}{a + i b} = \frac{a}{a^2+b^2} - i \frac{b}{a^2+b^2} \]
- * This method produces the same result as:
- * <pre>
- * Complex.ONE.divide(this)
- * </pre>
- *
- * @return \( 1 / z \)
- * @see #divide(Complex)
- * @see <a href="http://mathworld.wolfram.com/MultiplicativeInverse.html">Multiplicative inverse</a>
- */
- public Complex reciprocal() {
- // Note that this cannot be optimised assuming a=1 and b=0.
- // These preserve compatibility with the divide method:
- // 1. create NaNs for infinite parts c or d: 0.0 * inf = nan
- // 2. maintain signs when either c or d are negative signed and the other part is zero
- return divide(1.0, 0.0, real, imaginary);
- }
-
- /**
* Test for equality with another object. If the other object is a {@code Complex} then a
* comparison is made of the real and imaginary parts; otherwise {@code false} is returned.
*
diff --git a/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexTest.java b/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexTest.java
index ad07c10..577c986 100644
--- a/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexTest.java
+++ b/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexTest.java
@@ -566,67 +566,6 @@
}
@Test
- public void testReciprocal() {
- final Complex z = Complex.ofCartesian(5.0, 6.0);
- final Complex act = z.reciprocal();
- final double expRe = 5.0 / 61.0;
- final double expIm = -6.0 / 61.0;
- Assertions.assertEquals(expRe, act.getReal());
- Assertions.assertEquals(expIm, act.getImaginary());
- }
-
- @Test
- public void testReciprocalReciprocal() {
- final Complex z = Complex.ofCartesian(5.0, 6.0);
- final Complex zRR = z.reciprocal().reciprocal();
- final double tol = 1e-14;
- Assertions.assertEquals(zRR.getReal(), z.getReal(), tol);
- Assertions.assertEquals(zRR.getImaginary(), z.getImaginary(), tol);
- }
-
- @Test
- public void testReciprocalReal() {
- final Complex z = Complex.ofCartesian(-2.0, 0.0);
- Assertions.assertTrue(Complex.equals(Complex.ofCartesian(-0.5, 0.0), z.reciprocal()));
- }
-
- @Test
- public void testReciprocalImaginary() {
- final Complex z = Complex.ofCartesian(0.0, -2.0);
- Assertions.assertEquals(Complex.ofCartesian(0.0, 0.5), z.reciprocal());
- }
-
- @Test
- public void testReciprocalNaN() {
- Assertions.assertTrue(NAN.reciprocal().isNaN());
- }
-
- @Test
- public void testReciprocalZero() {
- final Complex z = Complex.ZERO.reciprocal();
- Assertions.assertEquals(inf, z.getReal());
- Assertions.assertEquals(nan, z.getImaginary());
- }
-
- @Test
- public void testReciprocalMatchesDivide() {
- final double[] parts = {Double.NEGATIVE_INFINITY, -1, -0.0, 0.0, 1, Math.PI, Double.POSITIVE_INFINITY, Double.NaN};
- for (final double x : parts) {
- for (final double y : parts) {
- final Complex z = Complex.ofCartesian(x, y);
- Assertions.assertEquals(Complex.ONE.divide(z), z.reciprocal(), () -> z.toString());
- }
- }
- final UniformRandomProvider rng = RandomSource.create(RandomSource.SPLIT_MIX_64);
- for (int i = 0; i < 10; i++) {
- final double x = -1 + rng.nextDouble() * 2;
- final double y = -1 + rng.nextDouble() * 2;
- final Complex z = Complex.ofCartesian(x, y);
- Assertions.assertEquals(Complex.ONE.divide(z), z.reciprocal());
- }
- }
-
- @Test
public void testMultiply() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final Complex y = Complex.ofCartesian(5.0, 6.0);