Evaluation of polynomial without creating the polynomial as the variables are already known. Slower than `Self::eval_direct` but uses less memory at the cost of recomputing products of field elements
(additions: &[F], alpha: &F, x: &F)
| 233 | /// Slower than `Self::eval_direct` but uses less memory at the cost of recomputing |
| 234 | /// products of field elements |
| 235 | pub fn eval_direct_without_memoize(additions: &[F], alpha: &F, x: &F) -> F { |
| 236 | let n = additions.len(); |
| 237 | (0..n) |
| 238 | .map(|s| { |
| 239 | let factor = Self::compute_factor(s, additions, alpha); |
| 240 | let poly = if s < n - 1 { |
| 241 | additions |
| 242 | .iter() |
| 243 | .skip(s + 1) |
| 244 | .map(|a| *a - *x) |
| 245 | .fold(F::one(), |a, b| a * b) |
| 246 | } else { |
| 247 | F::one() |
| 248 | }; |
| 249 | poly * factor |
| 250 | }) |
| 251 | .fold(F::zero(), |a, b| a + b) |
| 252 | } |
| 253 | |
| 254 | fn compute_factor(s: usize, additions: &[F], alpha: &F) -> F { |
| 255 | if s > 0 { |