pub struct SparseKernelMatrix { /* private fields */ }Expand description
Sparse kernel matrix using Compressed Sparse Row (CSR) format
Stores only non-zero entries for efficient memory usage.
§Example
use tensorlogic_sklears_kernels::SparseKernelMatrix;
let mut matrix = SparseKernelMatrix::new(3);
matrix.set(0, 1, 0.8);
matrix.set(1, 2, 0.6);
assert_eq!(matrix.get(0, 1), Some(0.8));
assert_eq!(matrix.get(0, 2), None);
assert_eq!(matrix.nnz(), 2);Implementations§
Source§impl SparseKernelMatrix
impl SparseKernelMatrix
Source§impl SparseKernelMatrix
Advanced sparse matrix operations
impl SparseKernelMatrix
Advanced sparse matrix operations
Sourcepub fn spmv(&mut self, x: &[f64]) -> Result<Vec<f64>>
pub fn spmv(&mut self, x: &[f64]) -> Result<Vec<f64>>
Sparse matrix-vector multiplication: y = A * x
Sourcepub fn frobenius_norm(&self) -> f64
pub fn frobenius_norm(&self) -> f64
Frobenius norm of the sparse matrix
Sourcepub fn iter_nonzeros(&mut self) -> SparseMatrixIterator<'_> ⓘ
pub fn iter_nonzeros(&mut self) -> SparseMatrixIterator<'_> ⓘ
Iterator over non-zero entries (row, col, value)
Trait Implementations§
Source§impl Clone for SparseKernelMatrix
impl Clone for SparseKernelMatrix
Source§fn clone(&self) -> SparseKernelMatrix
fn clone(&self) -> SparseKernelMatrix
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 moreSource§impl Debug for SparseKernelMatrix
impl Debug for SparseKernelMatrix
Source§impl<'de> Deserialize<'de> for SparseKernelMatrix
impl<'de> Deserialize<'de> for SparseKernelMatrix
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 Freeze for SparseKernelMatrix
impl RefUnwindSafe for SparseKernelMatrix
impl Send for SparseKernelMatrix
impl Sync for SparseKernelMatrix
impl Unpin for SparseKernelMatrix
impl UnwindSafe for SparseKernelMatrix
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