openvm_stark_backend/interaction/
trace.rs1use 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 } => self
27 .preprocessed
28 .unwrap()
29 .get((n + offset) % height, index)
30 .expect("matrix index out of bounds"),
31 Entry::Main { part_index, offset } => self.partitioned_main[part_index]
32 .get((n + offset) % height, index)
33 .expect("matrix index out of bounds"),
34 Entry::Public => self.public_values[index],
35 _ => unreachable!("There should be no after challenge variables"),
36 }
37 }
38 fn eval_is_first_row(&self) -> F {
39 unreachable!()
40 }
41 fn eval_is_last_row(&self) -> F {
42 unreachable!()
43 }
44 fn eval_is_transition(&self) -> F {
45 unreachable!()
46 }
47}