SyTen
syten::MPS::State Class Reference

Matrix Product State with automatic caching. More...

#include <state.h>

+ Collaboration diagram for syten::MPS::State:

Public Types

enum  DropNorm { Yes, No }
 Whether or not to drop the norm on normalisation. More...
 
enum  DropUnmatched { DropUnmatched::lr, lR, Lr, LR }
 Whether to drop blocks not contained in the left (capital L) and/or right (capital R) blocks in rightnorm()/leftnorm() More...
 

Public Member Functions

MemoryUsage::MemorySize allocSize () const
 allocSize()/memory_size.h support. More...
 
void cache (Index site) const
 Ensures that the specified tensor is cached on disk. More...
 
void cache ()
 Caches all tensors to disk and sets pleaseCache to true. More...
 
void dropUnmatched (Index const site, bool const left=true, bool const right=true)
 Removes blocks on the specified site without corresponding partners on neighbouring sites. More...
 
void dropUnmatched (bool force_cache=false)
 Drops unmatched tensors on all sites. More...
 
SRDef leftnorm (Index const site, Truncation trunc=Truncation(), DropNorm const dropN=DropNorm::Yes, DropUnmatched const dropU=DropUnmatched::lr)
 Left-normalises the tensor \(X_i\) on the specified site as \(X_i^{\sigma_i} \to U^\sigma S V\) and multiplies the corresponding transformation \(SV\) in the next tensor on the right \(X_{i+1} \to SV X_{i+1}\). More...
 
SRDef leftnorm (Truncation const &trunc=Truncation(), DropNorm const dropN=DropNorm::Yes)
 Calls leftnorm() on all sites from left to right. More...
 
template<class Archive >
void load (Archive &ar, const unsigned int in_version)
 Boost serialisation: Loading. More...
 
void maybeCache (Index site) const
 Caches specified tensor if pleaseCache is true. More...
 
void maybeCache ()
 Caches all tensors if pleaseCache is true. More...
 
void normalise ()
 Normalises the state s.t. \(\langle \psi | \psi \rangle = 1 \). More...
 
Tensor< 3 > & operator() (Index site)
 Returns a reference to the tensor on that site. More...
 
Tensor< 3 > const & operator() (Index site) const
 Returns a const reference to the tensor on that site. More...
 
Tensor< 3 > const & operator() (Index site, int) const
 Returns a const reference to the tensor on that site. More...
 
Stateoperator*= (SDef const c)
 Multiplies the state by a scalar as \( |\psi \rangle \to c |\psi\rangle\). More...
 
Stateoperator*= (Operator const &op)
 Applies an operator to this state as \( |\psi\rangle \to \hat O |\psi\rangle\) using apply_op_naive(); prefer using apply_op_itrunc() if you want to truncate the state later. More...
 
Stateoperator+= (State const &other)
 Adds another state to this state as \( |\psi \rangle \to |\psi\rangle + |\textrm{other}\rangle\). More...
 
Stateoperator= (State const &a)=default
 Copy assignment operator, see State(State& a) More...
 
Stateoperator= (State &&a)=default
 Move assignment operator, see State(State&& a) More...
 
AsyncCached< Tensor< 3 > > & operator[] (Index site)
 Returns a reference to the cached object at site site. More...
 
AsyncCached< Tensor< 3 > > const & operator[] (Index site) const
 Returns a const reference to the cached object at site site. More...
 
void resize (Index const new_size)
 Resizes the MPS to the specified size. More...
 
SRDef rightnorm (Index const site, Truncation trunc=Truncation(), DropNorm const dropN=DropNorm::Yes, DropUnmatched const dropU=DropUnmatched::lr)
 Right-normalises the tensor \(X_i\) on the specified site as \(X_i^{\sigma_i} \to U S V^\sigma\) and multiplies the corresponding transformation \(US\) in the next tensor on the left \(X_{i-1} \to X_{i-1} U S\). More...
 
SRDef rightnorm (Truncation const &trunc=Truncation(), DropNorm const dropN=DropNorm::Yes)
 Calls rightnorm() on all sites from right to left. More...
 
template<class Archive >
void save (Archive &ar, const unsigned int) const
 Boost serialisation: Saving. More...
 
void setMaybeCache (bool pc)
 Sets pleaseCache to the argument and calls maybeCache(). More...
 
Index size () const
 Returns the number of sites in this MPS. More...
 
 State ()=default
 Default ctor needed for archiving. More...
 
 State (State const &a)=default
 Copy ctor. More...
 
 State (State &&a)=default
 Move ctor. More...
 
SRDef truncate (Truncation const &trunc=Truncation(), DropNorm const dropN=DropNorm::Yes)
 Truncates the state. More...
 
SRDef truncateKeepNorm (Truncation const &trunc=Truncation())
 Truncate the state preserving the norm, see truncate(). More...
 
SRDef truncateKN2Conv (Truncation const &trunc=Truncation())
 Calls truncateKeepNorm repeatedly until the bond dimension no longer changes. More...
 
SRDef truncateVariational (Truncation const &trunc=Truncation(), DropNorm const dropN=DropNorm::Yes)
 Truncates the state using a two-site variational fitting procedure. More...
 
void uncache (Index site) const
 Ensures that the specified tensor is loaded in RAM. More...
 
void uncache ()
 Loads all tensors into RAM and sets pleaseCache to false. More...
 
 ~State ()=default
 Dtor. More...
 

Public Attributes

History history
 History records of this state. More...
 
bool pleaseCache = false
 Whether to cache tensors if requested. More...
 

Static Public Attributes

static constexpr Index lIdx {2}
 The number of the left MPS index in the underlying tensors. More...
 
static constexpr int lInt {2}
 The number of the left MPS index in the underlying tensors, int for prod specs. More...
 
static constexpr Index rIdx {3}
 The number of the right MPS index in the underlying tensors. More...
 
static constexpr int rInt {3}
 The number of the right MPS index in the underlying tensors, int for prod specs. More...
 
static constexpr Index uIdx {1}
 The number of the physical (upper) index in the underlying tensors. More...
 
static constexpr int uInt {1}
 The number of the physical (upper) index in the underlying tensors, int for prod specs. More...
 
static const std::string uuid = "a970205a-d904-44d9-8adc-09dee648fd2d"
 uuid of the state class for serialisation More...
 
static constexpr unsigned int version = 3
 current version, bump if you change one of the data structures here More...
 

Private Attributes

std::vector< AsyncCached< Tensor< 3 > > > data
 Vector of possibly-cached tensors. More...
 

Detailed Description

Matrix Product State with automatic caching.

An object of this class corresponds to a specific MPS. HDD caching can be enabled/disabled dynamically, but only uncaching occurs transparently on access.

If the state is given by

\[ | \psi \rangle = \sum_{\sigma_1, \sigma_2, \ldots, \sigma_L} M_1^{\sigma_1} M_2^{\sigma_2} \cdots M_L^{\sigma_L} | \sigma_1 \sigma_2 \ldots \sigma_L \rangle \]

then the entries State(0)...State(L-1) correspond to the tensors \( M_1\) through \( M_L\).

Member Enumeration Documentation

◆ DropNorm

Whether or not to drop the norm on normalisation.

◆ DropUnmatched

Whether to drop blocks not contained in the left (capital L) and/or right (capital R) blocks in rightnorm()/leftnorm()

Enumerator
lr 

drop no blocks

Constructor & Destructor Documentation

◆ State() [1/3]

syten::MPS::State::State ( )
default

Default ctor needed for archiving.

◆ State() [2/3]

syten::MPS::State::State ( State const &  a)
default

Copy ctor.

Will uncache tensors on source object and cache tensors again as soon as possible both here and on source object.

◆ State() [3/3]

syten::MPS::State::State ( State &&  a)
default

Move ctor.

Steals files associated to cached tensors from source object.

◆ ~State()

syten::MPS::State::~State ( )
default

Dtor.

Destroys all tensors and also removes all files associated with currently-cached tensors.

Member Function Documentation

◆ allocSize()

MemoryUsage::MemorySize syten::MPS::State::allocSize ( ) const

allocSize()/memory_size.h support.

References syten::MemoryUsage::allocSize(), and data.

Referenced by load().

+ Here is the caller graph for this function:

◆ cache() [1/2]

void syten::MPS::State::cache ( Index  site) const

◆ cache() [2/2]

void syten::MPS::State::cache ( )

Caches all tensors to disk and sets pleaseCache to true.

References data, and pleaseCache.

Referenced by dropUnmatched(), and maybeCache().

+ Here is the caller graph for this function:

◆ dropUnmatched() [1/2]

void syten::MPS::State::dropUnmatched ( Index const  site,
bool const  left = true,
bool const  right = true 
)

Removes blocks on the specified site without corresponding partners on neighbouring sites.

The MPS is given as the contraction over all sites. As such, blocks without equally-transforming blocks on neighbouring sites can be safely discarded. As sometimes we want to keep such blocks, the boolean parameters allow to disable comparison with the left and right tensors by setting those to false.

Edge tensors on the first and last site are always at most compared to one neighbour.

Parameters
sitelocation of tensor to modify.
leftif true, compare to tensor on left (site-1).
rightif true, compare to tensor on right (site+1).

References syten::BasisMap::hasSymmetry(), std::move(), syten::Tensor< rank >::push_back(), syten::Tensor< rank >::reserve(), size(), and SYTEN_ASSERT_DEBUG.

Referenced by syten::MPS::apply_op_itrunc(), syten::MPS::apply_op_naive(), dropUnmatched(), syten::MPS::DMRG::Worker::expand_to_left(), syten::MPS::expand_to_left(), syten::MPS::DMRG::Worker::expand_to_right(), syten::MPS::expand_to_right(), syten::Pyten::init_mps(), leftnorm(), syten::MPS::TEBD::TpsWrapper::leftnorm_w_lambda(), load(), syten::MPS::TDVP::Worker::normL(), syten::MPS::TDVP::Worker::normR(), operator*=(), rightnorm(), syten::MPS::DMRG::Worker::sync(), truncate(), and syten::MPS::DMRG::Worker::Worker().

+ Here is the caller graph for this function:

◆ dropUnmatched() [2/2]

void syten::MPS::State::dropUnmatched ( bool  force_cache = false)

Drops unmatched tensors on all sites.

Two sweeps from left to right and right to left are necessary to actually remove all tensors. If force_cache is true, unneeded site tensors are stored to disk always.

References cache(), dropUnmatched(), pleaseCache, and size().

◆ leftnorm() [1/2]

SRDef syten::MPS::State::leftnorm ( Index const  site,
Truncation  trunc = Truncation(),
State::DropNorm const  dropN = DropNorm::Yes,
State::DropUnmatched const  dropU = DropUnmatched::lr 
)

Left-normalises the tensor \(X_i\) on the specified site as \(X_i^{\sigma_i} \to U^\sigma S V\) and multiplies the corresponding transformation \(SV\) in the next tensor on the right \(X_{i+1} \to SV X_{i+1}\).

After normalisation, the contraction of \(X\) with its hermitian conjugate over the physical and left indices should give an identity matrix:

.-→[+]--→     .--→
|   ↓      =  |
'-←[ ]--←     '--←
Parameters
sitelocation of tensor to normalise
truncTruncation specification
dropNif tensors on all sites but site are normalised on entry, ensure that the state is normalised on exit.
dropUwhether, and if so, compared to where, drop unmatched blocks
Returns
the error incurred during truncation, calculated as \( sqrt(2 - 2 \sqrt(1-D)) \) where \( D \) is the squared sum of discarded singular values (see thesis for details) or -1 if no states have been kept.

If trunc is a default syten::Truncation object, a QR decomposition rather than a SVD is used.

References syten::clear(), dropUnmatched(), lInt, syten::MPS::norm(), syten::Truncation::notTruncating(), syten::QR::qr(), rInt, syten::Truncation::scale(), syten::singValSqdToError(), syten::Tensor< rank >::size(), size(), syten::SVD::svd(), SYTEN_ZNORM_THRESHOLD, uInt, and syten::underThreshold().

Referenced by syten::allSiteEntropy(), syten::MPS::apply_op_orthogonalise_fit(), syten::entropyOneSite(), syten::entropyTwoSite(), syten::Pyten::init_mps(), leftnorm(), load(), syten::MPS::orthogonalise_variational(), syten::MPS::DMRG::Worker::sweepRight(), syten::MPS::DMRG::Worker::sweepRight2sVar(), syten::MPS::DMRG::Worker::sync(), truncate(), truncateVariational(), and syten::MPS::DMRG::Worker::Worker().

+ Here is the caller graph for this function:

◆ leftnorm() [2/2]

SRDef syten::MPS::State::leftnorm ( Truncation const &  trunc = Truncation(),
State::DropNorm const  dropN = DropNorm::Yes 
)

Calls leftnorm() on all sites from left to right.

Parameters
truncTruncation specification
dropNif true, drop the norm on the last site, the state is then normalised.
Returns
the sum of errors incurred during truncations or -1 if no states have been kept.

References leftnorm(), maybeCache(), and size().

◆ load()

◆ maybeCache() [1/2]

void syten::MPS::State::maybeCache ( Index  site) const

◆ maybeCache() [2/2]

void syten::MPS::State::maybeCache ( )

Caches all tensors if pleaseCache is true.

References cache(), and pleaseCache.

Referenced by syten::Pyten::init_mps(), leftnorm(), load(), operator*=(), operator+=(), rightnorm(), setMaybeCache(), and truncateVariational().

+ Here is the caller graph for this function:

◆ normalise()

void syten::MPS::State::normalise ( )

Normalises the state s.t. \(\langle \psi | \psi \rangle = 1 \).

References syten::MPS::norm().

Referenced by syten::Pyten::init_mps(), and load().

+ Here is the caller graph for this function:

◆ operator()() [1/3]

Tensor< 3 > & syten::MPS::State::operator() ( Index  site)

Returns a reference to the tensor on that site.

Loads the tensor from disk if necessary, but does not store it there again if the reference is destroyed. site is 0-indexed.

References data.

◆ operator()() [2/3]

Tensor< 3 > const & syten::MPS::State::operator() ( Index  site) const

Returns a const reference to the tensor on that site.

Loads the tensor from disk if necessary, but does not store it there again if the reference is destroyed. site is 0-indexed. Due to being a const reference, the data file is not deleted from disk, allowing for efficiently saving the tensor again.

References data.

◆ operator()() [3/3]

Tensor< 3 > const & syten::MPS::State::operator() ( Index  site,
int   
) const

Returns a const reference to the tensor on that site.

Loads the tensor from disk if necessary, but does not store it there again if the reference is destroyed. site is 0-indexed. Due to being a const reference, the data file is not deleted from disk, allowing for efficiently saving the tensor again.

References data.

◆ operator*=() [1/2]

State & syten::MPS::State::operator*= ( SDef const  c)

Multiplies the state by a scalar as \( |\psi \rangle \to c |\psi\rangle\).

Parameters
cmultiplicative factor
Returns
a reference to *this after the multiplication

Implemented via scaling of the first tensor.

References dropUnmatched(), and maybeCache().

Referenced by load().

+ Here is the caller graph for this function:

◆ operator*=() [2/2]

State & syten::MPS::State::operator*= ( Operator const &  op)

Applies an operator to this state as \( |\psi\rangle \to \hat O |\psi\rangle\) using apply_op_naive(); prefer using apply_op_itrunc() if you want to truncate the state later.

Parameters
opoperator to apply to the state.
Returns
a reference to *this

The order of multiplication is tricky. If the state tensor (A) is of size d·m·m and the operator tensor (W) of size w·w·d·d, then the left and right fuses (L, R) are of size wm·m·w.

There are five possible orderings (due to symmetry, exchange L/R to get the other 5):

  1. ((AW)L)R = m²·d·dw² + dwm·wm·wm + dwm·wm·wm = dw²m²(d + 2mw)
  2. ((AL)R)W = dm·m·wm² + w²md·m·w²m + w²m²·dw²·d = dw²m²(m + w²m + d)
  3. ((AL)W)R = dm·m·wm² + wm²·dw·dw + wmd·wm·wm = dw²m²(m + dw + wm)
  4. ((WL)A)R = d²w·w·wm² + w²md·md·m + dwm·wm·wm = dw²m²(dw + dm + wm)
  5. ((WL)R)A = d²w·w·wm² + wmd²·w·wm² + dw²m²·dm² = dw²m²(dw + dwm + dm²)

Of these, 3) is strictly better than 4) [m < dm]. 1) is strictly better than 2) [2w < w²+1]. Comparing 1) and 3), we find: d + 2w·m ? dw + (w+1)m with d << m always. If w << m, then (w+1) < 2w is enough for 3) to be better. If w ~ m, then we have d + 2m² ? m² + (d+1)m. Since d+1 < 2m, 3) wins.

This means that operator application to a state without truncation is of cost O(L dw²m² [(w+1)·m + dw]) for L sites.

References syten::MPS::apply_op_naive().

◆ operator+=()

State & syten::MPS::State::operator+= ( State const &  other)

Adds another state to this state as \( |\psi \rangle \to |\psi\rangle + |\textrm{other}\rangle\).

Parameters
otherthe added state
Returns
a handle to *this after addition.

MPS can be added using a tensor addition for each physical index, which is implemented below. The state can then usually be truncated very easily, but this is not done in the function itself.

References syten::expansion(), syten::genCombinator(), lInt, maybeCache(), rInt, size(), SYTEN_ASSERT, uInt, and syten::validateTensorEdge().

Referenced by load().

+ Here is the caller graph for this function:

◆ operator=() [1/2]

State& syten::MPS::State::operator= ( State const &  a)
default

Copy assignment operator, see State(State& a)

◆ operator=() [2/2]

State& syten::MPS::State::operator= ( State &&  a)
default

Move assignment operator, see State(State&& a)

◆ operator[]() [1/2]

AsyncCached< Tensor< 3 > > & syten::MPS::State::operator[] ( Index  site)

Returns a reference to the cached object at site site.

Does not load the tensor from disk but gives you access to the AsyncCached<Tensor<3> > object. site is 0-indexed.

References data.

◆ operator[]() [2/2]

AsyncCached< Tensor< 3 > > const & syten::MPS::State::operator[] ( Index  site) const

Returns a const reference to the cached object at site site.

Does not load the tensor from disk but gives you access to the AsyncCached<Tensor<3> > object. site is 0-indexed.

References data.

◆ resize()

void syten::MPS::State::resize ( Index const  new_size)

Resizes the MPS to the specified size.

References data.

Referenced by syten::MPS::conj(), syten::MPS::fine_grain(), syten::MPS::RandomState::generateCompleteState(), syten::MPS::RandomState::generateNearVacuumState(), syten::Pyten::init_mps(), syten::MPS::LBOState::operator State(), and syten::MPS::DMRG::PDMRG::saveState().

+ Here is the caller graph for this function:

◆ rightnorm() [1/2]

SRDef syten::MPS::State::rightnorm ( Index const  site,
Truncation  trunc = Truncation(),
State::DropNorm const  dropN = DropNorm::Yes,
State::DropUnmatched const  dropU = DropUnmatched::lr 
)

Right-normalises the tensor \(X_i\) on the specified site as \(X_i^{\sigma_i} \to U S V^\sigma\) and multiplies the corresponding transformation \(US\) in the next tensor on the left \(X_{i-1} \to X_{i-1} U S\).

After normalisation, the contraction of \(X\) with its hermitian conjugate over the physical and right indices should give an identity matrix.

→--[+]→-.    →--.
    ↓   |  =    |
←--[ ]←-'    ←--'
Parameters
sitelocation of tensor to normalise
truncTruncation specification
dropNif the leftmost tensor is normalised, ensure that the total state is normalised.
dropUwhether, and if so, compared to where, drop unmatched blocks
Returns
the error incurred during truncation, calculated as \( sqrt(2 - 2 \sqrt(1-D)) \) where \( D \) is the squared sum of discarded singular values (see thesis for details) or -1 if no states have been kept.

References syten::clear(), dropUnmatched(), lInt, syten::MPS::norm(), syten::Truncation::notTruncating(), syten::QR::qr(), rInt, syten::Truncation::scale(), syten::singValSqdToError(), syten::Tensor< rank >::size(), size(), syten::SVD::svd(), SYTEN_ZNORM_THRESHOLD, uInt, and syten::underThreshold().

Referenced by syten::allSiteEntropy(), syten::MPS::apply_op_itrunc(), syten::btt_operator_fbasis(), syten::entropyOneSite(), syten::entropyTwoSite(), syten::MPS::error_estimate_2svariance(), syten::MPS::fine_grain(), syten::Pyten::init_mps(), load(), syten::MPS::orthogonalise_variational(), syten::MPS::orthogonalise_variational_two_site(), rightnorm(), syten::MPS::DMRG::PDMRG::saveState(), syten::MPS::DMRG::Worker::sweepLeft(), syten::MPS::DMRG::Worker::sweepLeft2sVar(), syten::MPS::DMRG::Worker::sync(), truncate(), truncateVariational(), syten::MPS::TDVP::Worker::Worker(), and syten::MPS::DMRG::Worker::Worker().

+ Here is the caller graph for this function:

◆ rightnorm() [2/2]

SRDef syten::MPS::State::rightnorm ( Truncation const &  trunc = Truncation(),
State::DropNorm const  dropN = DropNorm::Yes 
)

Calls rightnorm() on all sites from right to left.

Parameters
truncTruncation specification
dropNif true, drop the norm on the first site, the state is then normalised.
Returns
the sum of errors incurred during truncations or -1 if no states have been kept.

References maybeCache(), rightnorm(), and size().

◆ save()

template<class Archive >
void syten::MPS::State::save ( Archive &  ar,
const unsigned  int 
) const
inline

Boost serialisation: Saving.

References history, size(), and uuid.

◆ setMaybeCache()

void syten::MPS::State::setMaybeCache ( bool  pc)

Sets pleaseCache to the argument and calls maybeCache().

Parameters
pcthe new value of pleaseCache

References maybeCache(), and pleaseCache.

Referenced by syten::btt_operator_fbasis(), syten::MPS::conj(), and syten::Pyten::init_mps().

+ Here is the caller graph for this function:

◆ size()

Index syten::MPS::State::size ( ) const

Returns the number of sites in this MPS.

References data.

Referenced by syten::MPS::addScaled(), syten::allSiteEntropy(), syten::MPS::apply_op_itrunc(), syten::MPS::apply_op_naive(), syten::MPS::apply_op_orthogonalise_fit(), syten::btt_operator_fbasis(), syten::MPS::TDVP::Worker::calcContrR(), syten::MPS::conj(), dropUnmatched(), syten::entropyOneSite(), syten::entropyTwoSite(), syten::MPS::error_estimate_2svariance(), syten::MPS::TDVP::Worker::evolveBond(), syten::MPS::TDVP::Worker::evolveSingle(), syten::MPS::TDVP::Worker::evolveSite(), syten::MPS::TDVP::Worker::evolveTwoSite(), syten::MPS::DMRG::Worker::expand_to_right(), syten::MPS::expand_to_right(), syten::MPS::expectation(), syten::MPS::fine_grain(), syten::Pyten::init_mps(), syten::MPS::LBOState::LBOState(), leftnorm(), syten::MPS::TEBD::TpsWrapper::leftnorm_w_lambda(), load(), operator+=(), syten::MPS::operator<<(), syten::MPS::orthogonalise_variational(), syten::MPS::orthogonalise_variational_two_site(), syten::MPS::overlap(), rightnorm(), save(), syten::MPS::DMRG::PDMRG::saveState(), syten::MPS::DMRG::Worker::solveLocal(), syten::MPS::DMRG::Worker::solveLocalTwoSite(), syten::MPS::DMRG::Worker::sweepLeft(), syten::MPS::DMRG::Worker::sweepLeft2sVar(), syten::MPS::DMRG::Worker::sweepLeftTwoSite(), syten::MPS::DMRG::Worker::sweepRight(), syten::MPS::DMRG::Worker::sweepRight2sVar(), syten::MPS::DMRG::Worker::sweepRightTwoSite(), truncateKN2Conv(), truncateVariational(), syten::MPS::TDVP::Worker::Worker(), and syten::MPS::DMRG::Worker::Worker().

+ Here is the caller graph for this function:

◆ truncate()

SRDef syten::MPS::State::truncate ( Truncation const &  trunc = Truncation(),
State::DropNorm const  dropN = DropNorm::Yes 
)

Truncates the state.

First drops all unmatched blocks, then left-normalises the state without truncation and finally right-normalises with the given truncation.

Parameters
truncTruncation specification
dropNif true, drop the norm on both normalisation sweep
Returns
the total incurred error during truncations

References dropUnmatched(), leftnorm(), and rightnorm().

Referenced by syten::MPS::RandomState::generateCompleteState(), syten::MPS::RandomState::generateSampledState(), syten::Pyten::init_mps(), load(), and truncateKeepNorm().

+ Here is the caller graph for this function:

◆ truncateKeepNorm()

SRDef syten::MPS::State::truncateKeepNorm ( Truncation const &  trunc = Truncation())

Truncate the state preserving the norm, see truncate().

Parameters
truncTruncation specification
Returns
the total incurred error during truncations

References truncate().

Referenced by syten::MPS::SwappableTEBD::exponentiate_and_multiply(), syten::Pyten::init_mps(), load(), and truncateKN2Conv().

+ Here is the caller graph for this function:

◆ truncateKN2Conv()

SRDef syten::MPS::State::truncateKN2Conv ( Truncation const &  trunc = Truncation())

Calls truncateKeepNorm repeatedly until the bond dimension no longer changes.

References std::vector< T >::back(), syten::logGd(), std::vector< T >::push_back(), size(), and truncateKeepNorm().

Referenced by load().

+ Here is the caller graph for this function:

◆ truncateVariational()

SRDef syten::MPS::State::truncateVariational ( Truncation const &  trunc = Truncation(),
State::DropNorm const  dropN = DropNorm::Yes 
)

◆ uncache() [1/2]

void syten::MPS::State::uncache ( Index  site) const

Ensures that the specified tensor is loaded in RAM.

References data.

Referenced by syten::MPS::DMRG::Worker::sweepLeft(), syten::MPS::DMRG::Worker::sweepLeft2sVar(), syten::MPS::DMRG::Worker::sweepRight(), and syten::MPS::DMRG::Worker::sweepRight2sVar().

+ Here is the caller graph for this function:

◆ uncache() [2/2]

void syten::MPS::State::uncache ( )

Loads all tensors into RAM and sets pleaseCache to false.

References data, and pleaseCache.

Member Data Documentation

◆ data

std::vector<AsyncCached<Tensor<3> > > syten::MPS::State::data
private

Vector of possibly-cached tensors.

Referenced by allocSize(), cache(), load(), maybeCache(), operator()(), operator[](), resize(), size(), and uncache().

◆ history

◆ lIdx

constexpr Index syten::MPS::State::lIdx {2}
static

The number of the left MPS index in the underlying tensors.

Referenced by syten::allSiteEntropy(), syten::MPS::apply_op_orthogonalise_fit(), syten::btt_operator_fbasis(), syten::MPS::build_ctr_overlap_left(), syten::MPS::build_ctr_overlap_right(), syten::MPS::build_single_site_environment(), syten::MPS::build_two_site_environment(), syten::MPS::DMRG::Worker::calcContrLeft(), syten::MPS::DMRG::Worker::calcContrRight(), syten::do_apply_op(), syten::MPS::DMRG::Worker::energy(), syten::entropyOneSite(), syten::entropyTwoSite(), syten::MPS::error_estimate_2svariance(), syten::MPS::DMRG::Worker::eval_observables(), syten::MPS::DMRG::Worker::expand_to_left(), syten::MPS::expand_to_left(), syten::MPS::DMRG::Worker::expand_to_right(), syten::MPS::expand_to_right(), syten::MPS::expectation(), syten::MPS::fine_grain(), syten::MPS::RandomState::generateSampledProductState(), syten::Pyten::init_mps(), syten::MPS::left_complement(), syten::MPS::TEBD::TpsWrapper::leftnorm_w_lambda(), syten::MPS::mps_mpo_ctr_ctr(), syten::MPS::mps_mpo_mps_ctr_left(), syten::MPS::mps_mpo_mps_ctr_right(), syten::MPS::TDVP::Worker::normR(), syten::MPS::OperatorApplicators::LWMR::operator()(), syten::MPS::orthogonalise_variational(), syten::MPS::orthogonalise_variational_two_site(), syten::MPS::right_complement(), syten::MPS::DMRG::Worker::solveLocal(), syten::MPS::DMRG::Worker::solveLocalTwoSite(), syten::MPS::split_rank_4_into_mps_rnorm(), syten::MPS::DMRG::Worker::sweepLeft(), syten::MPS::DMRG::Worker::sweepLeft2sVar(), syten::MPS::DMRG::Worker::sweepLeftTwoSite(), syten::MPS::DMRG::Worker::sweepRightTwoSite(), syten::MPS::DMRG::Worker::sync(), syten::MPS::TDVP::Worker::Worker(), and syten::MPS::DMRG::Worker::Worker().

◆ lInt

◆ pleaseCache

◆ rIdx

constexpr Index syten::MPS::State::rIdx {3}
static

The number of the right MPS index in the underlying tensors.

Referenced by syten::allSiteEntropy(), syten::MPS::apply_op_itrunc(), syten::MPS::apply_op_naive(), syten::MPS::apply_op_orthogonalise_fit(), syten::btt_operator_fbasis(), syten::MPS::build_ctr_overlap_left(), syten::MPS::build_ctr_overlap_right(), syten::MPS::build_single_site_environment(), syten::MPS::build_two_site_environment(), syten::MPS::DMRG::Worker::calcContrLeft(), syten::MPS::DMRG::Worker::calcContrRight(), syten::MPS::DMRG::Worker::energy(), syten::entropyOneSite(), syten::entropyTwoSite(), syten::MPS::error_estimate_2svariance(), syten::MPS::DMRG::Worker::eval_observables(), syten::MPS::DMRG::Worker::expand_to_left(), syten::MPS::expand_to_left(), syten::MPS::DMRG::Worker::expand_to_right(), syten::MPS::expand_to_right(), syten::MPS::expectation(), syten::MPS::fine_grain(), syten::Pyten::init_mps(), syten::MPS::left_complement(), syten::MPS::TEBD::TpsWrapper::leftnorm_w_lambda(), syten::MPS::mps_mpo_ctr_ctr(), syten::MPS::mps_mpo_mps_ctr_left(), syten::MPS::mps_mpo_mps_ctr_right(), syten::MPS::TDVP::Worker::normL(), syten::MPS::OperatorApplicators::LWMR::operator()(), syten::MPS::orthogonalise_variational(), syten::MPS::orthogonalise_variational_two_site(), syten::MPS::right_complement(), syten::MPS::DMRG::Worker::solveLocal(), syten::MPS::DMRG::Worker::solveLocalTwoSite(), syten::MPS::split_rank_4_into_mps_rnorm(), syten::MPS::DMRG::Worker::sweepLeftTwoSite(), syten::MPS::DMRG::Worker::sweepRight(), syten::MPS::DMRG::Worker::sweepRight2sVar(), syten::MPS::DMRG::Worker::sweepRightTwoSite(), syten::MPS::DMRG::Worker::sync(), syten::MPS::TDVP::Worker::Worker(), and syten::MPS::DMRG::Worker::Worker().

◆ rInt

◆ uIdx

◆ uInt

◆ uuid

const std::string syten::MPS::State::uuid = "a970205a-d904-44d9-8adc-09dee648fd2d"
static

uuid of the state class for serialisation

Referenced by load(), and save().

◆ version

constexpr unsigned int syten::MPS::State::version = 3
static

current version, bump if you change one of the data structures here

Referenced by load().


The documentation for this class was generated from the following files: