SyTen
syten::BTT::State Class Reference

A binary tree tensor network state. More...

#include <btt_state.h>

+ Inheritance diagram for syten::BTT::State:
+ Collaboration diagram for syten::BTT::State:

Public Types

enum  DropNorm { Yes, No }
 Whether or not to drop the norm on normalisation. More...
 
enum  DropUnmatched { Yes, No }
 Whether to drop blocks not contained in the neighbouring nodes. More...
 
- Public Types inherited from syten::BinaryTree::Tree< Cached< Tensor< 4 > > >
typedef BinaryTree::Node< ValueNode
 Type of nodes. More...
 
typedef NodePtr
 Type of pointers to nodes. More...
 
typedef Cached< Tensor< 4 > > Value
 Type of values contained in the tree. More...
 

Public Member Functions

Tensor< 4 > & operator() (std::string const &coordinate)
 Returns a reference to the tensor at the specified coordinate. More...
 
Tensor< 4 > const & operator() (std::string const &coordinate) const
 Returns a const-reference to the tensor at the specified coordinate. More...
 
Stateoperator= (State const &other)=default
 Copy assignment operator. More...
 
Stateoperator= (State &&other)=default
 Move assignment operator. More...
 
SRDef rnorm (DropNorm const dropN=DropNorm::Yes, DropUnmatched const dropU=DropUnmatched::Yes)
 Root-normalises the entire tree. More...
 
 State ()=default
 Default ctor. More...
 
 State (State const &other)=default
 Copy ctor. More...
 
 State (State &&other)=default
 Move ctor. More...
 
Dropping of tensor blocks
void drop_all ()
 Drops all blocks on all tensors, i.e. sets the state to zero. More...
 
SRDef drop_unmatched (Ptr ptr, DropUnmatched const dropU)
 Compares the node ptr against all neighbours and drops unmatched blocks if dropU is DropUnmatched::Yes. More...
 
SRDef drop_unmatched_a (Ptr ptr, DropUnmatched const dropU)
 Compares the node ptr against its A-child if it exists and drops unmatched blocks in ptr if dropU is DropUnmatched::Yes. More...
 
SRDef drop_unmatched_b (Ptr ptr, DropUnmatched const dropU)
 Compares the node ptr against its B-child if it exists and drops unmatched blocks in ptr if dropU is DropUnmatched::Yes. More...
 
SRDef drop_unmatched_r (Ptr ptr, DropUnmatched const dropU)
 Compares the node ptr against its parent if it exists and drops unmatched blocks in ptr if dropU is DropUnmatched::Yes. More...
 
SRDef drop_unmatched (Ptr ptr, BinaryTree::NodeType const type, DropUnmatched const dropU)
 Compares the node ptr against the specified neighbour and drops unmatched blocks in ptr if dropU is DropUnmatched::Yes. More...
 
SRDef drop_unmatched_rec (Ptr ptr)
 Recursive helper for drop_unmatched() More...
 
SRDef drop_unmatched ()
 Drops unmatched blocks on all tensors. More...
 
Normalisation of nodes in a specific direction
SRDef rnorm_node (Ptr ptr, Truncation trunc=Truncation(), DropNorm const dropN=DropNorm::Yes, DropUnmatched const dropU=DropUnmatched::Yes)
 Root-normalise the node pointed to by ptr. More...
 
SRDef anorm_node (Ptr ptr, Truncation trunc=Truncation(), DropNorm const dropN=DropNorm::Yes, DropUnmatched const dropU=DropUnmatched::Yes)
 A-normalises the node pointed to by ptr, i.e. it gives an identity when contracted with the "A"-legs left open. More...
 
SRDef bnorm_node (Ptr ptr, Truncation trunc=Truncation(), DropNorm const dropN=DropNorm::Yes, DropUnmatched const dropU=DropUnmatched::Yes)
 B-normalises the node pointed to by ptr, i.e. it gives an identity when contracted with the "B"-legs left open. More...
 
Truncation of the state
SRDef truncate_rec (Ptr ptr, Truncation const &trunc, DropNorm const dropN)
 Recursive helper for truncation. More...
 
SRDef truncate (Truncation const &trunc=Truncation(), DropNorm const dropN=DropNorm::Yes)
 Truncates the state. More...
 
SRDef truncateKeepNorm (Truncation const &trunc=Truncation())
 Truncates the state, keeping the norm. More...
 
SRDef truncateKN2Conv (Truncation const &trunc=Truncation())
 Truncates the state repeatedly until the bond dimension no longer changes. More...
 
void normalise ()
 normalise the state to 1. More...
 
Caching of tensors
bool cache (const Ptr ptr) const
 Caches the tensor at the specified node. More...
 
bool uncache (const Ptr ptr) const
 Un-caches the tensor at the specified node. More...
 
bool maybeCache (const Ptr ptr) const
 Caches the tensor on the specified node if pleaseCache is true. More...
 
void cache ()
 Caches all tensors. More...
 
void uncache ()
 Uncaches all tensors. More...
 
void maybeCache ()
 Caches all tensors if pleaseCache is true. More...
 
void setMaybeCache (bool pc)
 Sets pleaseCache to the argument and calls maybeCache(). More...
 
Boost serialisation
template<typename Archive >
void save_node (Archive &ar, Ptr ptr, const unsigned int v)
 Boost serialisation helper. More...
 
template<typename Archive >
void save (Archive &ar, const unsigned int in_version) const
 Boost serialisation. More...
 
template<typename Archive >
void load_node (Archive &ar, Ptr ptr, const unsigned int v)
 Boost deserialisation helper. More...
 
template<typename Archive >
void load (Archive &ar, const unsigned int in_version)
 Boost deserialisation. More...
 
Addition of two states
void state_add_rec (Ptr tptr, const Ptr optr, bool cachet, bool cacheo)
 Recursive helper for state addition. More...
 
Stateoperator+= (State const &other)
 Adds the argument to *this More...
 
- Public Member Functions inherited from syten::BinaryTree::Tree< Cached< Tensor< 4 > > >
MemoryUsage::MemorySize allocSize () const
 Returns the total size in bytes allocated for this tree. More...
 
Treeoperator= (Tree const &other)
 Copy assignment operator. More...
 
Treeoperator= (Tree &&other)
 Move assignment operator. More...
 
void serialize (Archive &ar, unsigned int const in_version)
 Boost serialisation, recursive as usual. More...
 
 Tree ()
 Default ctor with empty root node. More...
 
 Tree (Args... args)
 Standard ctor. More...
 
 Tree (Tree &&other)
 Move ctor. More...
 
 Tree (Tree const &other)
 Copy ctor (deep-copies) More...
 
 ~Tree ()
 Dtor. More...
 
Nodego_down (Node *ptr, Index steps) const
 Returns the steps-th child of *ptr, provided that there are no branches. More...
 
Nodeoperator[] (std::string const &coordinate) const
 Returns a pointer to the node specified by coordinate. More...
 
Ptr operator[] (std::array< Index, 2 > const &coordinate) const
 Returns a pointer to the node specified by the two-index coordinate. More...
 
Ptr operator[] (std::initializer_list< Index > list) const
 Returns a pointer to the node specified by the two-index coordinate. More...
 
Ptr last_fork (Ptr leaf) const
 Returns a pointer to the last fork on the way to the specified node. More...
 
Ptr first_nonfork (Ptr leaf) const
 Returns a pointer to the first non-forking node in the non-forking branch that leads to leaf (i.e. one step further towards leaf than last_fork(leaf) More...
 
Ptr leaf (Index const which) const
 Returns a pointer to the which-th leaf of the tree. More...
 
std::result_of< Func(Ptr)>::type visit_bottom (Func &&f, typename std::result_of< Func(Ptr)>::type initial, IterFirst const dir=IterFirst::Left)
 Visits each node, starting at the left or right bottommost node. More...
 
std::result_of< Func(const Ptr)>::type visit_bottom (Func &&f, typename std::result_of< Func(const Ptr)>::type initial, IterFirst const dir=IterFirst::Left) const
 Visits each node, starting at the left or right bottommost node for const trees. More...
 
void visit_bottom (Func &&f, IterFirst const dir=IterFirst::Left)
 Visits each node, starting at the left or right bottommost node. More...
 
void visit_bottom (Func &&f, IterFirst const dir=IterFirst::Left) const
 Visits each node, starting at the left or right bottommost node for const trees. More...
 
std::result_of< Func(Value &)>::type visit_bottom (Func &&f, typename std::result_of< Func(Value &)>::type initial, IterFirst const dir=IterFirst::Left)
 Visits each node, starting at the left or right bottommost node. More...
 
std::result_of< Func(Value const &)>::type visit_bottom (Func &&f, typename std::result_of< Func(Value const &)>::type initial, IterFirst const dir=IterFirst::Left) const
 Visits each node, starting at the left or right bottommost node for const trees. More...
 
std::result_of< Func(Ptr)>::type visit_top (Func &&f, typename std::result_of< Func(Ptr)>::type initial, IterFirst const dir=IterFirst::Left)
 Visits each node, starting at the root node. More...
 
std::result_of< Func(const Ptr)>::type visit_top (Func &&f, typename std::result_of< Func(Ptr)>::type initial, IterFirst const dir=IterFirst::Left) const
 Visits each node, starting at the root node for const trees. More...
 
void visit_top (Func &&f, IterFirst const dir=IterFirst::Left)
 Visits each node, starting at the root node. More...
 
void visit_top (Func &&f, IterFirst const dir=IterFirst::Left) const
 Visits each node, starting at the root node, for const trees. More...
 
std::result_of< Func(Value const &)>::type visit_top (Func &&f, typename std::result_of< Func(Value &)>::type initial, IterFirst const dir=IterFirst::Left)
 Visits each node, starting at the root node. More...
 
std::result_of< Func(Value const &)>::type visit_top (Func &&f, typename std::result_of< Func(Value const &)>::type initial, IterFirst const dir=IterFirst::Left) const
 Visits each node, starting at the root node, for const trees. More...
 

Public Attributes

History history = History()
 History records of this state. More...
 
bool pleaseCache = false
 If true, cache tensors on request. More...
 
- Public Attributes inherited from syten::BinaryTree::Tree< Cached< Tensor< 4 > > >
Noder
 Root node of the tree. More...
 

Static Public Attributes

static const std::array< Direction, 4 > dirs
 Incoming/Outgoing bases convention. More...
 
static const std::string uuid = "791e0aa6-0ef8-4957-998f-7ca7fc618645"
 UUID of a BTT::State. More...
 
static constexpr unsigned int version = 2
 current version, bump if you change one of the data structures here More...
 
Index numbering
static constexpr Index pIdx = 1
 Physical tensor index. More...
 
static constexpr Index rIdx = 2
 Root-directed tensor index. More...
 
static constexpr Index aIdx = 3
 Index of left subtree ("A") More...
 
static constexpr Index bIdx = 4
 Index of right subtree ("B") More...
 
static constexpr int pInt = 1
 Physical tensor index. More...
 
static constexpr int rInt = 2
 Root-directed tensor index. More...
 
static constexpr int aInt = 3
 Index of left subtree ("A") More...
 
static constexpr int bInt = 4
 Index of right subtree ("B") More...
 

Additional Inherited Members

- Static Public Member Functions inherited from syten::BinaryTree::Tree< Cached< Tensor< 4 > > >
static std::result_of< Func(Ptr)>::type visit_bottom_rec (Func &&f, typename std::result_of< Func(PtrType)>::type initial, IterFirst const dir, PtrType ptr)
 Recursively visits a subtree, bottom-first. More...
 
static std::result_of< Func(ValueType &)>::type visit_bottom_rec (Func &&f, typename std::result_of< Func(ValueType &)>::type initial, IterFirst const dir, PtrType ptr)
 Recursively visits a subtree, bottom-first. More...
 
static void visit_bottom_rec (Func &&f, IterFirst const dir, PtrType ptr)
 Recursively visits a subtree, bottom-first. More...
 
static std::result_of< Func(PtrType)>::type visit_top_rec (Func &&f, typename std::result_of< Func(PtrType)>::type initial, IterFirst const dir, PtrType ptr)
 Recursively visits a subtree, top-first for const trees. More...
 
static std::result_of< Func(ValueType &)>::type visit_top_rec (Func &&f, typename std::result_of< Func(ValueType &)>::type initial, IterFirst const dir, PtrType ptr)
 Recursively visits a subtree, top-first. More...
 
static void visit_top_rec (Func &&f, IterFirst const dir, PtrType ptr)
 Recursively visits a subtree, top-first. More...
 

Detailed Description

A binary tree tensor network state.


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