pub struct SparseMatrix<A> {
pub shape: (usize, usize),
pub format: SparseFormat,
pub coo_data: SparseMatrixCOO<A>,
pub csr_data: Option<SparseMatrixCSR<A>>,
pub csc_data: Option<SparseMatrixCSC<A>>,
pub metadata: HashMap<String, String>,
}
Expand description
Enhanced sparse matrix with multiple format support
Fields§
§shape: (usize, usize)
Matrix dimensions
format: SparseFormat
Current storage format
coo_data: SparseMatrixCOO<A>
COO format data (always maintained for compatibility)
csr_data: Option<SparseMatrixCSR<A>>
CSR format data (computed on demand)
csc_data: Option<SparseMatrixCSC<A>>
CSC format data (computed on demand)
metadata: HashMap<String, String>
Additional metadata
Implementations§
Source§impl<A: Clone> SparseMatrix<A>
impl<A: Clone> SparseMatrix<A>
Sourcepub fn from_coo(coo: SparseMatrixCOO<A>) -> Self
pub fn from_coo(coo: SparseMatrixCOO<A>) -> Self
Create a new sparse matrix from COO data
Sourcepub fn new(rows: usize, cols: usize) -> Self
pub fn new(rows: usize, cols: usize) -> Self
Create a new sparse matrix with specified dimensions
Sourcepub fn insert(&mut self, row: usize, col: usize, value: A)
pub fn insert(&mut self, row: usize, col: usize, value: A)
Add a value to the sparse matrix (always updates COO format)
Sourcepub fn to_csr(&mut self) -> Result<&SparseMatrixCSR<A>>
pub fn to_csr(&mut self) -> Result<&SparseMatrixCSR<A>>
Convert to CSR format (cached)
Sourcepub fn to_csc(&mut self) -> Result<&SparseMatrixCSC<A>>
pub fn to_csc(&mut self) -> Result<&SparseMatrixCSC<A>>
Convert to CSC format (cached)
Sourcepub fn memory_usage(&self) -> usize
pub fn memory_usage(&self) -> usize
Get memory usage estimate in bytes
Trait Implementations§
Source§impl<A: Clone> Clone for SparseMatrix<A>
impl<A: Clone> Clone for SparseMatrix<A>
Source§fn clone(&self) -> SparseMatrix<A>
fn clone(&self) -> SparseMatrix<A>
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<A: Debug> Debug for SparseMatrix<A>
impl<A: Debug> Debug for SparseMatrix<A>
Source§impl<'de, A> Deserialize<'de> for SparseMatrix<A>where
A: Deserialize<'de> + Default,
impl<'de, A> Deserialize<'de> for SparseMatrix<A>where
A: Deserialize<'de> + Default,
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<A> Freeze for SparseMatrix<A>
impl<A> RefUnwindSafe for SparseMatrix<A>where
A: RefUnwindSafe,
impl<A> Send for SparseMatrix<A>where
A: Send,
impl<A> Sync for SparseMatrix<A>where
A: Sync,
impl<A> Unpin for SparseMatrix<A>where
A: Unpin,
impl<A> UnwindSafe for SparseMatrix<A>where
A: 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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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