use super::{FieldElement, Vec};
#[derive(Debug, Clone)]
pub struct EvaluationFrame<E: FieldElement> {
current: Vec<E>,
next: Vec<E>,
}
impl<E: FieldElement> EvaluationFrame<E> {
pub fn new(num_columns: usize) -> Self {
assert!(
num_columns > 0,
"number of columns must be greater than zero"
);
EvaluationFrame {
current: E::zeroed_vector(num_columns),
next: E::zeroed_vector(num_columns),
}
}
pub fn from_rows(current: Vec<E>, next: Vec<E>) -> Self {
assert!(!current.is_empty(), "a row must contain at least one value");
assert_eq!(
current.len(),
next.len(),
"number of values in the rows must be the same"
);
Self { current, next }
}
#[inline(always)]
pub fn current(&self) -> &[E] {
&self.current
}
#[inline(always)]
pub fn current_mut(&mut self) -> &mut [E] {
&mut self.current
}
#[inline(always)]
pub fn next(&self) -> &[E] {
&self.next
}
#[inline(always)]
pub fn next_mut(&mut self) -> &mut [E] {
&mut self.next
}
}