pub struct CsfTensor<T> { /* private fields */ }Expand description
Compressed Sparse Fiber (CSF) tensor format
Stores a sparse tensor using a hierarchical compressed structure. The modes are ordered from coarsest (level 0) to finest (last level). Values are stored only at the leaf level.
Implementations§
Source§impl<T> CsfTensor<T>
impl<T> CsfTensor<T>
Sourcepub fn from_sparse_tensor(
tensor: &SparseTensor<T>,
mode_order: &[usize],
) -> SparseResult<Self>where
T: Sum,
pub fn from_sparse_tensor(
tensor: &SparseTensor<T>,
mode_order: &[usize],
) -> SparseResult<Self>where
T: Sum,
Create a CSF tensor from a COO-format SparseTensor.
The mode_order specifies which tensor mode corresponds to each CSF level.
For example, for a 3D tensor with mode_order = [0, 1, 2], level 0
compresses mode 0, level 1 compresses mode 1, and values are indexed by mode 2.
§Arguments
tensor- The sparse tensor in COO formatmode_order- Ordering of modes (must be a permutation of 0..ndim)
Sourcepub fn mode_order(&self) -> &[usize]
pub fn mode_order(&self) -> &[usize]
Get the mode ordering
Sourcepub fn fiber_pointers(&self, level: usize) -> Option<&[usize]>
pub fn fiber_pointers(&self, level: usize) -> Option<&[usize]>
Get the fiber pointers at a given level
Sourcepub fn fiber_indices(&self, level: usize) -> Option<&[usize]>
pub fn fiber_indices(&self, level: usize) -> Option<&[usize]>
Get the fiber indices at a given level
Sourcepub fn to_sparse_tensor(&self) -> SparseResult<SparseTensor<T>>where
T: Sum,
pub fn to_sparse_tensor(&self) -> SparseResult<SparseTensor<T>>where
T: Sum,
Convert back to a COO-format SparseTensor
Sourcepub fn contract_vector(
&self,
mode: usize,
vector: &[T],
) -> SparseResult<SparseTensor<T>>where
T: Sum,
pub fn contract_vector(
&self,
mode: usize,
vector: &[T],
) -> SparseResult<SparseTensor<T>>where
T: Sum,
Tensor contraction along a specified mode with a vector.
Computes the mode-n product with a vector: result = T x_n v The result is a tensor of one lower dimension.
§Arguments
mode- The tensor mode to contractvector- The vector to contract with (length =shape[mode])
Sourcepub fn mode_n_product(
&self,
mode: usize,
matrix: &CsrArray<T>,
) -> SparseResult<SparseTensor<T>>
pub fn mode_n_product( &self, mode: usize, matrix: &CsrArray<T>, ) -> SparseResult<SparseTensor<T>>
Mode-n product with a matrix: result = T x_n M
The result has the same number of dimensions as the input tensor,
but the size of mode n changes from shape[n] to M.nrows.
§Arguments
mode- The tensor mode to multiply alongmatrix- The matrix (nrows xshape[mode])
Sourcepub fn memory_usage(&self) -> usize
pub fn memory_usage(&self) -> usize
Get memory usage estimate (bytes)
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for CsfTensor<T>
impl<T> RefUnwindSafe for CsfTensor<T>where
T: RefUnwindSafe,
impl<T> Send for CsfTensor<T>where
T: Send,
impl<T> Sync for CsfTensor<T>where
T: Sync,
impl<T> Unpin for CsfTensor<T>where
T: Unpin,
impl<T> UnsafeUnpin for CsfTensor<T>
impl<T> UnwindSafe for CsfTensor<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