@Test public void testComputeDiscr() { for (int i = 0; i < 10; i++) { Complex A2 = random(), B2 = random(), C2 = random(); Complex result = B2.times(B2).minus(A2.times(C2).times(4)); assertEquals(result, computeDiscr(B2, A2, C2), 0); } }
@VisibleForTesting static Complex computeDiscr(Complex B2, Complex A2, Complex C2) { double re0, re1; double im0, im1; re0 = B2.getRe() * B2.getRe() - B2.getIm() * B2.getIm(); im0 = B2.getRe() * B2.getIm() + B2.getIm() * B2.getRe(); re1 = A2.getRe() * C2.getRe() - A2.getIm() * C2.getIm(); im1 = A2.getRe() * C2.getIm() + A2.getIm() * C2.getRe(); re1 *= 4; im1 *= 4; re0 -= re1; im0 -= im1; return Complex.cart(re0, im0); }
MullerNewtonSolver implements IRootsSolver { @VisibleForTesting static Complex computeDiscr(Complex B2, Complex A2, Complex C2) { double re0, re1; double im0, im1; re0 = B2.getRe() * B2.getRe() - B2.getIm() * B2.getIm(); im0 = B2.getRe() * B2.getIm() + B2.getIm() * B2.getRe(); re1 = A2.getRe() * C2.getRe() - A2.getIm() * C2.getIm(); im1 = A2.getRe() * C2.getIm() + A2.getIm() * C2.getRe(); re1 *= 4; im1 *= 4; re0 -= re1; im0 -= im1; return Complex.cart(re0, im0); } }
MullerNewtonSolver implements IRootsSolver { @VisibleForTesting static Complex computeDiscr(Complex B2, Complex A2, Complex C2) { double re0, re1; double im0, im1; re0 = B2.getRe() * B2.getRe() - B2.getIm() * B2.getIm(); im0 = B2.getRe() * B2.getIm() + B2.getIm() * B2.getRe(); re1 = A2.getRe() * C2.getRe() - A2.getIm() * C2.getIm(); im1 = A2.getRe() * C2.getIm() + A2.getIm() * C2.getRe(); re1 *= 4; im1 *= 4; re0 -= re1; im0 -= im1; return Complex.cart(re0, im0); } MullerNewtonSolver(); }
MullerNewtonSolver implements IRootsSolver { @VisibleForTesting static Complex computeDiscr(Complex B2, Complex A2, Complex C2) { double re0, re1; double im0, im1; re0 = B2.getRe() * B2.getRe() - B2.getIm() * B2.getIm(); im0 = B2.getRe() * B2.getIm() + B2.getIm() * B2.getRe(); re1 = A2.getRe() * C2.getRe() - A2.getIm() * C2.getIm(); im1 = A2.getRe() * C2.getIm() + A2.getIm() * C2.getRe(); re1 *= 4; im1 *= 4; re0 -= re1; im0 -= im1; return Complex.cart(re0, im0); } MullerNewtonSolver(); @Override void clear(); @Override MullerNewtonSolver exemplar(); @Override boolean factorize(final Polynomial p); @Override Polynomial remainder(); @Override Complex[] roots(); boolean isLeastSquaresDivision(); void setLeastSquaresDivision(boolean lq); }
MullerNewtonSolver implements IRootsSolver { @VisibleForTesting static Complex computeDiscr(Complex B2, Complex A2, Complex C2) { double re0, re1; double im0, im1; re0 = B2.getRe() * B2.getRe() - B2.getIm() * B2.getIm(); im0 = B2.getRe() * B2.getIm() + B2.getIm() * B2.getRe(); re1 = A2.getRe() * C2.getRe() - A2.getIm() * C2.getIm(); im1 = A2.getRe() * C2.getIm() + A2.getIm() * C2.getRe(); re1 *= 4; im1 *= 4; re0 -= re1; im0 -= im1; return Complex.cart(re0, im0); } MullerNewtonSolver(); @Override void clear(); @Override MullerNewtonSolver exemplar(); @Override boolean factorize(final Polynomial p); @Override Polynomial remainder(); @Override Complex[] roots(); boolean isLeastSquaresDivision(); void setLeastSquaresDivision(boolean lq);  }