pub struct Tensor { /* private fields */ }Expand description
A dense multi-dimensional tensor.
Implementations§
Source§impl Tensor
impl Tensor
Sourcepub fn new(shape: Vec<usize>, data: Vec<f64>) -> SolverResult<Self>
pub fn new(shape: Vec<usize>, data: Vec<f64>) -> SolverResult<Self>
Creates a new tensor from shape and data.
Sourcepub fn get(&self, indices: &[usize]) -> SolverResult<f64>
pub fn get(&self, indices: &[usize]) -> SolverResult<f64>
Gets an element by multi-dimensional index.
Sourcepub fn set(&mut self, indices: &[usize], value: f64) -> SolverResult<()>
pub fn set(&mut self, indices: &[usize], value: f64) -> SolverResult<()>
Sets an element by multi-dimensional index.
Sourcepub fn unfold(&self, mode: usize) -> SolverResult<Matrix>
pub fn unfold(&self, mode: usize) -> SolverResult<Matrix>
Mode-n unfolding (matricization).
Rearranges the tensor into a matrix where mode n becomes the row
dimension and all other modes are collapsed into the column dimension.
Sourcepub fn fold(
matrix: &Matrix,
mode: usize,
shape: &[usize],
) -> SolverResult<Tensor>
pub fn fold( matrix: &Matrix, mode: usize, shape: &[usize], ) -> SolverResult<Tensor>
Folds a matrix back into a tensor (inverse of unfold).
Sourcepub fn frobenius_norm(&self) -> f64
pub fn frobenius_norm(&self) -> f64
Frobenius norm of the tensor.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Tensor
impl RefUnwindSafe for Tensor
impl Send for Tensor
impl Sync for Tensor
impl Unpin for Tensor
impl UnsafeUnpin for Tensor
impl UnwindSafe for Tensor
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