/// Performs a batch inversion using Montgomery's trick, returns the product
/// of every inverse. Zero inputs are ignored.
Performs a batch inversion using Montgomery's trick, returns the product
of every inverse. Zero inputs are ignored.
Performs a batch inversion using Montgomery ' s trick returns the product of every inverse . Zero inputs are ignored .
fn batch_invert(v: &mut [Self]) -> Self {
        let mut tmp = Vec::with_capacity(v.len());
        let mut acc = Self::one();
        for p in v.iter() {
            tmp.push(acc);
            acc = Self::conditional_select(&(acc * p), &acc, p.ct_is_zero());
        }
        acc = acc.invert().unwrap();
        let allinv = acc;
        for (p, tmp) in v.iter_mut().rev().zip(tmp.into_iter().rev()) {
            let skip = p.ct_is_zero();
            let tmp = tmp * acc;
            acc = Self::conditional_select(&(acc * *p), &acc, skip);
            *p = Self::conditional_select(&tmp, p, skip);
        }
        allinv
    }
fn batch_invert ( v : & mut [ Self ] ) -> Self { let mut tmp = Vec :: with_capacity ( v . len ( ) ) ; let mut acc = Self :: one ( ) ; for p in v . iter ( ) { tmp . push ( acc ) ; acc = Self :: conditional_select ( & ( acc * p ) , & acc , p . ct_is_zero ( ) ) ; } acc = acc . invert ( ) . unwrap ( ) ; let allinv = acc ; for ( p , tmp ) in v . iter_mut ( ) . rev ( ) . zip ( tmp . into_iter ( ) . rev ( ) ) { let skip = p . ct_is_zero ( ) ; let tmp = tmp * acc ; acc = Self :: conditional_select ( & ( acc * * p ) , & acc , skip ) ; * p = Self :: conditional_select ( & tmp , p , skip ) ; } allinv }
Performs a batch inversion using Montgomery's trick, returns the product
of every inverse.
Performs a batch inversion using Montgomery ' s trick returns the product of every inverse .
v
&mut [Self]