pub struct CsrMatrix { /* private fields */ }Expand description
Compressed-sparse-row matrix.
Stores only the non-zero entries data together with their column indices
indices (per row, in ascending column order) and the CSR row-pointer
indptr (length nrows + 1). A zero entry must not be stored.
Implementations§
Source§impl CsrMatrix
impl CsrMatrix
Sourcepub fn from_dense(dense: &[f64], nrows: usize, ncols: usize) -> Self
pub fn from_dense(dense: &[f64], nrows: usize, ncols: usize) -> Self
Build a CSR matrix from a dense row-major slice (row length ncols).
Zero entries are dropped.
Sourcepub fn get(&self, r: usize, c: usize) -> f64
pub fn get(&self, r: usize, c: usize) -> f64
Look up the stored value at (r, c), or 0.0 if not present.
Sourcepub fn scaled_identity_minus_scaled(&self, diag: f64) -> CsrMatrix
pub fn scaled_identity_minus_scaled(&self, diag: f64) -> CsrMatrix
Build the Newton matrix A = I − diag·self directly in CSR storage,
merging the unit diagonal with the scaled Jacobian entries per row
(both in ascending column order) without ever densifying.
Sourcepub fn jacobian<F>(
f: F,
t: f64,
y: &[f64],
f0: &[f64],
cols: Option<&[usize]>,
) -> Result<CsrMatrix, OdeError>
pub fn jacobian<F>( f: F, t: f64, y: &[f64], f0: &[f64], cols: Option<&[usize]>, ) -> Result<CsrMatrix, OdeError>
Build the full Jacobian J = df/dy at (t, y) via forward finite
differences, returned as a CsrMatrix. f0 must be f(t, y) and cols
is the set of columns to perturb (a sparsity pattern, or None for the
full dense pattern). When cols is None every column is finite-
differenced, matching the dense linalg::jacobian helper but in
compressed storage (exact-zero entries are dropped).
§Errors
Propagates any error returned by the RHS f.
Source§impl CsrMatrix
impl CsrMatrix
Sourcepub fn jacobian_colored<F>(
f: F,
t: f64,
y: &[f64],
f0: &[f64],
pattern: &JacobianPattern,
) -> Result<CsrMatrix, OdeError>
pub fn jacobian_colored<F>( f: F, t: f64, y: &[f64], f0: &[f64], pattern: &JacobianPattern, ) -> Result<CsrMatrix, OdeError>
Jacobian J = df/dy by forward differences, with one RHS call per color
instead of one per column.
Columns are grouped with JacobianPattern::column_coloring. All columns
of a color are perturbed together, and each row’s entry is recovered from
the single column of that color that the row’s pattern contains. The
result equals CsrMatrix::jacobian when pattern covers the true
structure.
§Errors
Propagates any error returned by the RHS f, or returns
OdeError::Invalid if the pattern size does not match y.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CsrMatrix
impl RefUnwindSafe for CsrMatrix
impl Send for CsrMatrix
impl Sync for CsrMatrix
impl Unpin for CsrMatrix
impl UnsafeUnpin for CsrMatrix
impl UnwindSafe for CsrMatrix
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T, U> Imply<T> for U
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> ⓘ
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> ⓘ
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.