Do not enumerate product inside of lagrange_interpolate.

This commit is contained in:
Sean Bowe 2020-10-15 13:56:42 -06:00
parent 2f7b46ffa1
commit 5c563eca12
No known key found for this signature in database
GPG key ID: 95684257D8F8B031

View file

@ -448,13 +448,13 @@ pub fn lagrange_interpolate<F: Field>(points: &[F], evals: &[F]) -> Vec<F> {
// Compute (x_j - x_k)^(-1)
let denom = (*x_j - x_k).invert().unwrap();
product.resize(tmp.len() + 1, F::zero());
for (i, (a, b)) in tmp
for ((a, b), product) in tmp
.iter()
.chain(std::iter::once(&F::zero()))
.zip(std::iter::once(&F::zero()).chain(tmp.iter()))
.enumerate()
.zip(product.iter_mut())
{
product[i] = *a * (-denom * x_k) + *b * denom;
*product = *a * (-denom * x_k) + *b * denom;
}
std::mem::swap(&mut tmp, &mut product);
}