Create a polynomial with given points in `updates` as: `(updates[0]-x) * (updates[1]-x) * (updates[2] - x)...(updates[last] - x)`
(updates: &[F])
| 41 | /// Create a polynomial with given points in `updates` as: |
| 42 | /// `(updates[0]-x) * (updates[1]-x) * (updates[2] - x)...(updates[last] - x)` |
| 43 | fn poly_from_given_updates<F: PrimeField>(updates: &[F]) -> DensePolynomial<F> { |
| 44 | if updates.is_empty() { |
| 45 | return DensePolynomial::zero(); |
| 46 | } |
| 47 | |
| 48 | let minus_one = -F::one(); |
| 49 | |
| 50 | // [(updates[0]-x), (updates[1]-x), (updates[2] - x), ..., (updates[last] - x)] |
| 51 | let terms = cfg_into_iter!(updates) |
| 52 | .map(|i| DensePolynomial::from_coefficients_slice(&[*i, minus_one])) |
| 53 | .collect::<Vec<_>>(); |
| 54 | |
| 55 | // Product (updates[0]-x) * (updates[1]-x) * (updates[2] - x)...(updates[last] - x) |
| 56 | multiply_many_polys(terms) |
| 57 | // Note: Using multiply operator from ark-poly is orders of magnitude slower than naive multiplication |
| 58 | // x_i.into_iter().reduce(|a, b| &a * &b).unwrap() |
| 59 | } |
| 60 | |
| 61 | // Polynomials as described in section 3 of the paper |
| 62 |
no test coverage detected