Skip to content

Commit bc967f6

Browse files
committed
Use shifts instead of mul/div by 2 in Toom-3
1 parent c528be1 commit bc967f6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/biguint/multiplication.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,10 +312,10 @@ fn mac3(mut acc: &mut [BigDigit], mut b: &[BigDigit], mut c: &[BigDigit]) {
312312
//
313313
// This particular sequence is given by Bodrato and is an interpolation
314314
// of the above equations.
315-
let mut comp3: BigInt = (r3 - &r1) / 3;
316-
let mut comp1: BigInt = (r1 - &r2) / 2;
315+
let mut comp3: BigInt = (r3 - &r1) / 3u32;
316+
let mut comp1: BigInt = (r1 - &r2) >> 1;
317317
let mut comp2: BigInt = r2 - &r0;
318-
comp3 = (&comp2 - comp3) / 2 + &r4 * 2;
318+
comp3 = ((&comp2 - comp3) >> 1) + (&r4 << 1);
319319
comp2 += &comp1 - &r4;
320320
comp1 -= &comp3;
321321

0 commit comments

Comments
 (0)