You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2015/08/29 00:27:46 UTC

[1/3] [math] Performance (FindBugs)

Repository: commons-math
Updated Branches:
  refs/heads/master e323f3c71 -> 7b9df59a9


Performance (FindBugs)


Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/392323e2
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/392323e2
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/392323e2

Branch: refs/heads/master
Commit: 392323e2d44bacdac605c1a4f037f06e21dcc239
Parents: e323f3c
Author: Gilles <er...@apache.org>
Authored: Fri Aug 28 23:42:39 2015 +0200
Committer: Gilles <er...@apache.org>
Committed: Fri Aug 28 23:42:39 2015 +0200

----------------------------------------------------------------------
 .../commons/math4/exception/util/ExceptionContext.java       | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/392323e2/src/main/java/org/apache/commons/math4/exception/util/ExceptionContext.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/exception/util/ExceptionContext.java b/src/main/java/org/apache/commons/math4/exception/util/ExceptionContext.java
index 7eb367a..59f91a3 100644
--- a/src/main/java/org/apache/commons/math4/exception/util/ExceptionContext.java
+++ b/src/main/java/org/apache/commons/math4/exception/util/ExceptionContext.java
@@ -283,12 +283,12 @@ public class ExceptionContext implements Serializable {
     private void serializeContext(ObjectOutputStream out)
         throws IOException {
         // Step 1.
-        final int len = context.keySet().size();
+        final int len = context.size();
         out.writeInt(len);
-        for (String key : context.keySet()) {
+        for (Map.Entry<String,Object> entry : context.entrySet()) {
             // Step 2.
-            out.writeObject(key);
-            final Object value = context.get(key);
+            out.writeObject(entry.getKey());
+            final Object value = entry.getValue();
             if (value instanceof Serializable) {
                 // Step 3a.
                 out.writeObject(value);


[3/3] [math] Constant can be "static" (FindBugs)

Posted by er...@apache.org.
Constant can be "static" (FindBugs)


Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/7b9df59a
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/7b9df59a
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/7b9df59a

Branch: refs/heads/master
Commit: 7b9df59a96adfce979c8c564dc5eaa6a29b7f25f
Parents: 10dc13c
Author: Gilles <er...@apache.org>
Authored: Sat Aug 29 00:26:43 2015 +0200
Committer: Gilles <er...@apache.org>
Committed: Sat Aug 29 00:26:43 2015 +0200

----------------------------------------------------------------------
 .../org/apache/commons/math4/linear/EigenDecomposition.java    | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/7b9df59a/src/main/java/org/apache/commons/math4/linear/EigenDecomposition.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/linear/EigenDecomposition.java b/src/main/java/org/apache/commons/math4/linear/EigenDecomposition.java
index 9633670..aa92b5e 100644
--- a/src/main/java/org/apache/commons/math4/linear/EigenDecomposition.java
+++ b/src/main/java/org/apache/commons/math4/linear/EigenDecomposition.java
@@ -80,7 +80,7 @@ public class EigenDecomposition {
     /** Internally used epsilon criteria. */
     private static final double EPSILON = 1e-12;
     /** Maximum number of iterations accepted in the implicit QL transformation */
-    private final byte maxIter = 30;
+    private static final byte MAX_ITER = 30;
     /** Main diagonal of the tridiagonal matrix. */
     private double[] main;
     /** Secondary diagonal of the tridiagonal matrix. */
@@ -608,9 +608,9 @@ public class EigenDecomposition {
                     }
                 }
                 if (m != j) {
-                    if (its == maxIter) {
+                    if (its == MAX_ITER) {
                         throw new MaxCountExceededException(LocalizedFormats.CONVERGENCE_FAILED,
-                                                            maxIter);
+                                                            MAX_ITER);
                     }
                     its++;
                     double q = (realEigenvalues[j + 1] - realEigenvalues[j]) / (2 * e[j]);


[2/3] [math] Fixed comparison pattern (FindBugs)

Posted by er...@apache.org.
Fixed comparison pattern (FindBugs)


Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/10dc13c8
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/10dc13c8
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/10dc13c8

Branch: refs/heads/master
Commit: 10dc13c80752b0489d291b54440212ca54c59fee
Parents: 392323e
Author: Gilles <er...@apache.org>
Authored: Sat Aug 29 00:03:03 2015 +0200
Committer: Gilles <er...@apache.org>
Committed: Sat Aug 29 00:03:03 2015 +0200

----------------------------------------------------------------------
 .../math4/fitting/GaussianCurveFitter.java      | 24 ++++++++------------
 1 file changed, 9 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/10dc13c8/src/main/java/org/apache/commons/math4/fitting/GaussianCurveFitter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/fitting/GaussianCurveFitter.java b/src/main/java/org/apache/commons/math4/fitting/GaussianCurveFitter.java
index da6d46d..10b11f3 100644
--- a/src/main/java/org/apache/commons/math4/fitting/GaussianCurveFitter.java
+++ b/src/main/java/org/apache/commons/math4/fitting/GaussianCurveFitter.java
@@ -261,23 +261,17 @@ public class GaussianCurveFitter extends AbstractCurveFitter {
                     if (p2 == null) {
                         return 1;
                     }
-                    if (p1.getX() < p2.getX()) {
-                        return -1;
+                    int comp = Double.compare(p1.getX(), p2.getX());
+                    if (comp != 0) {
+                        return comp;
                     }
-                    if (p1.getX() > p2.getX()) {
-                        return 1;
+                    comp = Double.compare(p1.getY(), p2.getY());
+                    if (comp != 0) {
+                        return comp;
                     }
-                    if (p1.getY() < p2.getY()) {
-                        return -1;
-                    }
-                    if (p1.getY() > p2.getY()) {
-                        return 1;
-                    }
-                    if (p1.getWeight() < p2.getWeight()) {
-                        return -1;
-                    }
-                    if (p1.getWeight() > p2.getWeight()) {
-                        return 1;
+                    comp = Double.compare(p1.getWeight(), p2.getWeight());
+                    if (comp != 0) {
+                        return comp;
                     }
                     return 0;
                 }