commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject svn commit: r1087637 - in /commons/proper/math/trunk/src: main/java/org/apache/commons/math/util/MultidimensionalCounter.java site/xdoc/changes.xml test/java/org/apache/commons/math/util/MultidimensionalCounterTest.java
Date Fri, 01 Apr 2011 10:10:18 GMT
Author: erans
Date: Fri Apr  1 10:10:18 2011
New Revision: 1087637

URL: http://svn.apache.org/viewvc?rev=1087637&view=rev
Log:
MATH-552
Fixed bug in "MultidimensionalCounter". Thanks to James Bence.

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MultidimensionalCounter.java
    commons/proper/math/trunk/src/site/xdoc/changes.xml
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/MultidimensionalCounterTest.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MultidimensionalCounter.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MultidimensionalCounter.java?rev=1087637&r1=1087636&r2=1087637&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MultidimensionalCounter.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MultidimensionalCounter.java
Fri Apr  1 10:10:18 2011
@@ -234,13 +234,7 @@ public class MultidimensionalCounter imp
             indices[i] = idx;
         }
 
-        int idx = 1;
-        while (count < index) {
-            count += idx;
-            ++idx;
-        }
-        --idx;
-        indices[last] = idx;
+        indices[last] = index - count;
 
         return indices;
     }

Modified: commons/proper/math/trunk/src/site/xdoc/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/site/xdoc/changes.xml?rev=1087637&r1=1087636&r2=1087637&view=diff
==============================================================================
--- commons/proper/math/trunk/src/site/xdoc/changes.xml (original)
+++ commons/proper/math/trunk/src/site/xdoc/changes.xml Fri Apr  1 10:10:18 2011
@@ -52,6 +52,9 @@ The <action> type attribute can be add,u
     If the output is not quite correct, check for invisible trailing spaces!
      -->
     <release version="3.0" date="TBD" description="TBD">
+      <action dev="erans" type="fix" issue="MATH-552" due-to="James Bence">
+        Fixed bug in "MultidimensionalCounter".
+      </action>
       <action dev="luc" type="fix" issue="MATH-423" due-to="Gilles Sadowski" >
         All unit tests have been converted to Junit 4. They need at least Junit 4.5 to run
         (the ant and maven build systems are currently set to use Junit 4.8.2)

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/MultidimensionalCounterTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/MultidimensionalCounterTest.java?rev=1087637&r1=1087636&r2=1087637&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/MultidimensionalCounterTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/MultidimensionalCounterTest.java
Fri Apr  1 10:10:18 2011
@@ -121,20 +121,32 @@ public class MultidimensionalCounterTest
 
     @Test
     public void testIterationConsistency() {
-        final MultidimensionalCounter c = new MultidimensionalCounter(2, 3, 2);
+        final MultidimensionalCounter c = new MultidimensionalCounter(2, 3, 4);
         final int[][] expected = new int[][] {
             { 0, 0, 0 },
             { 0, 0, 1 },
+            { 0, 0, 2 },
+            { 0, 0, 3 },
             { 0, 1, 0 },
             { 0, 1, 1 },
+            { 0, 1, 2 },
+            { 0, 1, 3 },
             { 0, 2, 0 },
             { 0, 2, 1 },
+            { 0, 2, 2 },
+            { 0, 2, 3 },
             { 1, 0, 0 },
             { 1, 0, 1 },
+            { 1, 0, 2 },
+            { 1, 0, 3 },
             { 1, 1, 0 },
             { 1, 1, 1 },
+            { 1, 1, 2 },
+            { 1, 1, 3 },
             { 1, 2, 0 },
-            { 1, 2, 1 }
+            { 1, 2, 1 },
+            { 1, 2, 2 },
+            { 1, 2, 3 }
         };
 
         final int totalSize = c.getSize();



Mime
View raw message