fix corner cases of "modint" when mod = 1 #142
Merged
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.
fixes #110
This pull request includes changes to the
src/modint.rs
file to address corner cases when the modulus is set to 1. The most important changes involve modifying the initialization logic forModInt
and adding tests to ensure the correctness of the implementation.Modifications to initialization logic:
src/modint.rs
(pub trait ModIntBase
): Changed the initialization value in thepow
method to handle the case when the modulus is 1.src/modint.rs
(macro_rules! impl_folding
): Updated theProduct
implementation forStaticModInt
andDynamicModInt
to handle the modulus being 1.Addition of tests:
src/modint.rs
(mod tests
): Added a new testmod1_corner_case
to check the behavior ofModInt
when the modulus is set to 1, including edge cases for the product of an empty iterator and the power of zero.This PR is extracted from the content of #112 .
fix issue:
related Issue/PR: