Hi.

[...]
+
+    /**
+     * Verifies that the iterator generates a lexicographically
+     * 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.

What about not using a fixed base (cf. below)?

+     *
+     * @param iterator
+     * @param n size of universe
+     * @param k size of subsets
+     */
+ private void checkIterator(Iterator<int[]> iterator, int n, int k) {
+        long lastLex = -1;
+        long length = 0;
+        while (iterator.hasNext()) {
+            final int[] iterate = iterator.next();
+            Assert.assertEquals(k, iterate.length);
+            final long curLex = lexNorm(iterate);
                                    ^^^^^^^^^^^^^^^
Replace with
   final long curLex = lexNorm(iterate, n);

+            Assert.assertTrue(curLex > lastLex);
+            lastLex = curLex;
+            length++;
+            for (int i = 1; i < iterate.length; i++) {
+                Assert.assertTrue(iterate[i] > iterate[i - 1]);
+            }
+        }

[...]

+
+    /**
+ * Returns the value represented by the digits in the input array in reverse order.
+     * For example [3,2,1] returns 123.
+     *
+     * @param iterate input array
+     * @return lexicographic norm
+     */
+    private long lexNorm(int[] iterate) {
                                       ^^^
Replace with
  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);
                                                      ^^^^^^^^^^^^^^
Replace with
   ret += iterate[i] * ArithmeticUtils.pow(n, (long) i);

+        }
+        return ret;
+    }
+}

[...]


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to