pub struct SparseMatrix<S: Scalar + Entity> { /* private fields */ }Expand description
CSC sparse matrix wrapping faer’s SparseColMat.
Trait relationship: SparseMatrix<S> does not currently implement
the crate::Matrix trait. Sparse-aware solvers in this crate
(crate::iterative, crate::preconditioner) consume &SparseMatrix<S>
concretely. Whether sparse should join the crate::Matrix trait is an
open foundation question deferred per Foundation Spec §7 #5 — see
F-MATRIX-SHAPE in docs/internal-followups.md.
Implementations§
Source§impl<S: Scalar + SimpleEntity + Conjugate<Canonical = S> + ComplexField> SparseMatrix<S>
impl<S: Scalar + SimpleEntity + Conjugate<Canonical = S> + ComplexField> SparseMatrix<S>
Sourcepub fn from_triplets(
nrows: usize,
ncols: usize,
triplets: &[(usize, usize, S)],
) -> Result<Self, LinalgError>
pub fn from_triplets( nrows: usize, ncols: usize, triplets: &[(usize, usize, S)], ) -> Result<Self, LinalgError>
Build from COO (triplet) format.
Duplicate entries at the same (row, col) are summed.
Sourcepub fn get(&self, row: usize, col: usize) -> S
pub fn get(&self, row: usize, col: usize) -> S
Element access (returns zero for missing entries).
Sourcepub fn to_dense(&self) -> DenseMatrix<S>
pub fn to_dense(&self) -> DenseMatrix<S>
Convert to dense matrix.
Sourcepub fn row_indices(&self) -> Vec<usize>
pub fn row_indices(&self) -> Vec<usize>
CSC row indices.
Sourcepub fn mul_vec(&self, x: &[S]) -> Result<Vec<S>, LinalgError>
pub fn mul_vec(&self, x: &[S]) -> Result<Vec<S>, LinalgError>
Sparse matrix-vector product: y = A * x.
Sourcepub fn transpose(&self) -> Result<SparseMatrix<S>, LinalgError>
pub fn transpose(&self) -> Result<SparseMatrix<S>, LinalgError>
Transpose of the sparse matrix.
Auto Trait Implementations§
impl<S> Freeze for SparseMatrix<S>
impl<S> RefUnwindSafe for SparseMatrix<S>
impl<S> Send for SparseMatrix<S>
impl<S> Sync for SparseMatrix<S>
impl<S> Unpin for SparseMatrix<S>
impl<S> UnsafeUnpin for SparseMatrix<S>
impl<S> UnwindSafe for SparseMatrix<S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more