../../.cargo/katex-header.html

Function winter_math::mul_acc

source ·
pub fn mul_acc<F, E>(a: &mut [E], b: &[F], c: E)
where F: FieldElement, E: FieldElement<BaseField = F::BaseField> + ExtensionOf<F>,
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);
}