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 A29EC1894A for ; Tue, 3 Nov 2015 20:37:08 +0000 (UTC) Received: (qmail 24592 invoked by uid 500); 3 Nov 2015 20:37:08 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 24314 invoked by uid 500); 3 Nov 2015 20:37:08 -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 23995 invoked by uid 99); 3 Nov 2015 20:37:07 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Nov 2015 20:37:07 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id B9A2BE055E; Tue, 3 Nov 2015 20:37:07 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: luc@apache.org To: commits@commons.apache.org Date: Tue, 03 Nov 2015 20:37:07 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/7] [math] Combined nested if statements. Repository: commons-math Updated Branches: refs/heads/MATH_3_X f0c6d3c0c -> 320a3a3a1 Combined nested if statements. Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/a96ee631 Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/a96ee631 Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/a96ee631 Branch: refs/heads/MATH_3_X Commit: a96ee63181816130911588b1aa36110801cec662 Parents: f0c6d3c Author: Luc Maisonobe Authored: Tue Nov 3 15:48:09 2015 +0100 Committer: Luc Maisonobe Committed: Tue Nov 3 15:49:23 2015 +0100 ---------------------------------------------------------------------- .../math3/distribution/EnumeratedDistribution.java | 8 ++++---- .../fitting/leastsquares/GaussNewtonOptimizer.java | 12 +++++------- 2 files changed, 9 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-math/blob/a96ee631/src/main/java/org/apache/commons/math3/distribution/EnumeratedDistribution.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math3/distribution/EnumeratedDistribution.java b/src/main/java/org/apache/commons/math3/distribution/EnumeratedDistribution.java index 4cb23c1..9e306f0 100644 --- a/src/main/java/org/apache/commons/math3/distribution/EnumeratedDistribution.java +++ b/src/main/java/org/apache/commons/math3/distribution/EnumeratedDistribution.java @@ -213,10 +213,10 @@ public class EnumeratedDistribution implements Serializable { index = -index-1; } - if (index >= 0 && index < probabilities.length) { - if (randomValue < cumulativeProbabilities[index]) { - return singletons.get(index); - } + if (index >= 0 && + index < probabilities.length && + randomValue < cumulativeProbabilities[index]) { + return singletons.get(index); } /* This should never happen, but it ensures we will return a correct http://git-wip-us.apache.org/repos/asf/commons-math/blob/a96ee631/src/main/java/org/apache/commons/math3/fitting/leastsquares/GaussNewtonOptimizer.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math3/fitting/leastsquares/GaussNewtonOptimizer.java b/src/main/java/org/apache/commons/math3/fitting/leastsquares/GaussNewtonOptimizer.java index dc758c1..6c1c3e7 100644 --- a/src/main/java/org/apache/commons/math3/fitting/leastsquares/GaussNewtonOptimizer.java +++ b/src/main/java/org/apache/commons/math3/fitting/leastsquares/GaussNewtonOptimizer.java @@ -233,13 +233,11 @@ public class GaussNewtonOptimizer implements LeastSquaresOptimizer { currentPoint = current.getPoint(); // Check convergence. - if (previous != null) { - if (checker.converged(iterationCounter.getCount(), previous, current)) { - return new OptimumImpl( - current, - evaluationCounter.getCount(), - iterationCounter.getCount()); - } + if (previous != null && + checker.converged(iterationCounter.getCount(), previous, current)) { + return new OptimumImpl(current, + evaluationCounter.getCount(), + iterationCounter.getCount()); } // solve the linearized least squares problem