commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject [1/7] [math] Combined nested if statements.
Date Tue, 03 Nov 2015 20:37:07 GMT
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 <luc@apache.org>
Authored: Tue Nov 3 15:48:09 2015 +0100
Committer: Luc Maisonobe <luc@apache.org>
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<T> 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


Mime
View raw message