Function winter_math::batch_inversion
source · pub fn batch_inversion<E>(values: &[E]) -> Vec<E>where
E: FieldElement,
Expand description
Computes a multiplicative inverse of a sequence of elements using batch inversion method.
Any ZEROs in the provided sequence are ignored.
When concurrent
feature is enabled, the inversion is performed concurrently in multiple
threads.
This function is significantly faster than inverting elements one-by-one because it
essentially transforms n
inversions into 3 * n
multiplications + 1 inversion.
Examples
let a: Vec<BaseElement> = rand_vector(2048);
let b = batch_inversion(&a);
for (&a, &b) in a.iter().zip(b.iter()) {
assert_eq!(a.inv(), b);
}