Skip to main content

Trace

Struct Trace 

Source
pub struct Trace<F: Field> { /* private fields */ }
Expand description

An execution trace: a 2D table of field elements.

Stored in row-major order: data[row * column_count + col]. Each row has exactly column_count elements.

§Examples

use field_cat::F101;
use machine_cat::{Column, ColumnCount, Trace};

let trace = Trace::from_rows(
    ColumnCount::new(2),
    &[
        vec![F101::new(1), F101::new(1)],
        vec![F101::new(1), F101::new(2)],
        vec![F101::new(2), F101::new(3)],
        vec![F101::new(3), F101::new(5)],
    ],
)?;

assert_eq!(trace.get(2, Column::new(0))?, F101::new(2));
assert_eq!(trace.get(2, Column::new(1))?, F101::new(3));

Implementations§

Source§

impl<F: Field> Trace<F>

Source

pub fn from_rows( column_count: ColumnCount, rows: &[Vec<F>], ) -> Result<Self, Error>

Construct a trace from a vector of rows.

Each inner vector must have exactly column_count elements.

§Errors

Returns Error::EmptyTrace if rows is empty, or Error::RowLengthMismatch if any row has the wrong length.

Source

pub fn column_count(&self) -> ColumnCount

The number of columns.

Source

pub fn row_count(&self) -> RowCount

The number of rows.

Source

pub fn get(&self, row: usize, col: Column) -> Result<F, Error>

Get the value at (row, col).

§Errors

Returns Error::ColumnOutOfBounds if the row or column is out of range.

Source

pub fn row_pair_assignment( &self, row: usize, ) -> Result<impl Fn(ColumnRef) -> Result<F, Error> + '_, Error>

Build an assignment function for a row pair (row, row+1).

The returned closure maps ColumnRef::Current to values in row and ColumnRef::Next to values in row + 1.

§Errors

Returns Error::InsufficientRows if row + 1 >= row_count.

Source

pub fn column_values(&self, col: Column) -> Result<Vec<F>, Error>

Extract all values from a single column.

Returns a vector of length row_count.

§Errors

Returns Error::ColumnOutOfBounds if col is out of range.

Source

pub fn data(&self) -> &[F]

The raw data as a flat slice (row-major order).

Trait Implementations§

Source§

impl<F: Clone + Field> Clone for Trace<F>

Source§

fn clone(&self) -> Trace<F>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<F: Debug + Field> Debug for Trace<F>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<F> Freeze for Trace<F>

§

impl<F> RefUnwindSafe for Trace<F>
where F: RefUnwindSafe,

§

impl<F> Send for Trace<F>
where F: Send,

§

impl<F> Sync for Trace<F>
where F: Sync,

§

impl<F> Unpin for Trace<F>
where F: Unpin,

§

impl<F> UnsafeUnpin for Trace<F>

§

impl<F> UnwindSafe for Trace<F>
where F: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.