pub struct SparseMatrixGpu {
pub n: usize,
pub nnz: usize,
pub row_ptr: Vec<usize>,
pub col_idx: Vec<usize>,
pub values: Vec<f64>,
}Expand description
Compressed Sparse Row (CSR) matrix stored in GPU-friendly layout.
Rows have entries in col_idx[row_ptr[i]..row_ptr[i+1]] with
corresponding values in values[row_ptr[i]..row_ptr[i+1]].
Fields§
§n: usizeNumber of rows (and columns — assumed square).
nnz: usizeNumber of non-zero entries.
row_ptr: Vec<usize>Row pointer array (length n+1).
col_idx: Vec<usize>Column index array (length nnz).
values: Vec<f64>Value array (length nnz).
Implementations§
Source§impl SparseMatrixGpu
impl SparseMatrixGpu
Sourcepub fn from_csr(
n: usize,
row_ptr: Vec<usize>,
col_idx: Vec<usize>,
values: Vec<f64>,
) -> Self
pub fn from_csr( n: usize, row_ptr: Vec<usize>, col_idx: Vec<usize>, values: Vec<f64>, ) -> Self
Sourcepub fn add_entry(&mut self, row: usize, col: usize, val: f64)
pub fn add_entry(&mut self, row: usize, col: usize, val: f64)
Append a single entry (row, col, val) in COO style.
This invalidates the CSR structure until finalize is called.
Sourcepub fn finalize(&mut self)
pub fn finalize(&mut self)
Convert count-per-row in row_ptr to proper CSR offsets.
Must be called after a series of add_entry calls
and before any SpMV or solver operations.
Sourcepub fn diagonal(&self) -> Vec<f64>
pub fn diagonal(&self) -> Vec<f64>
Extract the main diagonal as a dense vector.
Missing diagonal entries are filled with zero.
Sourcepub fn is_symmetric(&self) -> bool
pub fn is_symmetric(&self) -> bool
Check whether the matrix is structurally symmetric (A[i,j] ↔ A[j,i]).
Sourcepub fn frobenius_norm(&self) -> f64
pub fn frobenius_norm(&self) -> f64
Frobenius norm: √(∑ aᵢⱼ²).
Trait Implementations§
Source§impl Clone for SparseMatrixGpu
impl Clone for SparseMatrixGpu
Source§fn clone(&self) -> SparseMatrixGpu
fn clone(&self) -> SparseMatrixGpu
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for SparseMatrixGpu
impl RefUnwindSafe for SparseMatrixGpu
impl Send for SparseMatrixGpu
impl Sync for SparseMatrixGpu
impl Unpin for SparseMatrixGpu
impl UnsafeUnpin for SparseMatrixGpu
impl UnwindSafe for SparseMatrixGpu
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
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>
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>
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