Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves performance of exact factorial computation via balanced binary splitting and introduces a new permutation() API for both BigInt and BigDecimal, with accompanying tests.
Changes:
- Replace naive factorial running-product with a balanced
product_range()implementation (binary splitting) forBigIntand exactBigDecimalfactorial. - Add
permutation()special functions and public methods onBigInt/BigDecimal(with optional rounding forBigDecimal). - Add unit tests covering basic
permutation()behavior and error handling.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/bigint/test_bigint_special.mojo | Adds BigInt permutation tests, including k > n and negative k behavior. |
| tests/bigdecimal/test_bigdecimal_special.mojo | Adds BigDecimal permutation tests for exact and rounded modes. |
| src/decimo/bigint/special.mojo | Implements factorial via binary splitting and adds permutation() using product_range(). |
| src/decimo/bigint/bigint.mojo | Exposes BigInt.permutation(k) public API delegating to bigint special functions. |
| src/decimo/bigdecimal/special.mojo | Implements exact factorial via binary splitting and adds exact/rounded permutation(). |
| src/decimo/bigdecimal/bigdecimal.mojo | Exposes BigDecimal.permutation(k, precision) public API delegating to bigdecimal special functions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
This PR improves performance of exact factorial computation via balanced binary splitting and introduces a new
permutation()API for bothBigIntandBigDecimal, with accompanying tests.Changes:
product_range()implementation (binary splitting) forBigIntand exactBigDecimalfactorial.permutation()special functions and public methods onBigInt/BigDecimal(with optional rounding forBigDecimal).permutation()behavior and error handling.