Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D085FD1A3 for ; Mon, 16 Jul 2012 13:38:35 +0000 (UTC) Received: (qmail 84612 invoked by uid 500); 16 Jul 2012 13:38:34 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 84272 invoked by uid 500); 16 Jul 2012 13:38:34 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 84254 invoked by uid 99); 16 Jul 2012 13:38:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 16 Jul 2012 13:38:33 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 16 Jul 2012 13:38:32 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 4011123889DE for ; Mon, 16 Jul 2012 13:38:13 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1362032 - /commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/LaguerreSolver.java Date: Mon, 16 Jul 2012 13:38:13 -0000 To: commits@commons.apache.org From: erans@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120716133813.4011123889DE@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: erans Date: Mon Jul 16 13:38:12 2012 New Revision: 1362032 URL: http://svn.apache.org/viewvc?rev=1362032&view=rev Log: Code cleanup. Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/LaguerreSolver.java Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/LaguerreSolver.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/LaguerreSolver.java?rev=1362032&r1=1362031&r2=1362032&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/LaguerreSolver.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/LaguerreSolver.java Mon Jul 16 13:38:12 2012 @@ -88,21 +88,21 @@ public class LaguerreSolver extends Abst */ @Override public double doSolve() { - double min = getMin(); - double max = getMax(); - double initial = getStartValue(); + final double min = getMin(); + final double max = getMax(); + final double initial = getStartValue(); final double functionValueAccuracy = getFunctionValueAccuracy(); verifySequence(min, initial, max); // Return the initial guess if it is good enough. - double yInitial = computeObjectiveValue(initial); + final double yInitial = computeObjectiveValue(initial); if (FastMath.abs(yInitial) <= functionValueAccuracy) { return initial; } // Return the first endpoint if it is good enough. - double yMin = computeObjectiveValue(min); + final double yMin = computeObjectiveValue(min); if (FastMath.abs(yMin) <= functionValueAccuracy) { return min; } @@ -113,7 +113,7 @@ public class LaguerreSolver extends Abst } // Return the second endpoint if it is good enough. - double yMax = computeObjectiveValue(max); + final double yMax = computeObjectiveValue(max); if (FastMath.abs(yMax) <= functionValueAccuracy) { return max; } @@ -151,8 +151,8 @@ public class LaguerreSolver extends Abst double fLo, double fHi) { final Complex c[] = ComplexUtils.convertToComplex(getCoefficients()); - Complex initial = new Complex(0.5 * (lo + hi), 0); - Complex z = complexSolver.solve(c, initial); + final Complex initial = new Complex(0.5 * (lo + hi), 0); + final Complex z = complexSolver.solve(c, initial); if (complexSolver.isRoot(lo, hi, z)) { return z.getReal(); } else { @@ -260,7 +260,7 @@ public class LaguerreSolver extends Abst if (coefficients == null) { throw new NullArgumentException(); } - int n = coefficients.length - 1; + final int n = coefficients.length - 1; if (n == 0) { throw new NoDataException(LocalizedFormats.POLYNOMIAL); } @@ -307,7 +307,7 @@ public class LaguerreSolver extends Abst throw new NullArgumentException(); } - int n = coefficients.length - 1; + final int n = coefficients.length - 1; if (n == 0) { throw new NoDataException(LocalizedFormats.POLYNOMIAL); } @@ -316,8 +316,8 @@ public class LaguerreSolver extends Abst final double relativeAccuracy = getRelativeAccuracy(); final double functionValueAccuracy = getFunctionValueAccuracy(); - final Complex N = new Complex(n, 0); - final Complex N1 = new Complex(n - 1, 0); + final Complex nC = new Complex(n, 0); + final Complex n1C = new Complex(n - 1, 0); Complex z = initial; Complex oldz = new Complex(Double.POSITIVE_INFINITY, @@ -335,7 +335,7 @@ public class LaguerreSolver extends Abst } d2v = d2v.multiply(new Complex(2.0, 0.0)); - // check for convergence + // Check for convergence. final double tolerance = FastMath.max(relativeAccuracy * z.abs(), absoluteAccuracy); if ((z.subtract(oldz)).abs() <= tolerance) { @@ -345,12 +345,12 @@ public class LaguerreSolver extends Abst return z; } - // now pv != 0, calculate the new approximation + // Now pv != 0, calculate the new approximation. final Complex G = dv.divide(pv); final Complex G2 = G.multiply(G); final Complex H = G2.subtract(d2v.divide(pv)); - final Complex delta = N1.multiply((N.multiply(H)).subtract(G2)); - // choose a denominator larger in magnitude + final Complex delta = n1C.multiply((nC.multiply(H)).subtract(G2)); + // Choose a denominator larger in magnitude. final Complex deltaSqrt = delta.sqrt(); final Complex dplus = G.add(deltaSqrt); final Complex dminus = G.subtract(deltaSqrt); @@ -363,7 +363,7 @@ public class LaguerreSolver extends Abst Double.POSITIVE_INFINITY); } else { oldz = z; - z = z.subtract(N.divide(denominator)); + z = z.subtract(nC.divide(denominator)); } incrementEvaluationCount(); }