pub struct TensorCI2<T: Scalar + TTScalar> { /* private fields */ }Expand description
State object for the two-site Tensor Cross Interpolation algorithm.
Holds the current index sets (I, J), site tensors, and error statistics
produced by crossinterpolate2. After interpolation, call
to_tensor_train to extract the resulting
TensorTrain.
§Key methods
| Method | Purpose |
|---|---|
rank | Maximum bond dimension |
link_dims | Bond dimensions at each bond |
to_tensor_train | Extract the tensor train |
max_bond_error | Largest bond error from last sweep |
pivot_errors | Per-bond pivot errors from back-truncation |
You normally do not construct TensorCI2 directly; use
crossinterpolate2 instead.
Implementations§
Source§impl<T> TensorCI2<T>
impl<T> TensorCI2<T>
Sourcepub fn local_dims(&self) -> &[usize]
pub fn local_dims(&self) -> &[usize]
Get local dimensions
Sourcepub fn max_sample_value(&self) -> f64
pub fn max_sample_value(&self) -> f64
Get the maximum observed sample value seen so far
Sourcepub fn max_bond_error(&self) -> f64
pub fn max_bond_error(&self) -> f64
Get maximum bond error
Sourcepub fn pivot_errors(&self) -> &[f64]
pub fn pivot_errors(&self) -> &[f64]
Get pivot errors from back-truncation
Sourcepub fn is_site_tensors_available(&self) -> bool
pub fn is_site_tensors_available(&self) -> bool
Check if site tensors are available
Sourcepub fn site_tensor(&self, p: usize) -> &Tensor3<T>
pub fn site_tensor(&self, p: usize) -> &Tensor3<T>
Get site tensor at position p
Sourcepub fn to_tensor_train(&self) -> Result<TensorTrain<T>>
pub fn to_tensor_train(&self) -> Result<TensorTrain<T>>
Convert to TensorTrain
Sourcepub fn add_global_pivots(&mut self, pivots: &[MultiIndex]) -> Result<()>
pub fn add_global_pivots(&mut self, pivots: &[MultiIndex]) -> Result<()>
Add global pivots to the TCI
Sourcepub fn i_set(&self, p: usize) -> &[MultiIndex] ⓘ
pub fn i_set(&self, p: usize) -> &[MultiIndex] ⓘ
Get I-set at site p
Sourcepub fn j_set(&self, p: usize) -> &[MultiIndex] ⓘ
pub fn j_set(&self, p: usize) -> &[MultiIndex] ⓘ
Get J-set at site p
Sourcepub fn invalidate_site_tensors(&mut self)
pub fn invalidate_site_tensors(&mut self)
Invalidate all site tensors
Sourcepub fn flush_pivot_errors(&mut self)
pub fn flush_pivot_errors(&mut self)
Flush pivot errors (reset to empty)
Sourcepub fn sweep2site<F, B>(
&mut self,
f: &F,
batched_f: &Option<B>,
forward: bool,
options: &TCI2Options,
) -> Result<()>
pub fn sweep2site<F, B>( &mut self, f: &F, batched_f: &Option<B>, forward: bool, options: &TCI2Options, ) -> Result<()>
Perform one 2-site sweep.
This is a public wrapper around the internal update_pivots logic,
suitable for calling from C-API.
Sourcepub fn sweep1site<F>(
&mut self,
f: &F,
forward: bool,
rel_tol: f64,
abs_tol: f64,
max_bond_dim: usize,
update_tensors: bool,
) -> Result<()>where
F: Fn(&MultiIndex) -> T,
pub fn sweep1site<F>(
&mut self,
f: &F,
forward: bool,
rel_tol: f64,
abs_tol: f64,
max_bond_dim: usize,
update_tensors: bool,
) -> Result<()>where
F: Fn(&MultiIndex) -> T,
Perform a 1-site sweep, updating I/J sets and optionally site tensors.
This is used for cleanup after adding global pivots, and for computing canonical site tensors.
Port of Julia’s sweep1site! from tensorci2.jl.
Sourcepub fn fill_site_tensors<F>(&mut self, f: &F) -> Result<()>where
F: Fn(&MultiIndex) -> T,
pub fn fill_site_tensors<F>(&mut self, f: &F) -> Result<()>where
F: Fn(&MultiIndex) -> T,
Fill all site tensors using 1-site LU decomposition at each bond.
For each site b (except the last), computes the Pi matrix (Kronecker(I_b, d_b) × J_b) and the pivot matrix P (I_{b+1} × J_b), then solves P^T \ Pi^T to get the site tensor T_b = Pi * P^{-1}. The last site tensor is set by direct evaluation.
Port of Julia’s fillsitetensors! / setsitetensor!.
Sourcepub fn make_canonical<F>(
&mut self,
f: &F,
rel_tol: f64,
abs_tol: f64,
max_bond_dim: usize,
) -> Result<()>where
F: Fn(&MultiIndex) -> T,
pub fn make_canonical<F>(
&mut self,
f: &F,
rel_tol: f64,
abs_tol: f64,
max_bond_dim: usize,
) -> Result<()>where
F: Fn(&MultiIndex) -> T,
Make the TCI canonical by performing 3 one-site sweeps.
- Forward sweep (exact, no truncation)
- Backward sweep (with truncation)
- Forward sweep (with truncation + update tensors)
Port of Julia’s makecanonical!.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for TensorCI2<T>
impl<T> RefUnwindSafe for TensorCI2<T>where
T: RefUnwindSafe,
impl<T> Send for TensorCI2<T>
impl<T> Sync for TensorCI2<T>
impl<T> Unpin for TensorCI2<T>where
T: Unpin,
impl<T> UnsafeUnpin for TensorCI2<T>
impl<T> UnwindSafe for TensorCI2<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>,
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
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>
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