pub struct CscMatrix<T> { /* private fields */ }
Expand description
Compressed Sparse Column (CSC) matrix
A sparse matrix format that compresses columns, making it efficient for column operations and matrix operations.
Implementations§
Source§impl<T> CscMatrix<T>
impl<T> CscMatrix<T>
Sourcepub fn new(
data: Vec<T>,
row_indices: Vec<usize>,
col_indices: Vec<usize>,
shape: (usize, usize),
) -> SparseResult<Self>
pub fn new( data: Vec<T>, row_indices: Vec<usize>, col_indices: Vec<usize>, shape: (usize, usize), ) -> SparseResult<Self>
Create a new CSC matrix from raw data
§Arguments
data
- Vector of non-zero valuesrow_indices
- Vector of row indices for each non-zero valuecol_indices
- Vector of column indices for each non-zero valueshape
- Tuple containing the matrix dimensions (rows, cols)
§Returns
- A new CSC matrix
§Examples
use scirs2_sparse::csc::CscMatrix;
// Create a 3x3 sparse matrix with 5 non-zero elements
let rows = vec![0, 0, 1, 2, 2];
let cols = vec![0, 2, 2, 0, 1];
let data = vec![1.0, 2.0, 3.0, 4.0, 5.0];
let shape = (3, 3);
let matrix = CscMatrix::new(data.clone(), rows, cols, shape).unwrap();
Sourcepub fn from_raw_csc(
data: Vec<T>,
indptr: Vec<usize>,
indices: Vec<usize>,
shape: (usize, usize),
) -> SparseResult<Self>
pub fn from_raw_csc( data: Vec<T>, indptr: Vec<usize>, indices: Vec<usize>, shape: (usize, usize), ) -> SparseResult<Self>
Sourcepub fn from_csc_data(
values: Vec<T>,
row_indices: Vec<usize>,
col_ptrs: Vec<usize>,
shape: (usize, usize),
) -> SparseResult<Self>
pub fn from_csc_data( values: Vec<T>, row_indices: Vec<usize>, col_ptrs: Vec<usize>, shape: (usize, usize), ) -> SparseResult<Self>
Create a new empty CSC matrix
§Arguments
shape
- Tuple containing the matrix dimensions (rows, cols)
§Returns
- A new empty CSC matrix Create a CSC matrix from CSC data (values, row indices, column pointers)
§Arguments
values
- Valuesrow_indices
- Row indicescol_ptrs
- Column pointersshape
- Shape of the matrix (rows, cols)
§Returns
- Result containing the CSC matrix
pub fn empty(shape: (usize, usize)) -> Self
Sourcepub fn row_indices(&self) -> &[usize]
pub fn row_indices(&self) -> &[usize]
Get row indices array
Auto Trait Implementations§
impl<T> Freeze for CscMatrix<T>
impl<T> RefUnwindSafe for CscMatrix<T>where
T: RefUnwindSafe,
impl<T> Send for CscMatrix<T>where
T: Send,
impl<T> Sync for CscMatrix<T>where
T: Sync,
impl<T> Unpin for CscMatrix<T>where
T: Unpin,
impl<T> UnwindSafe for CscMatrix<T>where
T: UnwindSafe,
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
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>
Converts
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>
Converts
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 more