Complex implements FieldElement<Complex>, Serializable { @Override public int hashCode() { if (isNaN) { return 7; } return 37 * (17 * MathUtils.hash(imaginary) + MathUtils.hash(real)); } Complex(double real);  Complex(double real, double imaginary); double abs(); Complex add(Complex addend); Complex add(double addend); Complex conjugate(); Complex divide(Complex divisor); Complex divide(double divisor); Complex reciprocal(); @Override boolean equals(Object other); static boolean equals(Complex x, Complex y, int maxUlps); static boolean equals(Complex x, Complex y); static boolean equals(Complex x, Complex y, double eps); static boolean equalsWithRelativeTolerance(Complex x, Complex y,
                                                      double eps); @Override int hashCode(); double getImaginary(); double getReal(); boolean isNaN(); boolean isInfinite(); Complex multiply(Complex factor); Complex multiply(final int factor); Complex multiply(double factor); Complex negate(); Complex subtract(Complex subtrahend); Complex subtract(double subtrahend); Complex acos(); Complex asin(); Complex atan(); Complex cos(); Complex cosh(); Complex exp(); Complex log(); Complex pow(Complex x); Complex pow(double x); Complex sin(); Complex sinh(); Complex sqrt(); Complex sqrt1z(); Complex tan(); Complex tanh(); double getArgument(); List<Complex> nthRoot(int n); static Complex valueOf(double realPart,
                                  double imaginaryPart); static Complex valueOf(double realPart); ComplexField getField(); @Override String toString(); static final Complex I; static final Complex NaN; static final Complex INF; static final Complex ONE; static final Complex ZERO; }
@Test public void testHashCode() { Complex x = new Complex(0.0, 0.0); Complex y = new Complex(0.0, 0.0 + Double.MIN_VALUE); Assert.assertFalse(x.hashCode()==y.hashCode()); y = new Complex(0.0 + Double.MIN_VALUE, 0.0); Assert.assertFalse(x.hashCode()==y.hashCode()); Complex realNaN = new Complex(Double.NaN, 0.0); Complex imaginaryNaN = new Complex(0.0, Double.NaN); Assert.assertEquals(realNaN.hashCode(), imaginaryNaN.hashCode()); Assert.assertEquals(imaginaryNaN.hashCode(), Complex.NaN.hashCode()); final String msg = "'equals' not compatible with 'hashCode'"; x = new Complex(0.0, 0.0); y = new Complex(0.0, -0.0); Assert.assertTrue(x.hashCode() != y.hashCode()); Assert.assertFalse(msg, x.equals(y)); x = new Complex(0.0, 0.0); y = new Complex(-0.0, 0.0); Assert.assertTrue(x.hashCode() != y.hashCode()); Assert.assertFalse(msg, x.equals(y)); }