Remove prefix before calling eval_unfiltered_*

This commit is contained in:
wborgeaud 2021-06-23 16:06:30 +02:00
parent c01e772fd8
commit 0a75dcdb95
2 changed files with 14 additions and 2 deletions

View File

@ -58,8 +58,9 @@ pub trait Gate<F: Extendable<D>, const D: usize>: 'static + Send + Sync {
vars: EvaluationTargets<D>, vars: EvaluationTargets<D>,
) -> Vec<ExtensionTarget<D>>; ) -> Vec<ExtensionTarget<D>>;
fn eval_filtered(&self, vars: EvaluationVars<F, D>, prefix: &[bool]) -> Vec<F::Extension> { fn eval_filtered(&self, mut vars: EvaluationVars<F, D>, prefix: &[bool]) -> Vec<F::Extension> {
let filter = compute_filter(prefix, vars.local_constants); let filter = compute_filter(prefix, vars.local_constants);
vars.remove_prefix(prefix);
self.eval_unfiltered(vars) self.eval_unfiltered(vars)
.into_iter() .into_iter()
.map(|c| filter * c) .map(|c| filter * c)
@ -67,8 +68,9 @@ pub trait Gate<F: Extendable<D>, const D: usize>: 'static + Send + Sync {
} }
/// Like `eval_filtered`, but specialized for points in the base field. /// Like `eval_filtered`, but specialized for points in the base field.
fn eval_filtered_base(&self, vars: EvaluationVarsBase<F>, prefix: &[bool]) -> Vec<F> { fn eval_filtered_base(&self, mut vars: EvaluationVarsBase<F>, prefix: &[bool]) -> Vec<F> {
let filter = compute_filter(prefix, vars.local_constants); let filter = compute_filter(prefix, vars.local_constants);
vars.remove_prefix(prefix);
self.eval_unfiltered_base(vars) self.eval_unfiltered_base(vars)
.into_iter() .into_iter()
.map(|c| c * filter) .map(|c| c * filter)

View File

@ -27,6 +27,16 @@ impl<'a, F: Extendable<D>, const D: usize> EvaluationVars<'a, F, D> {
let arr = self.local_wires[wire_range].try_into().unwrap(); let arr = self.local_wires[wire_range].try_into().unwrap();
ExtensionAlgebra::from_basefield_array(arr) ExtensionAlgebra::from_basefield_array(arr)
} }
pub fn remove_prefix(&mut self, prefix: &[bool]) {
self.local_constants = &self.local_constants[prefix.len()..];
}
}
impl<'a, F: Field> EvaluationVarsBase<'a, F> {
pub fn remove_prefix(&mut self, prefix: &[bool]) {
self.local_constants = &self.local_constants[prefix.len()..];
}
} }
#[derive(Copy, Clone)] #[derive(Copy, Clone)]