SyTen
syten::MPS::Operator Class Reference

Matrix Product Operator. More...

#include <operator.h>

+ Inheritance diagram for syten::MPS::Operator:
+ Collaboration diagram for syten::MPS::Operator:

Public Member Functions

MemoryUsage::MemorySize allocSize () const
 allocSize() support More...
 
void dropUnmatched ()
 Sweeps left-to-right and right-to-left over the MPO and drops unmatched blocks. More...
 
void dropUnmatched (Index const site)
 Drop blocks in tensor on specified site which have no counterparts to the right/left. More...
 
bool isIdentity () const
 Returns true if *this is an identity operator. More...
 
bool isSingleSite () const
 Returns true if *this is a single-site operator. More...
 
 Operator (Index length)
 Standard ctor. More...
 
 Operator ()=default
 Default ctor to initialise from archives. More...
 
Tensor< 4 > & operator() (Index const site)
 Access tensor on specified site. More...
 
Tensor< 4 > const & operator() (Index const site) const
 Access tensor on specified site. More...
 
Operatoroperator*= (Operator const &other)
 Product of two operators, \( \hat O \; \hat T \), *this will be applied first to the state. More...
 
Operatoroperator*= (SDef const c)
 Product of a scalar and an operator, \( c \hat O \). More...
 
Operatoroperator+= (Operator const &other)
 Sum of two MPO, \( \hat O + \hat P \). More...
 
Operatoroperator-= (Operator const &other)
 Difference between two MPO, \( \hat O - \hat P \). More...
 
SRDef project (Sector const &sector)
 Projects the operator onto the given symmetry sector. More...
 
template<typename Archive >
void serialize (Archive &ar, const unsigned int in_version)
 Boost archiving. More...
 
Index singleSite () const
 Returns the site on which the single-site operator acts if isSingleSite() is true, otherwise returns 0. More...
 
SRDef truncate (TruncationType const &type=TruncationType::Default, bool verbose=false, SRDef const threshold=NAN, bool const nowarn=false)
 Truncates the operator by applying the specified truncation method on every site. More...
 
SRDef truncate_mult_to_left (Index const site, TruncationType const &type, SRDef const threshold)
 Applies the specified truncation method on site position and multiplies the remainder into the next site to the left (use during right-to-left sweep). More...
 
SRDef truncate_mult_to_right (Index const site, TruncationType const &type, SRDef const threshold)
 Applies the specified truncation method on site position and multiplies the remainder into the next site to the right (use during left-to-right sweep). More...
 
- Public Member Functions inherited from std::vector< Tensor< 4 > >
Tensor< 4 > assign (Tensor< 4 > ... args)
 
Tensor< 4 > at (Tensor< 4 > ... args)
 
Tensor< 4 > back (Tensor< 4 > ... args)
 
Tensor< 4 > begin (Tensor< 4 > ... args)
 
Tensor< 4 > capacity (Tensor< 4 > ... args)
 
Tensor< 4 > cbegin (Tensor< 4 > ... args)
 
Tensor< 4 > cend (Tensor< 4 > ... args)
 
Tensor< 4 > clear (Tensor< 4 > ... args)
 
Tensor< 4 > crbegin (Tensor< 4 > ... args)
 
Tensor< 4 > crend (Tensor< 4 > ... args)
 
Tensor< 4 > data (Tensor< 4 > ... args)
 
Tensor< 4 > emplace (Tensor< 4 > ... args)
 
Tensor< 4 > emplace_back (Tensor< 4 > ... args)
 
Tensor< 4 > empty (Tensor< 4 > ... args)
 
Tensor< 4 > end (Tensor< 4 > ... args)
 
Tensor< 4 > erase (Tensor< 4 > ... args)
 
Tensor< 4 > front (Tensor< 4 > ... args)
 
Tensor< 4 > get_allocator (Tensor< 4 > ... args)
 
Tensor< 4 > insert (Tensor< 4 > ... args)
 
Tensor< 4 > max_size (Tensor< 4 > ... args)
 
Tensor< 4 > operator= (Tensor< 4 > ... args)
 
Tensor< 4 > operator[] (Tensor< 4 > ... args)
 
Tensor< 4 > pop_back (Tensor< 4 > ... args)
 
Tensor< 4 > push_back (Tensor< 4 > ... args)
 
Tensor< 4 > rbegin (Tensor< 4 > ... args)
 
Tensor< 4 > rend (Tensor< 4 > ... args)
 
Tensor< 4 > reserve (Tensor< 4 > ... args)
 
Tensor< 4 > resize (Tensor< 4 > ... args)
 
Tensor< 4 > shrink_to_fit (Tensor< 4 > ... args)
 
Tensor< 4 > size (Tensor< 4 > ... args)
 
Tensor< 4 > swap (Tensor< 4 > ... args)
 
Tensor< 4 > vector (Tensor< 4 > ... args)
 
Tensor< 4 > ~vector (Tensor< 4 > ... args)
 

Public Attributes

int is_sso {-1}
 if > -1, denotes the site of the sso, otherwise, that the tensor is not a single-site operator; if -2 denotes that this is an identity and will take on the SSO-ness of the other operator during multiplication! More...
 
- Public Attributes inherited from std::vector< Tensor< 4 > >
Tensor< 4 > elements
 STL member. More...
 

Static Public Attributes

static constexpr Index dIdx {4}
 position of lower physical index in constituent tensors More...
 
static constexpr int dInt {4}
 position of lower physical index in constituent tensors, int for prod specs More...
 
static const std::array< Direction, 4 > dirs = {Direction::Inc, Direction::Out, Direction::Inc, Direction::Out}
 incoming/outgoing bases convention More...
 
static constexpr Index lIdx {2}
 position of left MPO index in constituent tensors More...
 
static constexpr int lInt {2}
 position of left MPO index in constituent tensors, int for prod specs More...
 
static constexpr Index rIdx {1}
 position of right MPO index in constituent tensors More...
 
static constexpr int rInt {1}
 position of right MPO index in constituent tensors, int for prod specs More...
 
static constexpr Index uIdx {3}
 position of upper physical index in constituent tensors More...
 
static constexpr int uInt {3}
 position of upper physical index in constituent tensors, int for prod specs More...
 
static constexpr unsigned int version = 2
 Bump this if the above changes. More...
 

Private Member Functions

SRDef truncate_impl (TruncationType const &type, Index max_sweeps=0, bool verbose=false, SRDef threshold=NAN, bool const nowarn=false)
 Actual implementation of the truncation, sweeps with the specified method until output dimensions don't change any longer if max_sweeps == 0 or until either max_sweeps have been done or the output dimension doesn't change any more. More...
 

Detailed Description

Matrix Product Operator.

Always kept entirely in RAM, as they tend not to be too big (even without symmetries at most just L³ (~ 2 GB for 512 sites) and typically 100 × L (~ 1 MB for 512 sites)).

Note on Order of Application

The order in which operators are applied to a state differ from the usual convention. That is:

State s; s *= op1; s *= op2;

first applies op1 and then op2 and is equivalent to

s = (s * op1); s = (s * op2);

which in turn is equivalent to

t = op1; t *= op2; s *= t;

and

s = s * (op1 * op2);

whereas in linear algebra one would expect the opposite ( \( \hat B \hat A \) first applying \( \hat A \), then \( \hat B \)).

If we tried the other convention, State *= Operator would either have to be removed or stick out and Operator =* State unfortunately doesn’t exist.

Constructor & Destructor Documentation

◆ Operator() [1/2]

syten::MPS::Operator::Operator ( Index  length)
explicit

Standard ctor.

Parameters
lengthsize of the MPO, i.e. number of sites

References std::vector< Tensor< 4 > >::push_back(), and std::vector< Tensor< 4 > >::reserve().

◆ Operator() [2/2]

syten::MPS::Operator::Operator ( )
default

Default ctor to initialise from archives.

Member Function Documentation

◆ allocSize()

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

allocSize() support

References syten::MemoryUsage::allocSize(), and std::vector< Tensor< 4 > >::size().

Referenced by serialize().

+ Here is the caller graph for this function:

◆ dropUnmatched() [1/2]

void syten::MPS::Operator::dropUnmatched ( )

Sweeps left-to-right and right-to-left over the MPO and drops unmatched blocks.

References std::vector< T >::push_back(), std::vector< T >::reserve(), and std::vector< Tensor< 4 > >::size().

Referenced by syten::MPS::Lattice::get(), operator*=(), operator+=(), operator-=(), syten::MPS::switch_sites(), truncate_mult_to_left(), and truncate_mult_to_right().

+ Here is the caller graph for this function:

◆ dropUnmatched() [2/2]

void syten::MPS::Operator::dropUnmatched ( Index const  site)

◆ isIdentity()

bool syten::MPS::Operator::isIdentity ( ) const

Returns true if *this is an identity operator.

References is_sso.

Referenced by operator*=(), operator+=(), operator-=(), and serialize().

+ Here is the caller graph for this function:

◆ isSingleSite()

bool syten::MPS::Operator::isSingleSite ( ) const

Returns true if *this is a single-site operator.

References is_sso.

Referenced by syten::MPS::dot(), operator*=(), operator+=(), operator-=(), and serialize().

+ Here is the caller graph for this function:

◆ operator()() [1/2]

Tensor< 4 > & syten::MPS::Operator::operator() ( Index const  site)

Access tensor on specified site.

◆ operator()() [2/2]

Tensor< 4 > const & syten::MPS::Operator::operator() ( Index const  site) const

Access tensor on specified site.

◆ operator*=() [1/2]

Operator & syten::MPS::Operator::operator*= ( Operator const &  other)

Product of two operators, \( \hat O \; \hat T \), *this will be applied first to the state.

References syten::compat_exact_equal(), dropUnmatched(), is_sso, isIdentity(), isSingleSite(), syten::MPS::mpo_cmp_prod(), singleSite(), std::vector< T >::size(), std::vector< Tensor< 4 > >::size(), and SYTEN_ASSERT.

◆ operator*=() [2/2]

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

◆ operator+=()

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

Sum of two MPO, \( \hat O + \hat P \).

Bad things happen if the two operators don’t transform in the same quantum number sector

References dIdx, dropUnmatched(), syten::expansion(), is_sso, isIdentity(), isSingleSite(), lIdx, rIdx, singleSite(), std::vector< T >::size(), std::vector< Tensor< 4 > >::size(), SYTEN_ASSERT_DEBUG, and uIdx.

◆ operator-=()

Operator & syten::MPS::Operator::operator-= ( Operator const &  other)

Difference between two MPO, \( \hat O - \hat P \).

Bad things happen if the two operators don’t transform in the same quantum number sector.

References dIdx, dropUnmatched(), syten::expansion(), is_sso, isIdentity(), isSingleSite(), lIdx, rIdx, singleSite(), std::vector< T >::size(), std::vector< Tensor< 4 > >::size(), SYTEN_ASSERT_DEBUG, and uIdx.

◆ project()

SRDef syten::MPS::Operator::project ( Sector const &  sector)

Projects the operator onto the given symmetry sector.

Removes all blocks on the first site whose LHS MPO index transforms outside of the specified sector and then truncates the MPO to remove all now-unmatched blocks.

References syten::Tensor< rank >::add(), std::move(), and truncate().

◆ serialize()

◆ singleSite()

Index syten::MPS::Operator::singleSite ( ) const

Returns the site on which the single-site operator acts if isSingleSite() is true, otherwise returns 0.

References is_sso.

Referenced by syten::MPS::dot(), operator*=(), operator+=(), operator-=(), and serialize().

+ Here is the caller graph for this function:

◆ truncate()

SRDef syten::MPS::Operator::truncate ( TruncationType const &  type = TruncationType::Default,
bool  verbose = false,
SRDef const  threshold = NAN,
bool const  nowarn = false 
)

Truncates the operator by applying the specified truncation method on every site.

References syten::EnvVars::default_tpo_truncate, and SYTEN_ASSERT_MSG.

Referenced by syten::create_dg_kinetic_term(), syten::create_interaction_term(), syten::create_ring_repulsion(), syten::create_rs_occ_operators(), syten::create_sq_inter_ring_kinetic_term(), syten::create_sq_intra_ring_kinetic_term(), syten::MPS::ParseOperator::dotqF(), syten::Pyten::init_mpl(), project(), syten::projector(), and syten::MPS::ParseOperator::truncateF().

+ Here is the caller graph for this function:

◆ truncate_impl()

SRDef syten::MPS::Operator::truncate_impl ( TruncationType const &  type,
Index  max_sweeps = 0,
bool  verbose = false,
SRDef  threshold = NAN,
bool const  nowarn = false 
)
private

Actual implementation of the truncation, sweeps with the specified method until output dimensions don't change any longer if max_sweeps == 0 or until either max_sweeps have been done or the output dimension doesn't change any more.

References std::isnan().

◆ truncate_mult_to_left()

SRDef syten::MPS::Operator::truncate_mult_to_left ( Index const  site,
TruncationType const &  type,
SRDef const  threshold 
)

Applies the specified truncation method on site position and multiplies the remainder into the next site to the left (use during right-to-left sweep).

References dropUnmatched().

◆ truncate_mult_to_right()

SRDef syten::MPS::Operator::truncate_mult_to_right ( Index const  site,
TruncationType const &  type,
SRDef const  threshold 
)

Applies the specified truncation method on site position and multiplies the remainder into the next site to the right (use during left-to-right sweep).

References dropUnmatched().

Member Data Documentation

◆ dIdx

◆ dInt

◆ dirs

const std::array< Direction, 4 > syten::MPS::Operator::dirs = {Direction::Inc, Direction::Out, Direction::Inc, Direction::Out}
static

incoming/outgoing bases convention

◆ is_sso

int syten::MPS::Operator::is_sso {-1}

if > -1, denotes the site of the sso, otherwise, that the tensor is not a single-site operator; if -2 denotes that this is an identity and will take on the SSO-ness of the other operator during multiplication!

Referenced by syten::MPS::Lattice::get(), isIdentity(), isSingleSite(), syten::MPS::Lattice::Lattice(), operator*=(), operator+=(), operator-=(), serialize(), and singleSite().

◆ lIdx

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

◆ lInt

◆ rIdx

constexpr Index syten::MPS::Operator::rIdx {1}
static

position of right MPO index in constituent tensors

Referenced by syten::MPS::apply_op_itrunc(), syten::MPS::apply_op_naive(), syten::MPS::apply_op_orthogonalise_fit(), syten::btt_operator_fbasis(), syten::MPS::coarse_grain(), syten::MPS::TEBD::connect_local_operators(), syten::MPS::TEBD::contract_local_sites(), syten::MPS::DMRG::Worker::energy(), syten::MPS::DMRG::LBOWorker::energyM(), syten::MPS::error_estimate_2svariance(), syten::MPS::DMRG::Worker::eval_observables(), syten::MPS::TDVP::Worker::evolveTwo(), syten::MPS::DMRG::Worker::expand_to_left(), syten::MPS::expand_to_left(), syten::MPS::expand_to_left_lbo(), syten::MPS::DMRG::Worker::expand_to_right(), syten::MPS::expand_to_right(), syten::MPS::expand_to_right_lbo(), syten::MPS::expand_to_top(), syten::MPS::expectation(), syten::MPS::SwappableTEBD::exponentiate_factor_mpo(), syten::MPS::SwappableTEBD::exponentiate_mpo_tensors(), syten::MPS::Lat::genParity(), syten::MPS::lboify_mpo_cmp(), syten::MPS::DMRG::LBOWorker::LBOWorker(), syten::MPS::OperatorApplicators::LWMR::LWMR(), syten::MPS::mpo_cmp_prod(), syten::MPS::mps_mpo_ctr_ctr(), syten::MPS::mps_mpo_mps_ctr_left(), syten::MPS::mps_mpo_mps_ctr_right(), syten::MPS::SwappableTEBD::multiply_factors(), operator+=(), operator-=(), syten::MPS::overlap(), syten::MPS::DMRG::LBOWorker::solveLocalM(), syten::MPS::DMRG::Worker::solveLocalTwoSite(), syten::MPS::DMRG::LBOWorker::solveLocalV(), syten::MPS::SwappableTEBD::split_rank6_into_mpos(), syten::MPS::switch_sites(), syten::MPS::TDVP::Worker::Worker(), and syten::MPS::DMRG::Worker::Worker().

◆ rInt

◆ uIdx

constexpr Index syten::MPS::Operator::uIdx {3}
static

◆ uInt

◆ version

constexpr unsigned int syten::MPS::Operator::version = 2
static

Bump this if the above changes.

Referenced by serialize().


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