pub struct HybridMatrix<T> {
pub nrows: usize,
pub ncols: usize,
pub ell_width: usize,
pub ell_col: Vec<usize>,
pub ell_val: Vec<T>,
pub coo_row: Vec<usize>,
pub coo_col: Vec<usize>,
pub coo_val: Vec<T>,
}Expand description
ELL+COO hybrid sparse matrix format.
The matrix is split into two components:
- ELL part: rows with NNZ ≤
ell_widthare stored in ELLPACK format. - COO part: remaining non-zeros from rows exceeding
ell_widthare stored in coordinate (COO) format.
This hybrid strikes a balance between regular GPU memory access (ELL) and full generality (COO) for matrices with irregular degree distribution.
Fields§
§nrows: usizeNumber of rows.
ncols: usizeNumber of columns.
ell_width: usizeELL width (maximum NNZ per row in the ELL part).
ell_col: Vec<usize>ELL column indices: nrows * ell_width entries.
ell_val: Vec<T>ELL values: nrows * ell_width entries.
coo_row: Vec<usize>COO row indices (overflow entries).
coo_col: Vec<usize>COO column indices (overflow entries).
coo_val: Vec<T>COO values (overflow entries).
Implementations§
Source§impl<T> HybridMatrix<T>
impl<T> HybridMatrix<T>
Sourcepub fn from_csr(csr: &CsrMatrix<T>, ell_width: usize) -> SparseResult<Self>
pub fn from_csr(csr: &CsrMatrix<T>, ell_width: usize) -> SparseResult<Self>
Build from CSR using the given ELL width.
Rows with more than ell_width non-zeros contribute their first
ell_width entries to the ELL part and remaining entries to COO.
Sourcepub fn from_csr_auto(csr: &CsrMatrix<T>) -> SparseResult<Self>
pub fn from_csr_auto(csr: &CsrMatrix<T>) -> SparseResult<Self>
Auto-select ell_width as the median row NNZ (a common heuristic).
Sourcepub fn spmv(&self, x: &[T]) -> SparseResult<Vec<T>>
pub fn spmv(&self, x: &[T]) -> SparseResult<Vec<T>>
SpMV: y = self * x.
Sourcepub fn to_csr(&self) -> SparseResult<CsrMatrix<T>>where
T: PartialEq,
pub fn to_csr(&self) -> SparseResult<CsrMatrix<T>>where
T: PartialEq,
Convert to CSR.
Trait Implementations§
Source§impl<T: Clone> Clone for HybridMatrix<T>
impl<T: Clone> Clone for HybridMatrix<T>
Source§fn clone(&self) -> HybridMatrix<T>
fn clone(&self) -> HybridMatrix<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl<T> Freeze for HybridMatrix<T>
impl<T> RefUnwindSafe for HybridMatrix<T>where
T: RefUnwindSafe,
impl<T> Send for HybridMatrix<T>where
T: Send,
impl<T> Sync for HybridMatrix<T>where
T: Sync,
impl<T> Unpin for HybridMatrix<T>where
T: Unpin,
impl<T> UnsafeUnpin for HybridMatrix<T>
impl<T> UnwindSafe for HybridMatrix<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
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