Function winter_math::mul_acc[][src]

pub fn mul_acc<B, E>(a: &mut [E], b: &[B], c: E) where
    B: FieldElement,
    E: FieldElement + From<B>, 
Expand description

Multiplies a sequence of values by a scalar and accumulates the results.

More precisely, computes a[i] + b[i] * c for all i and saves result into a[i].

When concurrent feature is enabled, the computation is performed concurrently in multiple threads.

Panics

Panics if lengths of a and b slices are not the same.

Examples

let a: Vec<BaseElement> = rand_vector(2048);
let b: Vec<BaseElement> = rand_vector(2048);
let c = BaseElement::new(12345);

let mut d = a.clone();
mul_acc(&mut d, &b, c);

for ((a, b), d) in a.into_iter().zip(b).zip(d) {
    assert_eq!(a + b * c, d);
}