commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject svn commit: r1517338 - /commons/proper/math/trunk/src/test/java/org/apache/commons/math3/util/CombinatoricsUtilsTest.java
Date Sun, 25 Aug 2013 17:06:55 GMT
Author: erans
Date: Sun Aug 25 17:06:55 2013
New Revision: 1517338

URL: http://svn.apache.org/r1517338
Log:
Extending the validity range of the check.

Modified:
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/util/CombinatoricsUtilsTest.java

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/util/CombinatoricsUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/util/CombinatoricsUtilsTest.java?rev=1517338&r1=1517337&r2=1517338&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/util/CombinatoricsUtilsTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/util/CombinatoricsUtilsTest.java
Sun Aug 25 17:06:55 2013
@@ -379,6 +379,9 @@ public class CombinatoricsUtilsTest {
         combinationsIterator = CombinatoricsUtils.combinationsIterator(0, 0);
         checkIterator(combinationsIterator, 0, 0);
         combinationsIterator = CombinatoricsUtils.combinationsIterator(4, 2);
+        checkIterator(combinationsIterator, 4, 2);
+        combinationsIterator = CombinatoricsUtils.combinationsIterator(123, 2);
+        checkIterator(combinationsIterator, 123, 2);
     }
     
     /**
@@ -386,8 +389,6 @@ public class CombinatoricsUtilsTest {
      * increasing sequence of b(n,k) arrays, each having length k
      * and each array itself increasing.
      * 
-     * Note: the lexicographic order check only works for n < 10.
-     * 
      * @param iterator 
      * @param n size of universe
      * @param k size of subsets
@@ -398,7 +399,7 @@ public class CombinatoricsUtilsTest {
         while (iterator.hasNext()) {
             final int[] iterate = iterator.next();
             Assert.assertEquals(k, iterate.length);
-            final long curLex = lexNorm(iterate);
+            final long curLex = lexNorm(iterate, n);
             Assert.assertTrue(curLex > lastLex);
             lastLex = curLex;
             length++;
@@ -431,12 +432,13 @@ public class CombinatoricsUtilsTest {
      * For example [3,2,1] returns 123.
      * 
      * @param iterate input array
+     * @param n size of universe
      * @return lexicographic norm
      */
-    private long lexNorm(int[] iterate) {
+    private long lexNorm(int[] iterate, int n) {
         long ret = 0;
         for (int i = iterate.length - 1; i >= 0; i--) {
-            ret += iterate[i] * ArithmeticUtils.pow(10l, (long) i);
+            ret += iterate[i] * ArithmeticUtils.pow(n, (long) i);
         }
         return ret;
     }



Mime
View raw message