Skip to main content

center_canonicalize

Function center_canonicalize 

Source
pub fn center_canonicalize<T: TTScalar + Scalar + Default>(
    tensors: &mut [Tensor3<T>],
    center: usize,
)
Expand description

Center canonicalize a vector of tensors in place

After this call, tensors at indices < center are left-orthogonal and tensors at indices > center are right-orthogonal. The overall tensor train represented by the slice is unchanged.

ยงExamples

use tensor4all_simplett::{TensorTrain, AbstractTensorTrain, tensor3_zeros, Tensor3Ops};
use tensor4all_simplett::canonical::center_canonicalize;

// Start with a simple 3-site constant TT.
let tt = TensorTrain::<f64>::constant(&[2, 3, 2], 1.0);
let mut tensors: Vec<_> = tt.site_tensors().to_vec();

// Canonicalize around site 1.
center_canonicalize(&mut tensors, 1);

// Rebuild TT from the canonicalized tensors; values are preserved.
let tt2 = TensorTrain::new(tensors).unwrap();
let val = tt2.evaluate(&[0, 1, 0]).unwrap();
assert!((val - 1.0).abs() < 1e-12);