Skip to content

Commit

Permalink
feat: elementary school addition/multiplication
Browse files Browse the repository at this point in the history
  • Loading branch information
0xWOLAND committed Nov 19, 2023
1 parent 6e9f39c commit fdcb457
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/ntt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,16 @@ fn fft(inp: Vec<BigInt>, c: &Constants, w: BigInt) -> Vec<BigInt> {
.zip(hi)
.enumerate()
.for_each(|(idx, (lo, hi))| {
let neg = (*lo).sub_mod(*hi, MOD);
*lo = (*lo).add_mod(*hi, MOD);
let neg = if *lo < *hi {
(MOD + *lo) - *hi
} else {
*lo - *hi
};
*lo = if *lo + *hi >= MOD {
(*lo + *hi) - MOD
} else {
*lo + *hi
};
*hi = neg.mul_mod(pre[nchunks * idx], MOD);
});
});
Expand Down

0 comments on commit fdcb457

Please sign in to comment.