pub trait Matrix: Send + Sync {
Show 16 methods
// Required methods
fn rows(&self) -> DimensionType;
fn cols(&self) -> DimensionType;
fn get(&self, row: usize, col: usize) -> Option<Precision>;
fn row_iter(
&self,
row: usize,
) -> Box<dyn Iterator<Item = (IndexType, Precision)> + '_>;
fn col_iter(
&self,
col: usize,
) -> Box<dyn Iterator<Item = (IndexType, Precision)> + '_>;
fn multiply_vector(
&self,
x: &[Precision],
result: &mut [Precision],
) -> Result<()>;
fn multiply_vector_add(
&self,
x: &[Precision],
result: &mut [Precision],
) -> Result<()>;
fn is_diagonally_dominant(&self) -> bool;
fn diagonal_dominance_factor(&self) -> Option<Precision>;
fn nnz(&self) -> usize;
fn sparsity_info(&self) -> SparsityInfo;
fn conditioning_info(&self) -> ConditioningInfo;
fn format_name(&self) -> &'static str;
// Provided methods
fn is_square(&self) -> bool { ... }
fn frobenius_norm(&self) -> Precision { ... }
fn spectral_radius_estimate(&self) -> Precision { ... }
}Expand description
Trait defining the interface for matrix operations.
This trait abstracts over different matrix storage formats, allowing algorithms to work with CSR, CSC, or graph adjacency representations transparently.
Required Methods§
Sourcefn rows(&self) -> DimensionType
fn rows(&self) -> DimensionType
Get the number of rows in the matrix.
Sourcefn cols(&self) -> DimensionType
fn cols(&self) -> DimensionType
Get the number of columns in the matrix.
Sourcefn get(&self, row: usize, col: usize) -> Option<Precision>
fn get(&self, row: usize, col: usize) -> Option<Precision>
Get a specific matrix element, returning None if it’s zero or out of bounds.
Sourcefn row_iter(
&self,
row: usize,
) -> Box<dyn Iterator<Item = (IndexType, Precision)> + '_>
fn row_iter( &self, row: usize, ) -> Box<dyn Iterator<Item = (IndexType, Precision)> + '_>
Get an iterator over non-zero elements in a specific row. Returns (column_index, value) pairs.
Sourcefn col_iter(
&self,
col: usize,
) -> Box<dyn Iterator<Item = (IndexType, Precision)> + '_>
fn col_iter( &self, col: usize, ) -> Box<dyn Iterator<Item = (IndexType, Precision)> + '_>
Get an iterator over non-zero elements in a specific column. Returns (row_index, value) pairs.
Sourcefn multiply_vector(
&self,
x: &[Precision],
result: &mut [Precision],
) -> Result<()>
fn multiply_vector( &self, x: &[Precision], result: &mut [Precision], ) -> Result<()>
Perform matrix-vector multiplication: result = A * x
Sourcefn multiply_vector_add(
&self,
x: &[Precision],
result: &mut [Precision],
) -> Result<()>
fn multiply_vector_add( &self, x: &[Precision], result: &mut [Precision], ) -> Result<()>
Perform matrix-vector multiplication with accumulation: result += A * x
Sourcefn is_diagonally_dominant(&self) -> bool
fn is_diagonally_dominant(&self) -> bool
Check if the matrix is diagonally dominant. A matrix is diagonally dominant if |a_ii| >= Σ_{j≠i} |a_ij| for all i.
Sourcefn diagonal_dominance_factor(&self) -> Option<Precision>
fn diagonal_dominance_factor(&self) -> Option<Precision>
Get the diagonal dominance factor (minimum ratio of diagonal to off-diagonal).
Sourcefn sparsity_info(&self) -> SparsityInfo
fn sparsity_info(&self) -> SparsityInfo
Get sparsity pattern information.
Sourcefn conditioning_info(&self) -> ConditioningInfo
fn conditioning_info(&self) -> ConditioningInfo
Get matrix conditioning information.
Sourcefn format_name(&self) -> &'static str
fn format_name(&self) -> &'static str
Get the storage format name.
Provided Methods§
Sourcefn frobenius_norm(&self) -> Precision
fn frobenius_norm(&self) -> Precision
Get the Frobenius norm of the matrix.
Sourcefn spectral_radius_estimate(&self) -> Precision
fn spectral_radius_estimate(&self) -> Precision
Estimate the spectral radius (largest eigenvalue magnitude). Uses Gershgorin circle theorem for a conservative estimate.