pub struct RingMatrix { /* private fields */ }Expand description
Matrix of ring elements over Z_m.
Implementations§
Source§impl RingMatrix
impl RingMatrix
Sourcepub fn new(rows: Vec<RingVector>) -> Self
pub fn new(rows: Vec<RingVector>) -> Self
Create a new matrix from rows of ring elements.
§Panics
Panics when the rows are empty, ragged, or use different moduli.
Sourcepub fn try_new(rows: Vec<RingVector>) -> Result<Self, RingError>
pub fn try_new(rows: Vec<RingVector>) -> Result<Self, RingError>
Try to create a new matrix from rows of ring elements.
§Errors
Returns RingError::DimensionMismatch for an empty or ragged matrix and
RingError::ModulusMismatch when the rows use different moduli.
Sourcepub fn from_values(rows: &[Vec<u64>], modulus: u64) -> Self
pub fn from_values(rows: &[Vec<u64>], modulus: u64) -> Self
Create a matrix from raw values.
Sourcepub fn row_vectors(&self) -> &[RingVector]
pub fn row_vectors(&self) -> &[RingVector]
Borrow the matrix rows.
Sourcepub fn row(&self, index: usize) -> &RingVector
pub fn row(&self, index: usize) -> &RingVector
Borrow one row.
Sourcepub fn get(&self, row: usize, col: usize) -> RingElement
pub fn get(&self, row: usize, col: usize) -> RingElement
Get one entry.
Sourcepub fn set(&mut self, row: usize, col: usize, value: RingElement)
pub fn set(&mut self, row: usize, col: usize, value: RingElement)
Set one entry.
§Panics
Panics if the index is out of bounds or the element modulus does not match the matrix modulus.
Sourcepub fn permute_columns(&self, permutation: &[usize]) -> Result<Self, RingError>
pub fn permute_columns(&self, permutation: &[usize]) -> Result<Self, RingError>
Reorder columns according to permutation, where each new column j
comes from old column permutation[j].
§Errors
Returns RingError::DimensionMismatch when the permutation has the wrong
length or contains duplicates/out-of-range indices.
Sourcepub fn select_columns(&self, columns: &[usize]) -> Result<Self, RingError>
pub fn select_columns(&self, columns: &[usize]) -> Result<Self, RingError>
Select columns in the provided order.
§Errors
Returns RingError::DimensionMismatch when a requested column is out of range.
Sourcepub fn mul_vector(&self, vector: &RingVector) -> Result<RingVector, RingError>
pub fn mul_vector(&self, vector: &RingVector) -> Result<RingVector, RingError>
Multiply this matrix by a column vector.
§Errors
Returns RingError::DimensionMismatch or RingError::ModulusMismatch
when the operands are incompatible.
Sourcepub fn left_mul_vector(
&self,
vector: &RingVector,
) -> Result<RingVector, RingError>
pub fn left_mul_vector( &self, vector: &RingVector, ) -> Result<RingVector, RingError>
Multiply a row vector by this matrix.
§Errors
Returns RingError::DimensionMismatch or RingError::ModulusMismatch
when the operands are incompatible.
Sourcepub fn try_mul(&self, other: &Self) -> Result<Self, RingError>
pub fn try_mul(&self, other: &Self) -> Result<Self, RingError>
Multiply this matrix by another matrix.
§Errors
Returns RingError::DimensionMismatch or RingError::ModulusMismatch
when the operands are incompatible.
Sourcepub fn inverse(&self) -> Result<Self, RingError>
pub fn inverse(&self) -> Result<Self, RingError>
Compute the inverse of a square matrix with Gauss-Jordan elimination.
§Errors
Returns RingError::DimensionMismatch if the matrix is not square and
RingError::SingularMatrix if no invertible pivot can be found.
Trait Implementations§
Source§impl Clone for RingMatrix
impl Clone for RingMatrix
Source§fn clone(&self) -> RingMatrix
fn clone(&self) -> RingMatrix
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more