mirror of
https://github.com/saymrwulf/pasta_curves-source.git
synced 2026-09-06 20:20:34 +00:00
Do not enumerate product inside of lagrange_interpolate.
This commit is contained in:
parent
2f7b46ffa1
commit
5c563eca12
1 changed files with 3 additions and 3 deletions
|
|
@ -448,13 +448,13 @@ pub fn lagrange_interpolate<F: Field>(points: &[F], evals: &[F]) -> Vec<F> {
|
||||||
// Compute (x_j - x_k)^(-1)
|
// Compute (x_j - x_k)^(-1)
|
||||||
let denom = (*x_j - x_k).invert().unwrap();
|
let denom = (*x_j - x_k).invert().unwrap();
|
||||||
product.resize(tmp.len() + 1, F::zero());
|
product.resize(tmp.len() + 1, F::zero());
|
||||||
for (i, (a, b)) in tmp
|
for ((a, b), product) in tmp
|
||||||
.iter()
|
.iter()
|
||||||
.chain(std::iter::once(&F::zero()))
|
.chain(std::iter::once(&F::zero()))
|
||||||
.zip(std::iter::once(&F::zero()).chain(tmp.iter()))
|
.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);
|
std::mem::swap(&mut tmp, &mut product);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue