pub struct StoichMatrix(/* private fields */);Expand description
Newtype around sprs::CsMat that serializes transparently.
Keeping this as a newtype (rather than a bare CsMat) lets us evolve the
representation later — e.g. switching to a hand-rolled CSR or adding
per-column cached metadata — without touching call sites.
Implementations§
Source§impl StoichMatrix
impl StoichMatrix
Sourcepub fn from_triplets(
n_rows: usize,
n_cols: usize,
triplets: impl IntoIterator<Item = (usize, usize, f64)>,
) -> Self
pub fn from_triplets( n_rows: usize, n_cols: usize, triplets: impl IntoIterator<Item = (usize, usize, f64)>, ) -> Self
Build from (row, col, value) triplets. Shape is (n_rows, n_cols).
Duplicate (row, col) entries are summed (matches sprs semantics).
Sourcepub fn zeros(n_rows: usize, n_cols: usize) -> Self
pub fn zeros(n_rows: usize, n_cols: usize) -> Self
Empty matrix of the given shape (CSC orientation).
pub fn rows(&self) -> usize
pub fn cols(&self) -> usize
pub fn nnz(&self) -> usize
pub fn inner(&self) -> &CsMat<f64>
pub fn into_inner(self) -> CsMat<f64>
Sourcepub fn column(&self, col: usize) -> Vec<(usize, f64)>
pub fn column(&self, col: usize) -> Vec<(usize, f64)>
Iterate non-zero entries of a single reaction column as (met_row, coef).
Assumes CSC orientation (the invariant enforced by our constructors). If the underlying matrix happens to be CSR, we fall back to a linear scan of all triplets — correct, just slower.
Trait Implementations§
Source§impl Clone for StoichMatrix
impl Clone for StoichMatrix
Source§fn clone(&self) -> StoichMatrix
fn clone(&self) -> StoichMatrix
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for StoichMatrix
impl Debug for StoichMatrix
Source§impl Default for StoichMatrix
impl Default for StoichMatrix
Source§impl<'de> Deserialize<'de> for StoichMatrix
impl<'de> Deserialize<'de> for StoichMatrix
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for StoichMatrix
impl RefUnwindSafe for StoichMatrix
impl Send for StoichMatrix
impl Sync for StoichMatrix
impl Unpin for StoichMatrix
impl UnsafeUnpin for StoichMatrix
impl UnwindSafe for StoichMatrix
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