@Test public void testDivDouble() { assertEquals(c1.div(c3), c1.div(3.14), EPS); }
public Complex div(final Complex c) { double dRe, dIm; double scalar; if (Math.abs(c.re) >= Math.abs(c.im)) { scalar = 1.0 / (c.re + c.im * (c.im / c.re)); dRe = scalar * (re + im * (c.im / c.re)); dIm = scalar * (im - re * (c.im / c.re)); } else { scalar = 1.0 / (c.re * (c.re / c.im) + c.im); dRe = scalar * (re * (c.re / c.im) + im); dIm = scalar * (im * (c.re / c.im) - re); } return Complex.cart(dRe, dIm); }
Complex implements Serializable { public Complex div(final Complex c) { double dRe, dIm; double scalar; if (Math.abs(c.re) >= Math.abs(c.im)) { scalar = 1.0 / (c.re + c.im * (c.im / c.re)); dRe = scalar * (re + im * (c.im / c.re)); dIm = scalar * (im - re * (c.im / c.re)); } else { scalar = 1.0 / (c.re * (c.re / c.im) + c.im); dRe = scalar * (re * (c.re / c.im) + im); dIm = scalar * (im * (c.re / c.im) - re); } return Complex.cart(dRe, dIm); } }
Complex implements Serializable { public Complex div(final Complex c) { double dRe, dIm; double scalar; if (Math.abs(c.re) >= Math.abs(c.im)) { scalar = 1.0 / (c.re + c.im * (c.im / c.re)); dRe = scalar * (re + im * (c.im / c.re)); dIm = scalar * (im - re * (c.im / c.re)); } else { scalar = 1.0 / (c.re * (c.re / c.im) + c.im); dRe = scalar * (re * (c.re / c.im) + im); dIm = scalar * (im * (c.re / c.im) - re); } return Complex.cart(dRe, dIm); } private  Complex(final double re, final double im); }
Complex implements Serializable { public Complex div(final Complex c) { double dRe, dIm; double scalar; if (Math.abs(c.re) >= Math.abs(c.im)) { scalar = 1.0 / (c.re + c.im * (c.im / c.re)); dRe = scalar * (re + im * (c.im / c.re)); dIm = scalar * (im - re * (c.im / c.re)); } else { scalar = 1.0 / (c.re * (c.re / c.im) + c.im); dRe = scalar * (re * (c.re / c.im) + im); dIm = scalar * (im * (c.re / c.im) - re); } return Complex.cart(dRe, dIm); } private  Complex(final double re, final double im); static Complex cart(final double re, final double im); static Complex[] difference(final Complex[] lr, final int lrlength,
	    final Complex[] rr, final int rrlength, final double epsilon); static double distance(Complex l, Complex r); static Complex[] intersection(final int lnroots,
	    final Complex[] lroots, final int rnroots, final Complex[] rroots,
	    final double epsilon); static void lejaOrder(final Complex[] xin); static Complex polar(double r, double theta); static Complex[] roots(final Complex c, final int nRoots); static Complex[] union(final Complex[] lr, final Complex[] rr); static Complex[] union(final Complex[] lr, final int lrlength,
	    final Complex[] rr, final int rrlength); static Complex[] unitRoots(final int nRoots); static Complex cart(final double re); double abs(); double absSquare(); Complex sqrt(); double arg(); Complex conj(); Complex div(final Complex c); Complex div(final double b); boolean equals(final Complex z, final double tolerance); @Override boolean equals(Object obj); double getIm(); double getRe(); @Override int hashCode(); Complex inv(); boolean isInfinity(); boolean isNaN(); Complex minus(final Complex b); Complex minus(final double z); Complex negate(); Complex plus(final Complex b); Complex plus(final double a); Complex times(final Complex b); Complex times(final double z); @Override String toString(); }
Complex implements Serializable { public Complex div(final Complex c) { double dRe, dIm; double scalar; if (Math.abs(c.re) >= Math.abs(c.im)) { scalar = 1.0 / (c.re + c.im * (c.im / c.re)); dRe = scalar * (re + im * (c.im / c.re)); dIm = scalar * (im - re * (c.im / c.re)); } else { scalar = 1.0 / (c.re * (c.re / c.im) + c.im); dRe = scalar * (re * (c.re / c.im) + im); dIm = scalar * (im * (c.re / c.im) - re); } return Complex.cart(dRe, dIm); } private  Complex(final double re, final double im); static Complex cart(final double re, final double im); static Complex[] difference(final Complex[] lr, final int lrlength,
	    final Complex[] rr, final int rrlength, final double epsilon); static double distance(Complex l, Complex r); static Complex[] intersection(final int lnroots,
	    final Complex[] lroots, final int rnroots, final Complex[] rroots,
	    final double epsilon); static void lejaOrder(final Complex[] xin); static Complex polar(double r, double theta); static Complex[] roots(final Complex c, final int nRoots); static Complex[] union(final Complex[] lr, final Complex[] rr); static Complex[] union(final Complex[] lr, final int lrlength,
	    final Complex[] rr, final int rrlength); static Complex[] unitRoots(final int nRoots); static Complex cart(final double re); double abs(); double absSquare(); Complex sqrt(); double arg(); Complex conj(); Complex div(final Complex c); Complex div(final double b); boolean equals(final Complex z, final double tolerance); @Override boolean equals(Object obj); double getIm(); double getRe(); @Override int hashCode(); Complex inv(); boolean isInfinity(); boolean isNaN(); Complex minus(final Complex b); Complex minus(final double z); Complex negate(); Complex plus(final Complex b); Complex plus(final double a); Complex times(final Complex b); Complex times(final double z); @Override String toString(); static final Complex I; static final Complex TWO; static final Complex ONE; static final Complex ZERO; static final Complex NEG_ONE; static final Complex NEG_TWO; static final Complex NEG_I; final static double EPS; final static double TWOPI; }