Matrix

Trait Matrix 

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

Source

fn rows(&self) -> DimensionType

Get the number of rows in the matrix.

Source

fn cols(&self) -> DimensionType

Get the number of columns in the matrix.

Source

fn get(&self, row: usize, col: usize) -> Option<Precision>

Get a specific matrix element, returning None if it’s zero or out of bounds.

Source

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.

Source

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.

Source

fn multiply_vector( &self, x: &[Precision], result: &mut [Precision], ) -> Result<()>

Perform matrix-vector multiplication: result = A * x

Source

fn multiply_vector_add( &self, x: &[Precision], result: &mut [Precision], ) -> Result<()>

Perform matrix-vector multiplication with accumulation: result += A * x

Source

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.

Source

fn diagonal_dominance_factor(&self) -> Option<Precision>

Get the diagonal dominance factor (minimum ratio of diagonal to off-diagonal).

Source

fn nnz(&self) -> usize

Get the number of non-zero elements.

Source

fn sparsity_info(&self) -> SparsityInfo

Get sparsity pattern information.

Source

fn conditioning_info(&self) -> ConditioningInfo

Get matrix conditioning information.

Source

fn format_name(&self) -> &'static str

Get the storage format name.

Provided Methods§

Source

fn is_square(&self) -> bool

Check if the matrix is square.

Source

fn frobenius_norm(&self) -> Precision

Get the Frobenius norm of the matrix.

Source

fn spectral_radius_estimate(&self) -> Precision

Estimate the spectral radius (largest eigenvalue magnitude). Uses Gershgorin circle theorem for a conservative estimate.

Implementors§