pub struct SparseTensorCOO {
pub values: Vec<f32>,
pub rows: Vec<usize>,
pub cols: Vec<usize>,
pub shape: Vec<usize>,
pub nnz: usize,
}Expand description
Sparse tensor in COO (Coordinate) format
Fields§
§values: Vec<f32>Non-zero values
rows: Vec<usize>Row indices
cols: Vec<usize>Column indices
shape: Vec<usize>Shape of the tensor
nnz: usizeNumber of non-zero elements
Implementations§
Source§impl SparseTensorCOO
impl SparseTensorCOO
Sourcepub fn new(
values: Vec<f32>,
rows: Vec<usize>,
cols: Vec<usize>,
shape: Vec<usize>,
) -> Result<Self>
pub fn new( values: Vec<f32>, rows: Vec<usize>, cols: Vec<usize>, shape: Vec<usize>, ) -> Result<Self>
Create a new sparse tensor in COO format
Sourcepub fn from_dense(tensor: &Tensor, threshold: f32) -> Self
pub fn from_dense(tensor: &Tensor, threshold: f32) -> Self
Create sparse tensor from dense tensor (threshold-based)
Sourcepub fn spmm(&self, other: &SparseTensorCOO) -> Result<SparseTensorCOO>
pub fn spmm(&self, other: &SparseTensorCOO) -> Result<SparseTensorCOO>
Sparse matrix-matrix multiplication
Sourcepub fn add(&self, other: &SparseTensorCOO) -> Result<SparseTensorCOO>
pub fn add(&self, other: &SparseTensorCOO) -> Result<SparseTensorCOO>
Element-wise addition with another sparse tensor
Sourcepub fn transpose(&self) -> Result<SparseTensorCOO>
pub fn transpose(&self) -> Result<SparseTensorCOO>
Transpose the sparse matrix
Trait Implementations§
Source§impl Clone for SparseTensorCOO
impl Clone for SparseTensorCOO
Source§fn clone(&self) -> SparseTensorCOO
fn clone(&self) -> SparseTensorCOO
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 SparseTensorCOO
impl RefUnwindSafe for SparseTensorCOO
impl Send for SparseTensorCOO
impl Sync for SparseTensorCOO
impl Unpin for SparseTensorCOO
impl UnwindSafe for SparseTensorCOO
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