pub struct SparseMatrix {
pub row_indices: Vec<usize>,
pub col_indices: Vec<usize>,
pub values: Vec<f64>,
pub shape: (usize, usize),
pub sparsity: f64,
}Expand description
Sparse matrix representation for missing data patterns
Fields§
§row_indices: Vec<usize>Row indices for non-missing values
col_indices: Vec<usize>Column indices for non-missing values
values: Vec<f64>Non-missing values
shape: (usize, usize)Matrix dimensions
sparsity: f64Sparsity ratio (fraction of missing values)
Implementations§
Source§impl SparseMatrix
impl SparseMatrix
Sourcepub fn from_dense(array: &Array2<f64>, missing_value: f64) -> Self
pub fn from_dense(array: &Array2<f64>, missing_value: f64) -> Self
Create a sparse matrix from a dense array
Sourcepub fn to_dense(&self, missing_value: f64) -> Array2<f64>
pub fn to_dense(&self, missing_value: f64) -> Array2<f64>
Convert back to dense array with missing values filled
Sourcepub fn get(&self, row: usize, col: usize) -> Option<f64>
pub fn get(&self, row: usize, col: usize) -> Option<f64>
Get non-missing value at specific coordinates
Sourcepub fn is_beneficial(&self) -> bool
pub fn is_beneficial(&self) -> bool
Check if the matrix is sparse enough to benefit from sparse representation
Sourcepub fn memory_savings(&self) -> f64
pub fn memory_savings(&self) -> f64
Calculate memory savings compared to dense representation
Trait Implementations§
Source§impl Clone for SparseMatrix
impl Clone for SparseMatrix
Source§fn clone(&self) -> SparseMatrix
fn clone(&self) -> SparseMatrix
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for SparseMatrix
impl RefUnwindSafe for SparseMatrix
impl Send for SparseMatrix
impl Sync for SparseMatrix
impl Unpin for SparseMatrix
impl UnwindSafe for SparseMatrix
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