pub struct Triplets<T: Real = f64> {
pub n_rows: usize,
pub n_cols: usize,
pub row: Vec<u32>,
pub col: Vec<u32>,
pub val: Vec<T>,
}Expand description
Coordinate builder: push (i, j, v) in any order, duplicates summed in
insertion order, then Triplets::to_csc (Algorithm C′).
The fields are public, as in the contract, so a list assembled by
other means can be converted; to_csc validates them ((D1)–(D3)).
Fields§
§n_rows: usizeNumber of rows m.
n_cols: usizeNumber of columns n.
row: Vec<u32>Row index i_k of each triplet.
col: Vec<u32>Column index j_k of each triplet.
val: Vec<T>Value v_k of each triplet.
Implementations§
Source§impl<T: Real> Triplets<T>
impl<T: Real> Triplets<T>
Sourcepub fn from_csc(a: &CscMatrix<T>) -> Self
pub fn from_csc(a: &CscMatrix<T>) -> Self
The stored entries of a, one triplet each, column by column: a
builder that Triplets::to_csc maps back to a exactly, and to
which further entries can be pushed.
Sourcepub fn push(&mut self, i: u32, j: u32, v: T)
pub fn push(&mut self, i: u32, j: u32, v: T)
Appends the triplet (i, j, v). Indices are not checked here (they
are in to_csc, step C′1); a zero v is legal (step C′4).
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Removes every triplet, keeping the dimensions and the allocated buffers (for a matrix rebuilt with new values at every iteration).
Sourcepub fn check_invariants(&self) -> Result<(), SparseError>
pub fn check_invariants(&self) -> Result<(), SparseError>
Checks (D1)–(D3): equal lengths, dimensions in u32, indices in
range, values finite. The validation step C′1 of Triplets::to_csc.
Sourcepub fn to_csc(&self) -> Result<CscMatrix<T>, SparseError>
pub fn to_csc(&self) -> Result<CscMatrix<T>, SparseError>
Algorithm C′: the m × n matrix the triplets denote — sorted,
duplicates summed in insertion order, zero sums not stored (C3) —
or the first violation of (D1)–(D3) found.