Skip to content

Commit

Permalink
chore: fix clippy::manual_div_ceil & fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
byeongkeunahn committed Feb 1, 2025
1 parent 975634a commit b7c4c0d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
4 changes: 3 additions & 1 deletion basm-std/src/math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,9 @@ mod test {
assert_eq!(Some(4i64), modinv(3i64, 11i64));
assert_eq!(Some(4u64), modinv(3u64, 11u64));
let p = 0u64.wrapping_sub((1u64 << 32) - 1);
assert_eq!(Some((p + 1) / 2), modinv(2u64, p));
#[allow(clippy::manual_div_ceil)]
let p_half = (p + 1) / 2;
assert_eq!(Some(p_half), modinv(2u64, p));
assert_eq!(Some(9999999966u64), modinv(9999999966u64, 9999999967u64));
assert_eq!(Some(12297829382473034411u64), modinv(3, 0u64));
assert_eq!(
Expand Down
8 changes: 4 additions & 4 deletions basm-std/src/math/ntt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ mod test {
1614279433659886989,
2232618956921417485
],
multiply_u64(&[2745895686766400144, 7520886206723962441], &[
9006621652498007052,
5476023620144815056
])
multiply_u64(
&[2745895686766400144, 7520886206723962441],
&[9006621652498007052, 5476023620144815056]
)
);
}
#[test]
Expand Down
4 changes: 2 additions & 2 deletions basm-std/src/math/ntt/nttcore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -849,9 +849,9 @@ pub fn pack_into(src: &[u64], dst1: &mut [u64], dst2: &mut [u64], bits: u64) {

pub const fn compute_bits(l: u64) -> u64 {
let total_bits = l * 64;
let (mut lo, mut hi) = (42, 62);
let (mut lo, mut hi) = (42u64, 62u64);
while lo < hi {
let mid = (lo + hi + 1) / 2;
let mid = (lo + hi).div_ceil(2);
let single_digit_max_val = (1u64 << mid) - 1;
let l_corrected = total_bits.div_ceil(mid);
let (lhs, overflow) = (single_digit_max_val as u128)
Expand Down
4 changes: 2 additions & 2 deletions basm-std/src/math/ntt/polyops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ pub fn polyneginv_u64(h: &[u64], n: usize, modulo: u64) -> Option<Vec<u64>> {
a[0] = modulo - h0_inv;
let mut d = vec![n];
while *d.last().unwrap() > 1 {
d.push((d.last().unwrap() + 1) / 2);
d.push(d.last().unwrap().div_ceil(2));
}
d.pop();
let mut l = 1;
let mut h1a_c = vec![0; (n + 1) / 2];
let mut h1a_c = vec![0; n.div_ceil(2)];
for &target_len in d.iter().rev() {
let e = min(h.len(), target_len);
let t = min(l + e - 1, target_len);
Expand Down
2 changes: 1 addition & 1 deletion basm-std/src/math/reeds_sloane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fn reeds_sloane_prime_power(first_terms: &[u64], p: u64, e: usize) -> Vec<u64> {
// Returns (theta, u)
let (mut lo, mut hi) = (0, e);
while lo < hi {
let mid = (lo + hi + 1) / 2;
let mid = (lo + hi).div_ceil(2);
#[allow(clippy::collapsible_else_if)]
if ppow[mid] == 0 {
if x == 0 {
Expand Down

0 comments on commit b7c4c0d

Please sign in to comment.