pub struct TensorTrain {
pub cores: Vec<TtCore>,
pub shape: Vec<usize>,
}Expand description
A tensor in Tensor Train (TT / MPS) format.
A d-way tensor T of shape (n_0, …, n_{d-1}) is represented as a product of 3-way cores G_k of shape (r_{k-1}, n_k, r_k) where r_0 = r_d = 1.
Fields§
§cores: Vec<TtCore>The TT cores. Core k has shape (r_{k-1}, n_k, r_k).
Each core is stored as a flat Vecf64` in C-order.
shape: Vec<usize>Mode dimensions n_k.
Implementations§
Source§impl TensorTrain
impl TensorTrain
Sourcepub fn evaluate(&self, idx: &[usize]) -> f64
pub fn evaluate(&self, idx: &[usize]) -> f64
Evaluate the TT representation at a given multi-index.
Contracts the cores left-to-right: result = G_0[i_0] G_1[i_1] … G_{d-1}[i_{d-1}]. Each G_k[i_k] is the r_{k-1}×r_k slice.
Sourcepub fn from_dense(
tensor: &DenseTensor,
max_rank: usize,
tol: f64,
) -> TensorTrain
pub fn from_dense( tensor: &DenseTensor, max_rank: usize, tol: f64, ) -> TensorTrain
Convert a full dense tensor to Tensor Train format via left-to-right SVD rounding (TT-SVD algorithm).
max_rank caps each TT rank; tol is relative truncation tolerance.
Sourcepub fn frobenius_norm_approx(&self) -> f64
pub fn frobenius_norm_approx(&self) -> f64
Frobenius norm of the TT tensor (contract all cores).
Source§impl TensorTrain
impl TensorTrain
Sourcepub fn frobenius_norm(&self) -> f64
pub fn frobenius_norm(&self) -> f64
Compute the Frobenius norm via contraction of the full TT.
For small tensors only — reconstructs fully.
Sourcepub fn to_dense(&self) -> DenseTensor
pub fn to_dense(&self) -> DenseTensor
Reconstruct to a dense DenseTensor.
Sourcepub fn dot_product(&self, other: &TensorTrain) -> f64
pub fn dot_product(&self, other: &TensorTrain) -> f64
Dot product <TT_a, TT_b> between two TensorTrains with the same shape.
Uses the supercore contraction (quadratic in ranks).
Sourcepub fn scale(&self, s: f64) -> TensorTrain
pub fn scale(&self, s: f64) -> TensorTrain
Scale all cores by a scalar.
Trait Implementations§
Source§impl Clone for TensorTrain
impl Clone for TensorTrain
Source§fn clone(&self) -> TensorTrain
fn clone(&self) -> TensorTrain
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for TensorTrain
impl RefUnwindSafe for TensorTrain
impl Send for TensorTrain
impl Sync for TensorTrain
impl Unpin for TensorTrain
impl UnsafeUnpin for TensorTrain
impl UnwindSafe for TensorTrain
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<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.