BigComplex { public static BigComplex valueOf(BigDecimal real) { return valueOf(real, BigDecimal.ZERO); } private  BigComplex(BigDecimal re, BigDecimal im); BigComplex add(BigComplex value); BigComplex add(BigComplex value, MathContext mathContext); BigComplex add(BigDecimal value, MathContext mathContext); BigComplex add(BigDecimal value); BigComplex add(double value); BigComplex subtract(BigComplex value); BigComplex subtract(BigComplex value, MathContext mathContext); BigComplex subtract(BigDecimal value, MathContext mathContext); BigComplex subtract(BigDecimal value); BigComplex subtract(double value); BigComplex multiply(BigComplex value); BigComplex multiply(BigComplex value, MathContext mathContext); BigComplex multiply(BigDecimal value, MathContext mathContext); BigComplex multiply(BigDecimal value); BigComplex multiply(double value); BigComplex divide(BigComplex value, MathContext mathContext); BigComplex divide(BigDecimal value, MathContext mathContext); BigComplex divide(double value, MathContext mathContext); BigComplex reciprocal(MathContext mathContext); BigComplex conjugate(); BigComplex negate(); BigDecimal abs(MathContext mathContext); BigDecimal angle(MathContext mathContext); BigDecimal absSquare(MathContext mathContext); boolean isReal(); BigComplex re(); BigComplex im(); BigComplex round(MathContext mathContext); @Override int hashCode(); @Override boolean equals(Object obj); boolean strictEquals(Object obj); @Override String toString(); static BigComplex valueOf(BigDecimal real); static BigComplex valueOf(double real); static BigComplex valueOf(double real, double imaginary); static BigComplex valueOf(BigDecimal real, BigDecimal imaginary); static BigComplex valueOfPolar(BigDecimal radius, BigDecimal angle, MathContext mathContext); static BigComplex valueOfPolar(double radius, double angle, MathContext mathContext); static final BigComplex ZERO; static final BigComplex ONE; static final BigComplex I; final BigDecimal re; final BigDecimal im; }
@Test public void testValueOf() { assertEquals(BigDecimal.valueOf(1.2), BigComplex.valueOf(BigDecimal.valueOf(1.2), BigDecimal.valueOf(3.4)).re); assertEquals(BigDecimal.valueOf(3.4), BigComplex.valueOf(BigDecimal.valueOf(1.2), BigDecimal.valueOf(3.4)).im); assertEquals(BigDecimal.valueOf(1.2), BigComplex.valueOf(1.2, 3.4).re); assertEquals(BigDecimal.valueOf(3.4), BigComplex.valueOf(1.2, 3.4).im); assertEquals(BigDecimal.valueOf(1.2), BigComplex.valueOf(BigDecimal.valueOf(1.2)).re); assertEquals(BigDecimal.ZERO, BigComplex.valueOf(BigDecimal.valueOf(1.2)).im); assertEquals(BigDecimal.valueOf(1.2), BigComplex.valueOf(1.2).re); assertEquals(BigDecimal.ZERO, BigComplex.valueOf(1.2).im); }
@Test public void testValueOfConstants() { assertSame(BigComplex.ZERO, BigComplex.valueOf(0.0)); assertSame(BigComplex.ZERO, BigComplex.valueOf(0.0, 0.0)); assertSame(BigComplex.ZERO, BigComplex.valueOf(BigDecimal.ZERO, BigDecimal.ZERO)); assertSame(BigComplex.ONE, BigComplex.valueOf(BigDecimal.ONE, BigDecimal.ZERO)); assertSame(BigComplex.ONE, BigComplex.valueOf(1.0, 0.0)); assertSame(BigComplex.ONE, BigComplex.valueOf(1.0, 0.0)); assertSame(BigComplex.I, BigComplex.valueOf(BigDecimal.ZERO, BigDecimal.ONE)); assertSame(BigComplex.I, BigComplex.valueOf(0.0, 1.0)); }