uint icon indicating copy to clipboard operation
uint copied to clipboard

`algorithms/gcd/gcd_old`: We can update r0 and r1 in place. This won't remove the partially

Open github-actions[bot] opened this issue 2 years ago • 0 comments

On 2022-06-06 @recmo wrote in 4c74c09 “Merge pull request #110 from recmo/gcd”:

We can update r0 and r1 in place. This won't remove the partially redundant call to lehmer_update, but it reduces memory usage. We shadow s for readability.

/// Our approach is similar to Cohen, but instead doing the second round
/// on the same matrix, we start we a fresh matrix and multiply both in the
/// end. This requires 8 additional multiplications, but allows us to use
/// the tighter stopping conditions from Jebelean. It also seems the simplest
/// out of these solutions.
// OPT: We can update r0 and r1 in place. This won't remove the partially
// redundant call to lehmer_update, but it reduces memory usage.
// We shadow s for readability.
#[allow(clippy::shadow_unrelated)]
fn lehmer_double(mut r0: U256, mut r1: U256) -> Matrix {
    debug_assert!(r0 >= r1);
    if r0.leading_zeros() >= 192 {
        // OPT: Rewrite using to_u64 -> Option

From src/algorithms/gcd/gcd_old.rs:287

github-actions[bot] avatar Jun 06 '22 03:06 github-actions[bot]