pub struct Matrix<E> where
    E: FieldElement, 
{ /* private fields */ }
Expand description

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

This struct is used as a backing type for many objects manipulated by the prover. The matrix itself does not assign any contextual meaning to the values stored in it. For example, columns may contain evaluations of polynomials, or polynomial coefficients, or really anything else. However, the matrix does expose a number of methods which make assumptions about the underlying data.

A matrix imposes the following restrictions on its content:

  • A matrix must consist of at least 1 column and at least 2 rows.
  • All columns must be of the same length.
  • Number of rows must be a power of two.

Implementations

Returns a new Matrix instantiated with the data from the specified columns.

Panics

Panics if:

  • The provided vector of columns is empty.
  • Not all of the columns have the same number of elements.
  • Number of rows is smaller than or equal to 1.
  • Number of rows is not a power of two.

Returns the number of columns in this matrix.

Returns the number of rows in this matrix.

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.

Set the cell in this matrix at the specified column and row indexes to the provided value.

Panics

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

Returns a reference to the column at the specified index.

Returns a reference to the column at the specified index.

Copies values of all columns at the specified row into the specified row slice.

Panics

Panics if row_idx is out of bounds for this matrix.

Updates a row in this matrix at the specified index to the provided data.

Panics

Panics if row_idx is out of bounds for this matrix.

Returns an iterator over the columns of this matrix.

Returns a mutable iterator over the columns of this matrix.

Interpolates columns of the matrix into polynomials in coefficient form and returns the result.

The interpolation is performed as follows:

  • Each column of the matrix is interpreted as evaluations of degree num_rows - 1 polynomial over a subgroup of size num_rows.
  • Then each column is interpolated using iFFT algorithm into a polynomial in coefficient form.
  • The resulting polynomials are returned as a single matrix where each column contains coefficients of a degree num_rows - 1 polynomial.

Interpolates columns of the matrix into polynomials in coefficient form and returns the result. The input matrix is consumed in the process.

The interpolation is performed as follows:

  • Each column of the matrix is interpreted as evaluations of degree num_rows - 1 polynomial over a subgroup of size num_rows.
  • Then each column is interpolated (in place) using iFFT algorithm into a polynomial in coefficient form.
  • The resulting polynomials are returned as a single matrix where each column contains coefficients of a degree num_rows - 1 polynomial.

Evaluates polynomials contained in the columns of this matrix over the specified domain and returns the result.

The evaluation is done as follows:

  • Each column of the matrix is interpreted as coefficients of degree num_rows - 1 polynomial.
  • These polynomials are evaluated over the LDE domain defined by the specified StarkDomain using FFT algorithm. The domain specification includes the size of the subgroup as well as the domain offset (to define a coset).
  • The resulting evaluations are returned in a new Matrix.

Evaluates polynomials contained in the columns of this matrix at a single point x.

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 built 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 return as the commitment to the entire matrix.

Returns the columns of this matrix as a list of vectors.

TODO: replace this with an iterator.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Should always be Self

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.