Skip to main content

TensorCI2

Struct TensorCI2 

Source
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

MethodPurpose
rankMaximum bond dimension
link_dimsBond dimensions at each bond
to_tensor_trainExtract the tensor train
max_bond_errorLargest bond error from last sweep
pivot_errorsPer-bond pivot errors from back-truncation

You normally do not construct TensorCI2 directly; use crossinterpolate2 instead.

Implementations§

Source§

impl<T> TensorCI2<T>
where T: Scalar + TTScalar + Default + MatrixLuciScalar, DenseFaerLuKernel: PivotKernel<T>, LazyBlockRookKernel: PivotKernel<T>,

Source

pub fn new(local_dims: Vec<usize>) -> Result<Self>

Create a new empty TensorCI2

Source

pub fn len(&self) -> usize

Number of sites

Source

pub fn is_empty(&self) -> bool

Check if empty

Source

pub fn local_dims(&self) -> &[usize]

Get local dimensions

Source

pub fn rank(&self) -> usize

Get current rank (maximum bond dimension)

Get bond dimensions

Source

pub fn max_sample_value(&self) -> f64

Get the maximum observed sample value seen so far

Source

pub fn max_bond_error(&self) -> f64

Get maximum bond error

Source

pub fn pivot_errors(&self) -> &[f64]

Get pivot errors from back-truncation

Source

pub fn is_site_tensors_available(&self) -> bool

Check if site tensors are available

Source

pub fn site_tensor(&self, p: usize) -> &Tensor3<T>

Get site tensor at position p

Source

pub fn to_tensor_train(&self) -> Result<TensorTrain<T>>

Convert to TensorTrain

Source

pub fn add_global_pivots(&mut self, pivots: &[MultiIndex]) -> Result<()>

Add global pivots to the TCI

Source

pub fn i_set(&self, p: usize) -> &[MultiIndex]

Get I-set at site p

Source

pub fn j_set(&self, p: usize) -> &[MultiIndex]

Get J-set at site p

Source

pub fn invalidate_site_tensors(&mut self)

Invalidate all site tensors

Source

pub fn flush_pivot_errors(&mut self)

Flush pivot errors (reset to empty)

Source

pub fn sweep2site<F, B>( &mut self, f: &F, batched_f: &Option<B>, forward: bool, options: &TCI2Options, ) -> Result<()>
where F: Fn(&MultiIndex) -> T, B: Fn(&[MultiIndex]) -> Vec<T>,

Perform one 2-site sweep.

This is a public wrapper around the internal update_pivots logic, suitable for calling from C-API.

Source

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.

Source

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!.

Source

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.

  1. Forward sweep (exact, no truncation)
  2. Backward sweep (with truncation)
  3. Forward sweep (with truncation + update tensors)

Port of Julia’s makecanonical!.

Trait Implementations§

Source§

impl<T: Clone + Scalar + TTScalar> Clone for TensorCI2<T>

Source§

fn clone(&self) -> TensorCI2<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug + Scalar + TTScalar> Debug for TensorCI2<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<U> As for U

§

fn as_<T>(self) -> T
where 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 more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> ByRef<T> for T

§

fn by_ref(&self) -> &T

§

impl<T> ByRef<T> for T

§

fn by_ref(&self) -> &T

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> DistributionExt for T
where T: ?Sized,

§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

§

impl<T> DistributionExt for T
where T: ?Sized,

§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

§

impl<T> MaybeSend for T

§

impl<T> MaybeSendSync for T

§

impl<T> MaybeSync for T