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\).


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