pub struct CscMatrix<'a> {
pub nrows: usize,
pub ncols: usize,
pub indptr: Cow<'a, [usize]>,
pub indices: Cow<'a, [usize]>,
pub data: Cow<'a, [f64]>,
}
Expand description
A matrix in Compressed Sparse Column format.
Fields§
§nrows: usize
The number of rows in the matrix.
ncols: usize
The number of columns in the matrix.
indptr: Cow<'a, [usize]>
The CSC column pointer array.
It contains the offsets into the index and data arrays of the entries in each column.
indices: Cow<'a, [usize]>
The CSC index array.
It contains the row index of each non-zero entry.
data: Cow<'a, [f64]>
The CSC data array.
It contains the values of each non-zero entry.
Implementations§
Source§impl<'a> CscMatrix<'a>
impl<'a> CscMatrix<'a>
Sourcepub fn from_column_iter_dense<I: IntoIterator<Item = f64>>(
nrows: usize,
ncols: usize,
iter: I,
) -> CscMatrix<'static>
pub fn from_column_iter_dense<I: IntoIterator<Item = f64>>( nrows: usize, ncols: usize, iter: I, ) -> CscMatrix<'static>
Creates a dense CSC matrix with its elements filled with the components provided by an iterator in column-major order.
Panics if iter
contains fewer than nrows * ncols
elements.
Sourcepub fn from_row_iter_dense<I: IntoIterator<Item = f64>>(
nrows: usize,
ncols: usize,
iter: I,
) -> CscMatrix<'static>
pub fn from_row_iter_dense<I: IntoIterator<Item = f64>>( nrows: usize, ncols: usize, iter: I, ) -> CscMatrix<'static>
Creates a dense CSC matrix with its elements filled with the components provided by an iterator in row-major order.
The order of elements in the slice must follow the usual mathematic writing, i.e., row-by-row.
Panics if iter
contains fewer than nrows * ncols
elements.
Sourcepub fn is_structurally_upper_tri(&self) -> bool
pub fn is_structurally_upper_tri(&self) -> bool
Returns true
if the matrix is structurally upper triangular.
A matrix is structurally upper triangular if, for each column, all elements below the diagonal, i.e. with their row number greater than their column number, are empty.
Note that an element with an explicit value of zero is not empty. To be empty an element must not be present in the sparse encoding of the matrix.
Sourcepub fn into_upper_tri(self) -> CscMatrix<'a>
pub fn into_upper_tri(self) -> CscMatrix<'a>
Extracts the upper triangular elements of the matrix.
This operation performs no allocations if the matrix is already structurally upper triangular or if it contains only owned data.
The returned matrix is guaranteed to be structurally upper triangular.