pub struct GpuCooMatrix {
pub row_idx: Vec<usize>,
pub col_idx: Vec<usize>,
pub values: Vec<f64>,
pub n_rows: usize,
pub n_cols: usize,
}Expand description
Sparse matrix in coordinate (COO) format.
Entries can be pushed in arbitrary order; call to_csr or
to_csc to produce a compressed representation. Duplicate
(row, col) entries are summed during conversion.
Fields§
§row_idx: Vec<usize>Row indices of non-zero entries.
col_idx: Vec<usize>Column indices of non-zero entries.
values: Vec<f64>Values of non-zero entries.
n_rows: usizeNumber of rows.
n_cols: usizeNumber of columns.
Implementations§
Source§impl GpuCooMatrix
impl GpuCooMatrix
Sourcepub fn new(n_rows: usize, n_cols: usize) -> Self
pub fn new(n_rows: usize, n_cols: usize) -> Self
Create an empty COO matrix of the given shape.
Sourcepub fn push(&mut self, row: usize, col: usize, val: f64)
pub fn push(&mut self, row: usize, col: usize, val: f64)
Append a single triplet (row, col, val).
Panics in debug mode when indices are out of bounds.
Sourcepub fn from_triplets(
n_rows: usize,
n_cols: usize,
rows: &[usize],
cols: &[usize],
vals: &[f64],
) -> SparseResult<Self>
pub fn from_triplets( n_rows: usize, n_cols: usize, rows: &[usize], cols: &[usize], vals: &[f64], ) -> SparseResult<Self>
Construct a COO matrix from parallel triplet slices.
§Errors
Returns SparseError::InconsistentData when slice lengths differ, or
SparseError::IndexOutOfBounds when any index exceeds the declared
dimensions.
Sourcepub fn to_csr(&self) -> GpuCsrMatrix
pub fn to_csr(&self) -> GpuCsrMatrix
Convert to CSR by sorting triplets in row-major order and summing duplicates.
Sourcepub fn to_csc(&self) -> GpuCscMatrix
pub fn to_csc(&self) -> GpuCscMatrix
Convert to CSC by sorting triplets in column-major order and summing duplicates.
Trait Implementations§
Source§impl Clone for GpuCooMatrix
impl Clone for GpuCooMatrix
Source§fn clone(&self) -> GpuCooMatrix
fn clone(&self) -> GpuCooMatrix
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 GpuCooMatrix
impl RefUnwindSafe for GpuCooMatrix
impl Send for GpuCooMatrix
impl Sync for GpuCooMatrix
impl Unpin for GpuCooMatrix
impl UnsafeUnpin for GpuCooMatrix
impl UnwindSafe for GpuCooMatrix
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