Struct winter_prover::matrix::RowMatrix
source · 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>
impl<E: FieldElement> RowMatrix<E>
sourcepub fn evaluate_polys<const N: usize>(
polys: &ColMatrix<E>,
blowup_factor: usize
) -> Self
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.
sourcepub fn evaluate_polys_over<const N: usize>(
polys: &ColMatrix<E>,
domain: &StarkDomain<E::BaseField>
) -> Self
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.
sourcepub fn from_segments<const N: usize>(
segments: Vec<Segment<E::BaseField, N>>,
elements_per_row: usize
) -> Self
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
segmentsis an empty vector.elements_per_rowis greater than the row width implied by the number of segments andNtype parameter.
sourcepub fn get(&self, col_idx: usize, row_idx: usize) -> E
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.
sourcepub fn row(&self, row_idx: usize) -> &[E]
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.
sourcepub fn data(&self) -> &[E::BaseField]
pub fn data(&self) -> &[E::BaseField]
Returns the data in this matrix as a slice of field elements.
sourcepub fn commit_to_rows<H>(&self) -> MerkleTree<H>where
H: ElementHasher<BaseField = E::BaseField>,
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.