Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rsk0315 committed Aug 21, 2023
1 parent 16f050c commit 7925352
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion crates/ds/bit_set/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl BitSet {
}

#[must_use]
pub fn contains(&mut self, index: usize) -> bool {
pub fn contains(&self, index: usize) -> bool {
check_bounds(index, self.capacity);

let (wi, bi) = (index / WORD_SIZE, index % WORD_SIZE);
Expand Down
8 changes: 5 additions & 3 deletions crates/math/modint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,13 @@ impl Barrett {

fn mul(&self, a: u32, b: u32) -> u32 {
let m = self.m.load(atomic::Ordering::SeqCst);
let im = self.m.load(atomic::Ordering::SeqCst);
let im = self.im.load(atomic::Ordering::SeqCst);

let z = a as u64 * b as u64;
let x = ((z as u128 * im as u128) >> 64) as u64;
let v = z.wrapping_sub(x.wrapping_mul(m as u64)) as u32;
if m <= v { v.wrapping_add(m) } else { v }
let y = x.wrapping_mul(m as u64);
let v = z.wrapping_sub(y) as u32;
v.wrapping_add(if z < y { m } else { 0 })
}
}

Expand Down Expand Up @@ -509,6 +510,7 @@ fn sanity_check() {
type Md = DynamicModInt<DefaultId>;
Md::set_modulus(10);
assert_eq!(Md::new(5) + Md::new(7), Md::new(2));
assert_eq!(Md::new(3) * Md::new(4), Md::new(2));

Md::set_modulus(4);
assert_eq!(Md::new(5) + Md::new(7), Md::new(0));
Expand Down
4 changes: 2 additions & 2 deletions static/nekolib/src/math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ pub use mod_recip_table_::mod_recip_table_prime;
pub use mod_tetration::ModTetration;
#[doc(inline)]
pub use modint::{
Mod1000000007, Mod998244353, ModInt1000000007, ModInt998244353, ModIntBase,
Modulus, StaticModInt,
DefaultId, DynamicModInt, Mod1000000007, Mod998244353, ModInt1000000007,
ModInt998244353, ModIntBase, Modulus, StaticModInt,
};
#[doc(inline)]
pub use prime_pi_::prime_pi;
Expand Down

0 comments on commit 7925352

Please sign in to comment.