openvm_stark_backend/interaction/
trace.rs
1use p3_field::Field;
2use p3_matrix::{dense::RowMajorMatrixView, Matrix};
3
4use crate::air_builders::symbolic::{
5 symbolic_expression::SymbolicEvaluator,
6 symbolic_variable::{Entry, SymbolicVariable},
7};
8
9pub(super) struct Evaluator<'a, F: Field> {
10 pub preprocessed: &'a Option<RowMajorMatrixView<'a, F>>,
11 pub partitioned_main: &'a [RowMajorMatrixView<'a, F>],
12 pub public_values: &'a [F],
13 pub height: usize,
14 pub local_index: usize,
15}
16
17impl<F: Field> SymbolicEvaluator<F, F> for Evaluator<'_, F> {
18 fn eval_const(&self, c: F) -> F {
19 c
20 }
21 fn eval_var(&self, symbolic_var: SymbolicVariable<F>) -> F {
22 let n = self.local_index;
23 let height = self.height;
24 let index = symbolic_var.index;
25 match symbolic_var.entry {
26 Entry::Preprocessed { offset } => {
27 self.preprocessed.unwrap().get((n + offset) % height, index)
28 }
29 Entry::Main { part_index, offset } => {
30 self.partitioned_main[part_index].get((n + offset) % height, index)
31 }
32 Entry::Public => self.public_values[index],
33 _ => unreachable!("There should be no after challenge variables"),
34 }
35 }
36 fn eval_is_first_row(&self) -> F {
37 unreachable!()
38 }
39 fn eval_is_last_row(&self) -> F {
40 unreachable!()
41 }
42 fn eval_is_transition(&self) -> F {
43 unreachable!()
44 }
45}