pub struct CscMatrix<T: Real = f64> {
pub n_rows: usize,
pub col_ptr: Vec<usize>,
pub row_idx: Vec<u32>,
pub val: Vec<T>,
}Expand description
Sparse matrix in compressed sparse column (CSC) format.
See the module documentation for the invariants. Equality is structural (same dimensions, same stored entries in the same order), which for matrices satisfying the invariants is equality of the matrices.
Fields§
§n_rows: usizeNumber of rows m.
col_ptr: Vec<usize>Column pointers, length n + 1; column j occupies
col_ptr[j]..col_ptr[j + 1].
row_idx: Vec<u32>Row index of each stored entry, strictly increasing within a column.
val: Vec<T>Value of each stored entry; finite and nonzero.
Implementations§
Source§impl<T: Real> CscMatrix<T>
impl<T: Real> CscMatrix<T>
Sourcepub fn new(n_rows: usize, n_cols: usize) -> Self
pub fn new(n_rows: usize, n_cols: usize) -> Self
The m × n zero matrix (the contract’s name; the same as
CscMatrix::zeros).
§Panics
If m or n exceeds u32::MAX.
Sourcepub fn from_raw_parts(
n_rows: usize,
col_ptr: Vec<usize>,
row_idx: Vec<u32>,
val: Vec<T>,
) -> Result<Self, SparseError>
pub fn from_raw_parts( n_rows: usize, col_ptr: Vec<usize>, row_idx: Vec<u32>, val: Vec<T>, ) -> Result<Self, SparseError>
Builds a matrix from raw compressed arrays, validating every invariant.
Sourcepub fn from_triplets(
n_rows: usize,
n_cols: usize,
triplets: &[(Row, Col, T)],
) -> Result<Self, SparseError>
pub fn from_triplets( n_rows: usize, n_cols: usize, triplets: &[(Row, Col, T)], ) -> Result<Self, SparseError>
Builds an m × n matrix from triplets (i, j, v) by Algorithm C:
duplicates are summed in input order and exact zeros are dropped.
Sourcepub fn gaxpy(&self, alpha: T, x: &[T], y: &mut [T])
pub fn gaxpy(&self, alpha: T, x: &[T], y: &mut [T])
y ← y + α A x with dense x (length n) and y (length m),
column by column: y_i ← y_i + a_ij (α x_j) for the stored entries,
skipping the columns with x_j = 0.
§Panics
If x.len() != n or y.len() != m.
Sourcepub fn to_csr(&self) -> CsrMatrix<T>
pub fn to_csr(&self) -> CsrMatrix<T>
The same matrix in row-wise (CSR) storage, by Algorithm T.
Sourcepub fn check_invariants(&self) -> Result<(), SparseError>
pub fn check_invariants(&self) -> Result<(), SparseError>
Checks invariants (C1)–(C4).
Source§impl<T: Real> CscMatrix<T>
impl<T: Real> CscMatrix<T>
Sourcepub fn pattern(&self) -> Pattern
pub fn pattern(&self) -> Pattern
The structure without values, consumed by the orderings (Chapter 5.9).
Sourcepub fn symmetric_pattern(&self) -> Result<Pattern, SparseError>
pub fn symmetric_pattern(&self) -> Result<Pattern, SparseError>
The pattern of A + Aᵀ (Algorithm S) for the symmetric orderings;
an error unless A is square.
Trait Implementations§
Source§impl<T: Real> ColumnSource<T> for CscMatrix<T>
An explicit square matrix B.
impl<T: Real> ColumnSource<T> for CscMatrix<T>
An explicit square matrix B.