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

Corner cases of "modint" when mod = 1 #110

Open
rsk0315 opened this issue Nov 19, 2022 · 0 comments · May be fixed by #112
Open

Corner cases of "modint" when mod = 1 #110

rsk0315 opened this issue Nov 19, 2022 · 0 comments · May be fixed by #112
Labels
bug Something isn't working

Comments

@rsk0315
Copy link

rsk0315 commented Nov 19, 2022

let mut r = Self::raw(1);

impl<M: Modulus> Product<_> for StaticModInt<M> { fn product(_) -> _ { _(Self::raw(1), Mul::mul) } }

impl<I: Id > Product<_> for DynamicModInt<I> { fn product(_) -> _ { _(Self::raw(1), Mul::mul) } }

The identity of multiplication should be Self::new(1)(not raw but new), because of following (corner) cases:

use ac_library_rs::ModInt;

ModInt::set_modulus(1); // !!

let x: ModInt = std::iter::empty::<ModInt>().product();
assert_eq!(x.val(), 0);

let y = ModInt::new(123).pow(0);
assert_eq!(y.val(), 0);

Note that the original ACL allows to use modint::set_mod(1).

@qryxip qryxip added the bug Something isn't working label Nov 19, 2022
mizar added a commit to mizar/ac-library-rs that referenced this issue Jan 21, 2023
mizar added a commit to mizar/ac-library-rs that referenced this issue Jan 21, 2023
mizar added a commit to mizar/ac-library-rs that referenced this issue Jan 22, 2023
mizar added a commit to mizar/ac-library-rs that referenced this issue Jan 22, 2023
mizar added a commit to mizar/ac-library-rs that referenced this issue Mar 26, 2023
mizar added a commit to mizar/ac-library-rs that referenced this issue Mar 26, 2023
mizar added a commit to mizar/ac-library-rs that referenced this issue Mar 26, 2023
mizar added a commit to mizar/ac-library-rs that referenced this issue Mar 27, 2023
@mizar mizar linked a pull request Mar 27, 2023 that will close this issue
mizar added a commit to mizar/ac-library-rs that referenced this issue Apr 17, 2023
mizar added a commit to mizar/ac-library-rs that referenced this issue Apr 18, 2023
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 a pull request may close this issue.

3 participants