Repository navigation
Conversation
EnumeratorOfCombinations( mset ) numbered the combinations by their
multiplicities in mixed radix, an order that matched neither
Combinations( mset ) nor EnumeratorOfCombinations( mset, k ). It now
lists them in the lexicographic order of Combinations( mset ) and lies
in the same family, so the two compare equal. Like the enumerator with
k, it is known to be strictly sorted, prints as a call, and lets
dictionaries hash lists of small integers by content. Position returns
fail for unsorted lists, which it used to accept. Suggested by Reinis
Cirpons.
Ranking and unranking use the number of sub-multisets of each suffix of
Set( mset ). Sets and Position get faster; A[i] for a multiset gets
slower, most with many distinct elements, as each step divides by such
a count rather than by a small radix.
gap> s:=EnumeratorOfCombinations([1..18]);;
gap> m:=EnumeratorOfCombinations(Concatenation([1..9],[1..9],[1..9]));;
gap> M:=EnumeratorOfCombinations(Concatenation([1..1000],[1..1000]));;
Before:
gap> l:=List([1..Length(s)],i->s[i]);; time;
653
gap> List(l,c->Position(s,c));; time;
899
gap> l:=List([1..Length(m)],i->m[i]);; time;
476
gap> List(l,c->Position(m,c));; time;
765
gap> l:=List([1..1000],i->M[QuoInt(i*Length(M),1000)]);; time;
299
gap> List(l,c->Position(M,c));; time;
299
After:
gap> l:=List([1..Length(s)],i->s[i]);; time;
345
gap> List(l,c->Position(s,c));; time;
258
gap> l:=List([1..Length(m)],i->m[i]);; time;
505
gap> List(l,c->Position(m,c));; time;
454
gap> l:=List([1..1000],i->M[QuoInt(i*Length(M),1000)]);; time;
557
gap> List(l,c->Position(M,c));; time;
192
Assisted-by: Generative AI
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #6797 +/- ##
==========================================
+ Coverage 79.80% 79.81% +0.01%
==========================================
Files 684 684
Lines 295788 295862 +74
Branches 8695 8672 -23
==========================================
+ Hits 236048 236141 +93
+ Misses 57923 57904 -19
Partials 1817 1817 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
james-d-mitchell
approved these changes
Oct 30, 2026
james-d-mitchell
left a comment
Contributor
There was a problem hiding this comment.
Other than the two minor comments indicated, this looks good to me!
| ## <P/> | ||
| ## The ordering of combinations from these functions can be different and also | ||
| ## different from the list returned by <Ref Func="Combinations"/>. | ||
| ## for the same combinations; it is equal to the strictly sorted list |
Contributor
There was a problem hiding this comment.
Suggested change
| ## for the same combinations; it is equal to the strictly sorted list | |
| ## for the same combinations; the enumerator is equal to the strictly sorted list |
| end); | ||
|
|
||
| # All combinations are numbered in lexicographic order, in which a list | ||
| # comes before its extensions. Let S[i] = Product(max{[i..l]} + 1) be the |
Contributor
There was a problem hiding this comment.
Be good to say what "max" is here Max.
Say that the enumerator, not the combinations, equals the sorted list, and define the notation used by the ranking comment. Assisted-by: Generative AI
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
EnumeratorOfCombinations( mset )numbered the combinations by their multiplicities in mixed radix, an order that matched neitherCombinations( mset )norEnumeratorOfCombinations( mset, k ). It now lists them in the lexicographic order of Combinations( mset ) and lies in the same family, so the two compare equal. Like the enumerator with k, it is known to be strictly sorted, prints as a call, and lets dictionaries hash lists of small integers by content. Position returns fail for unsorted lists, which it used to accept.Ranking and unranking use the number of sub-multisets of each suffix of
Set( mset ). Sets and Position get faster; A[i] for a multiset gets slower, most with many distinct elements, as each step divides by such a count rather than by a small radix.Before:
After:
Assisted-by: Generative AI