pub struct VidalTensorTrain<T: TTScalar> { /* private fields */ }Expand description
Vidal Tensor Train representation
Stores the tensor train in Vidal canonical form where:
- Site tensors are stored separately from singular values
- Singular values are stored as diagonal matrices between sites
This form is useful for algorithms that need to apply local operations and maintain canonical form efficiently.
§Examples
use tensor4all_simplett::{TensorTrain, AbstractTensorTrain, VidalTensorTrain};
// Build a simple tensor train and convert to Vidal form.
let tt = TensorTrain::<f64>::constant(&[2, 3], 1.0);
let vidal = VidalTensorTrain::from_tensor_train(&tt).unwrap();
assert_eq!(vidal.len(), 2);
// Converting back preserves tensor train values.
let tt2 = vidal.to_tensor_train();
let val = tt2.evaluate(&[0, 1]).unwrap();
assert!((val - 1.0).abs() < 1e-12);
// The sum is also preserved: 1.0 * 2 * 3 = 6.0
assert!((tt2.sum() - 6.0).abs() < 1e-10);Implementations§
Source§impl<T: TTScalar + Scalar + Default> VidalTensorTrain<T>
impl<T: TTScalar + Scalar + Default> VidalTensorTrain<T>
Sourcepub fn from_tensor_train(tt: &TensorTrain<T>) -> Result<Self>where
T: ComplexFloat + BackendLinalgScalar + Copy + 'static,
<T as TensorScalar>::Real: TensorScalar + ToPrimitive,
pub fn from_tensor_train(tt: &TensorTrain<T>) -> Result<Self>where
T: ComplexFloat + BackendLinalgScalar + Copy + 'static,
<T as TensorScalar>::Real: TensorScalar + ToPrimitive,
Create a VidalTensorTrain from a regular TensorTrain
Sourcepub fn from_tensor_train_with_partition(
tt: &TensorTrain<T>,
partition: Range<usize>,
) -> Result<Self>where
T: ComplexFloat + BackendLinalgScalar + Copy + 'static,
<T as TensorScalar>::Real: TensorScalar + ToPrimitive,
pub fn from_tensor_train_with_partition(
tt: &TensorTrain<T>,
partition: Range<usize>,
) -> Result<Self>where
T: ComplexFloat + BackendLinalgScalar + Copy + 'static,
<T as TensorScalar>::Real: TensorScalar + ToPrimitive,
Create a VidalTensorTrain with a specific partition
Sourcepub fn new(
tensors: Vec<Tensor3<T>>,
singular_values: Vec<DiagMatrix>,
) -> Result<Self>
pub fn new( tensors: Vec<Tensor3<T>>, singular_values: Vec<DiagMatrix>, ) -> Result<Self>
Create a VidalTensorTrain with given tensors and singular values
Sourcepub fn singular_values(&self, i: usize) -> &DiagMatrix
pub fn singular_values(&self, i: usize) -> &DiagMatrix
Get the singular values between sites i and i+1
Sourcepub fn all_singular_values(&self) -> &[DiagMatrix] ⓘ
pub fn all_singular_values(&self) -> &[DiagMatrix] ⓘ
Get all singular value matrices
Sourcepub fn site_tensors_mut(&mut self) -> &mut [Tensor3<T>] ⓘ
pub fn site_tensors_mut(&mut self) -> &mut [Tensor3<T>] ⓘ
Get mutable access to site tensors
Sourcepub fn singular_values_mut(&mut self, i: usize) -> &mut DiagMatrix
pub fn singular_values_mut(&mut self, i: usize) -> &mut DiagMatrix
Get mutable access to singular values
Sourcepub fn to_tensor_train(&self) -> TensorTrain<T>
pub fn to_tensor_train(&self) -> TensorTrain<T>
Convert to a regular TensorTrain
Trait Implementations§
Source§impl<T: TTScalar + Scalar + Default> AbstractTensorTrain<T> for VidalTensorTrain<T>
impl<T: TTScalar + Scalar + Default> AbstractTensorTrain<T> for VidalTensorTrain<T>
Source§impl<T: Clone + TTScalar> Clone for VidalTensorTrain<T>
impl<T: Clone + TTScalar> Clone for VidalTensorTrain<T>
Source§fn clone(&self) -> VidalTensorTrain<T>
fn clone(&self) -> VidalTensorTrain<T>
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<T> Freeze for VidalTensorTrain<T>
impl<T> RefUnwindSafe for VidalTensorTrain<T>where
T: RefUnwindSafe,
impl<T> Send for VidalTensorTrain<T>
impl<T> Sync for VidalTensorTrain<T>
impl<T> Unpin for VidalTensorTrain<T>where
T: Unpin,
impl<T> UnsafeUnpin for VidalTensorTrain<T>
impl<T> UnwindSafe for VidalTensorTrain<T>where
T: UnwindSafe,
Blanket Implementations§
§impl<U> As for U
impl<U> As for U
§fn as_<T>(self) -> Twhere
T: CastFrom<U>,
fn as_<T>(self) -> Twhere
T: CastFrom<U>,
Casts
self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read moreSource§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,
§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> Twhere
Self: Distribution<T>,
§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> Twhere
Self: Distribution<T>,
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