commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r825919 [2/2] - in /commons/proper/math/trunk: ./ src/main/java/org/apache/commons/math/analysis/integration/ src/main/java/org/apache/commons/math/analysis/interpolation/ src/main/java/org/apache/commons/math/analysis/polynomials/ src/main...
Date Fri, 16 Oct 2009 14:51:56 GMT
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java?rev=825919&r1=825918&r2=825919&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java Fri
Oct 16 14:51:55 2009
@@ -205,29 +205,35 @@
         long result = 1;
         if (n <= 61) {
             // For n <= 61, the naive implementation cannot overflow.
-            for (int j = 1, i = n - k + 1; j <= k; i++, j++) {
+            int i = n - k + 1;
+            for (int j = 1; j <= k; j++) {
                 result = result * i / j;
+                i++;
             }
         } else if (n <= 66) {
             // For n > 61 but n <= 66, the result cannot overflow,
             // but we must take care not to overflow intermediate values.
-            for (int j = 1, i = n - k + 1; j <= k; i++, j++) {
+            int i = n - k + 1;
+            for (int j = 1; j <= k; j++) {
                 // We know that (result * i) is divisible by j,
                 // but (result * i) may overflow, so we split j:
                 // Filter out the gcd, d, so j/d and i/d are integer.
                 // result is divisible by (j/d) because (j/d)
                 // is relative prime to (i/d) and is a divisor of
                 // result * (i/d).
-                long d = gcd(i, j);
+                final long d = gcd(i, j);
                 result = (result / (j / d)) * (i / d);
+                i++;
             }
         } else {
             // For n > 66, a result overflow might occur, so we check
             // the multiplication, taking care to not overflow
             // unnecessary.
-            for (int j = 1, i = n - k + 1; j <= k; i++, j++) {
-                long d = gcd(i, j);
+            int i = n - k + 1;
+            for (int j = 1; j <= k; j++) {
+                final long d = gcd(i, j);
                 result = mulAndCheck(result / (j / d), i / d);
+                i++;
             }
         }
         return result;

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/OpenIntToDoubleHashMap.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/OpenIntToDoubleHashMap.java?rev=825919&r1=825918&r2=825919&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/OpenIntToDoubleHashMap.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/OpenIntToDoubleHashMap.java
Fri Oct 16 14:51:55 2009
@@ -186,7 +186,8 @@
             return missingEntries;
         }
 
-        for (int perturb = perturb(hash), j = index; states[index] != FREE; perturb >>=
PERTURB_SHIFT) {
+        int j = index;
+        for (int perturb = perturb(hash); states[index] != FREE; perturb >>= PERTURB_SHIFT)
{
             j = probe(perturb, j);
             index = j & mask;
             if (containsKey(key, index)) {
@@ -215,7 +216,8 @@
             return false;
         }
 
-        for (int perturb = perturb(hash), j = index; states[index] != FREE; perturb >>=
PERTURB_SHIFT) {
+        int j = index;
+        for (int perturb = perturb(hash); states[index] != FREE; perturb >>= PERTURB_SHIFT)
{
             j = probe(perturb, j);
             index = j & mask;
             if (containsKey(key, index)) {
@@ -358,7 +360,8 @@
             return missingEntries;
         }
 
-        for (int perturb = perturb(hash), j = index; states[index] != FREE; perturb >>=
PERTURB_SHIFT) {
+        int j = index;
+        for (int perturb = perturb(hash); states[index] != FREE; perturb >>= PERTURB_SHIFT)
{
             j = probe(perturb, j);
             index = j & mask;
             if (containsKey(key, index)) {

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/OpenIntToFieldHashMap.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/OpenIntToFieldHashMap.java?rev=825919&r1=825918&r2=825919&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/OpenIntToFieldHashMap.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/OpenIntToFieldHashMap.java
Fri Oct 16 14:51:55 2009
@@ -198,7 +198,8 @@
             return missingEntries;
         }
 
-        for (int perturb = perturb(hash), j = index; states[index] != FREE; perturb >>=
PERTURB_SHIFT) {
+        int j = index;
+        for (int perturb = perturb(hash); states[index] != FREE; perturb >>= PERTURB_SHIFT)
{
             j = probe(perturb, j);
             index = j & mask;
             if (containsKey(key, index)) {
@@ -227,7 +228,8 @@
             return false;
         }
 
-        for (int perturb = perturb(hash), j = index; states[index] != FREE; perturb >>=
PERTURB_SHIFT) {
+        int j = index;
+        for (int perturb = perturb(hash); states[index] != FREE; perturb >>= PERTURB_SHIFT)
{
             j = probe(perturb, j);
             index = j & mask;
             if (containsKey(key, index)) {
@@ -370,7 +372,8 @@
             return missingEntries;
         }
 
-        for (int perturb = perturb(hash), j = index; states[index] != FREE; perturb >>=
PERTURB_SHIFT) {
+        int j = index;
+        for (int perturb = perturb(hash); states[index] != FREE; perturb >>= PERTURB_SHIFT)
{
             j = probe(perturb, j);
             index = j & mask;
             if (containsKey(key, index)) {



Mime
View raw message