MCPcopy Create free account
hub / github.com/docknetwork/crypto / eval_direct_without_memoize

Method eval_direct_without_memoize

vb_accumulator/src/batch_utils.rs:235–252  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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 {

Callers

nothing calls this directly

Calls 3

mapMethod · 0.80
lenMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected