Extending the validity range of the check.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1517338 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ad35857d0f
commit
5151780b34
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue