Skip to content

Commit

Permalink
sagemathgh-36814: Fast cardinality method for IntegerVectorsModPermut…
Browse files Browse the repository at this point in the history
…ationGroup

    
# Fast cardinality method for IntegerVectorsModPermutationGroup

This patch fixes sagemath#36787 by implementing a `cardinality` method for
`IntegerVectorsModPermutationGroup_with_constraints`.  The method
calculates the cardinality using the the [Polya enumeration
theorem](https://en.wikipedia.org/wiki/P%C3%B3lya_enumeration_theorem)
(also known as the cycle index theorem).

It is faster than the the default implementation, which iterates through
the full set to
find the cardinality.

Incidentally this PR fixes also sagemath#36681 so that cardinality and iter no
longer crash in empty-domain situations.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation accordingly.

### ⌛ Dependencies

- sagemath#36873: we can use `is_trivial` from that PR
<!-- List all open PRs that this PR logically depends on
- sagemath#12345: short description why this is a dependency
- sagemath#34567: ...
-->

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: sagemath#36814
Reported by: Jukka Kohonen
Reviewer(s): Dima Pasechnik, Jukka Kohonen, Martin Rubey, Travis Scrimshaw
  • Loading branch information
Release Manager committed Dec 17, 2023
2 parents d6a2dcc + 11bbef9 commit 5d0093c
Show file tree
Hide file tree
Showing 4 changed files with 369 additions and 39 deletions.
Loading

0 comments on commit 5d0093c

Please sign in to comment.