pub struct RowMatrix<E: FieldElement> { /* private fields */ }
Expand description

A two-dimensional matrix of field elements arranged in row-major order.

The matrix is represented as a single vector of base field elements for the field defined by E type parameter. The first row_width base field elements represent the first row of the matrix, the next row_width base field elements represent the second row, and so on.

When rows are returned via the RowMatrix::row() method, base field elements are grouped together as appropriate to form elements in E.

In some cases, rows may be padded with extra elements. The number of elements which are accessible via the RowMatrix::row() method is specified by the elements_per_row member.

Implementations§

source§

impl<E: FieldElement> RowMatrix<E>

source

pub fn evaluate_polys<const N: usize>( polys: &ColMatrix<E>, blowup_factor: usize ) -> Self

Returns a new RowMatrix constructed by evaluating the provided polynomials over the domain defined by the specified blowup factor.

The provided polys matrix is assumed to contain polynomials in coefficient form (one polynomial per column). Columns in the returned matrix will contain evaluations of the corresponding polynomials over the domain defined by polynomial size (i.e., number of rows in the polys matrix) and the blowup_factor.

To improve performance, polynomials are evaluated in batches specified by the N type parameter. Minimum batch size is 1.

source

pub fn evaluate_polys_over<const N: usize>( polys: &ColMatrix<E>, domain: &StarkDomain<E::BaseField> ) -> Self

Returns a new RowMatrix constructed by evaluating the provided polynomials over the specified StarkDomain.

The provided polys matrix is assumed to contain polynomials in coefficient form (one polynomial per column). Columns in the returned matrix will contain evaluations of the corresponding polynomials over the LDE domain defined by the provided StarkDomain.

To improve performance, polynomials are evaluated in batches specified by the N type parameter. Minimum batch size is 1.

source

pub fn from_segments<const N: usize>( segments: Vec<Segment<E::BaseField, N>>, elements_per_row: usize ) -> Self

Returns a new RowMatrix instantiated from the specified matrix segments.

elements_per_row specifies how many base field elements are considered to form a single row in the matrix.

Panics

Panics if

  • segments is an empty vector.
  • elements_per_row is greater than the row width implied by the number of segments and N type parameter.
source

pub fn num_cols(&self) -> usize

Returns the number of columns in this matrix.

source

pub fn num_rows(&self) -> usize

Returns the number of rows in this matrix.

source

pub fn get(&self, col_idx: usize, row_idx: usize) -> E

Returns the element located at the specified column and row indexes in this matrix.

Panics

Panics if either col_idx or row_idx are out of bounds for this matrix.

source

pub fn row(&self, row_idx: usize) -> &[E]

Returns a reference to a row at the specified index in this matrix.

Panics

Panics if the specified row index is out of bounds.

source

pub fn data(&self) -> &[E::BaseField]

Returns the data in this matrix as a slice of field elements.

source

pub fn commit_to_rows<H>(&self) -> MerkleTree<H>
where H: ElementHasher<BaseField = E::BaseField>,

Returns a commitment to this matrix.

The commitment is built as follows:

  • Each row of the matrix is hashed into a single digest of the specified hash function.
  • The resulting values are used to build a binary Merkle tree such that each row digest becomes a leaf in the tree. Thus, the number of leaves in the tree is equal to the number of rows in the matrix.
  • The resulting Merkle tree is returned as the commitment to the entire matrix.

Trait Implementations§

source§

impl<E: Clone + FieldElement> Clone for RowMatrix<E>
where E::BaseField: Clone,

source§

fn clone(&self) -> RowMatrix<E>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<E: Debug + FieldElement> Debug for RowMatrix<E>
where E::BaseField: Debug,

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<E> RefUnwindSafe for RowMatrix<E>

§

impl<E> Send for RowMatrix<E>

§

impl<E> Sync for RowMatrix<E>

§

impl<E> Unpin for RowMatrix<E>
where <E as FieldElement>::BaseField: Unpin,

§

impl<E> UnwindSafe for RowMatrix<E>

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> 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

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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>,

§

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.