Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix corner cases of "modint" when mod = 1 #142

Merged
merged 1 commit into from
Feb 22, 2025

Conversation

mizar
Copy link
Collaborator

@mizar mizar commented Feb 19, 2025

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 for ModInt 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 the pow method to handle the case when the modulus is 1.
  • src/modint.rs (macro_rules! impl_folding): Updated the Product implementation for StaticModInt and DynamicModInt to handle the modulus being 1.

Addition of tests:

  • src/modint.rs (mod tests): Added a new test mod1_corner_case to check the behavior of ModInt 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:

@mizar mizar added the bug Something isn't working label Feb 19, 2025
Copy link
Member

@qryxip qryxip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, why not actually link to #110?

@mizar
Copy link
Collaborator Author

mizar commented Feb 20, 2025

BTW, why not actually link to #110?

Thanks for pointing that out. I have corrected the first message and linked it.

@mizar
Copy link
Collaborator Author

mizar commented Feb 20, 2025

CI was fixed in #141 and rebased to master branch.

@koba-e964 koba-e964 merged commit 663c8fb into rust-lang-ja:master Feb 22, 2025
13 checks passed
@mizar mizar deleted the modint1_fix branch February 23, 2025 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Corner cases of "modint" when mod = 1
3 participants