pub struct SparseCOO {
pub indices: Vec<Vec<usize>>,
pub values: Vec<f32>,
pub shape: Vec<usize>,
pub is_coalesced: bool,
}Expand description
Sparse tensor in COO (Coordinate) format.
Stores non-zero elements as a list of (index, value) pairs. Efficient for construction but less efficient for arithmetic.
Fields§
§indices: Vec<Vec<usize>>Row indices of non-zero elements
values: Vec<f32>Values of non-zero elements
shape: Vec<usize>Shape of the tensor
is_coalesced: boolWhether indices are sorted
Implementations§
Source§impl SparseCOO
impl SparseCOO
Sourcepub fn new(
indices: Vec<Vec<usize>>,
values: Vec<f32>,
shape: Vec<usize>,
) -> Self
pub fn new( indices: Vec<Vec<usize>>, values: Vec<f32>, shape: Vec<usize>, ) -> Self
Creates a new sparse COO tensor.
§Arguments
indices- List of index tuples, one per dimensionvalues- Non-zero valuesshape- Shape of the tensor
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SparseCOO
impl RefUnwindSafe for SparseCOO
impl Send for SparseCOO
impl Sync for SparseCOO
impl Unpin for SparseCOO
impl UnwindSafe for SparseCOO
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