SyTen
syten::Tensor< rank > Class Template Reference

A single tensor, composed of a set of symmetry-protected blocks. More...

#include <tensor.h>

+ Inheritance diagram for syten::Tensor< rank >:
+ Collaboration diagram for syten::Tensor< rank >:

Public Types

typedef TensorBlock< rankBlock
 Type of the underlying block, a tensor is simply a set of such blocks. More...
 
typedef Block::CGC CGC
 Type of a single CGC space. More...
 
typedef Block::CGCSet CGCSet
 Type of the set of all CGC spaces. More...
 
typedef Block::Dense Dense
 Type of the reduced tensor (i.e. excluding CGC spaces) More...
 
typedef Block::Sym Sym
 Type of the symmetry transformation description of a given block. More...
 

Public Member Functions

MemoryUsage::MemorySize allocSize () const
 allocSize()/memory_size.h support. More...
 
template<typename Archive >
void serialize (Archive &ar, unsigned int const in_version)
 Boost serialisation. More...
 
Constructors
 Tensor ()
 Default ctor, initialised with invalid leg directions. More...
 
 Tensor (std::array< Direction, rank > const &dirs_)
 Zero-tensor with the specified directions. More...
 
 Tensor (std::array< Direction, rank > const &dirs_, Index size)
 Zero-tensor with the specified directions and default-constructed blocks. More...
 
Vector imitation of a tensor, allows easy iteration over the tensor
Blockoperator[] (Index i)
 Vector-like interface. More...
 
Block const & operator[] (Index i) const
 Vector-like interface. More...
 
Blockat (Index i)
 Vector-like interface. More...
 
Block const & at (Index i) const
 Vector-like interface. More...
 
std::vector< Block >::iterator begin ()
 Vector-like interface. More...
 
std::vector< Block >::const_iterator begin () const
 Vector-like interface. More...
 
std::vector< Block >::const_iterator cbegin () const
 Vector-like interface. More...
 
std::vector< Block >::iterator end ()
 Vector-like interface. More...
 
std::vector< Block >::const_iterator end () const
 Vector-like interface. More...
 
std::vector< Block >::const_iterator cend () const
 Vector-like interface. More...
 
std::vector< Block >::iterator erase (typename std::vector< Block >::const_iterator x)
 Vector-like interface. More...
 
std::vector< Block >::iterator erase (typename std::vector< Block >::const_iterator x, typename std::vector< Block >::const_iterator y)
 Vector-like interface. More...
 
Index size () const
 Vector-like interface. More...
 
bool empty () const
 Vector-like interface. More...
 
void reserve (Index i)
 Vector-like interface. More...
 
void resize (Index i)
 Vector-like interface. More...
 
void clear ()
 Vector-like interface. More...
 
void shrink_to_fit ()
 Vector-like interface. More...
 
void push_back (Block const &b)
 Vector-like interface. More...
 
void push_back (Block &&b)
 Vector-like interface. More...
 
template<typename... Types>
void emplace_back (Types &&... args)
 Vector-like interface. More...
 
Basis information
Basis getBasis (Index leg) const
 Constructs the basis on the specified leg. More...
 
Basis b (Index leg) const
 Shortcut for getBasis. More...
 
BasisMap getBasisMap (Index leg) const
 Constructs a basis map on the specified leg, suitable to quickly check for the existence of sectors. More...
 
Basis getAddedBasis (Index leg) const
 Constructs the maximal basis on the specified leg. More...
 
Index getReducedDim (Index leg) const
 Get the sum of all reduced tensor dimensions on the specified leg. More...
 
std::array< Index, rankgetReducedDims () const
 c.f. getReducedDim(), for all legs More...
 
Tensor const & print_bases () const
 
Index getTotalDim (Index leg) const
 Get the sum of the tensor-producted block dimensions on the specified leg. More...
 
std::array< Index, rankgetTotalDims () const
 c.f. getTotalDim(), for all legs More...
 
Index getMaxBlocksize (Index leg) const
 gets the sidelength of the largest block on the specified leg More...
 
Index getAvgBlocksize (Index leg) const
 get averaged sidelength of blocks as \( \left[\frac{1}{N} \sum_i m_i^3 \right]^{1/3} \) More...
 
std::size_t getDenseSize () const
 Returns the total number of dense tensor entries. More...
 
bool hasCGC () const
 Returns true if the tensor a symmetry which has a CGC space (typically) attached, e.g. More...
 
Deparallelisation of tensor blocks, addition of tensor blocks
void reduce (EliminateZeros const ezeros=EliminateZeros::Yes, bool const add_cgc=false, bool const no_para=false, bool const no_zero_check_dense=false)
 Reduce the number of blocks in the tensor by adding parallel blocks together. More...
 
void add (TensorBlock< rank > &&t)
 Adds a block to the tensor. More...
 
void add (TensorBlock< rank > const &t)
 
template<typename... Args>
void add (Args &&... args)
 

Public Attributes

std::vector< Blockblocks
 Blocks composing this tensor. More...
 
std::array< Direction, rankdirs
 Directions of the individual legs (incoming/outgoing) More...
 

Static Public Attributes

static constexpr Rank this_rank = rank
 Helper to retrieve the tensor rank from an object of this type. More...
 
static constexpr unsigned int version = 1
 Bump this if one of the above changes. More...
 

Detailed Description

template<Rank rank>
class syten::Tensor< rank >

A single tensor, composed of a set of symmetry-protected blocks.

Template Parameters
rankthe rank of the tensor, i.e. the number of indices

Member Typedef Documentation

◆ Block

template<Rank rank>
typedef TensorBlock<rank> syten::Tensor< rank >::Block

Type of the underlying block, a tensor is simply a set of such blocks.

◆ CGC

template<Rank rank>
typedef Block::CGC syten::Tensor< rank >::CGC

Type of a single CGC space.

◆ CGCSet

template<Rank rank>
typedef Block::CGCSet syten::Tensor< rank >::CGCSet

Type of the set of all CGC spaces.

◆ Dense

template<Rank rank>
typedef Block::Dense syten::Tensor< rank >::Dense

Type of the reduced tensor (i.e. excluding CGC spaces)

◆ Sym

template<Rank rank>
typedef Block::Sym syten::Tensor< rank >::Sym

Type of the symmetry transformation description of a given block.

Constructor & Destructor Documentation

◆ Tensor() [1/3]

template<Rank rank>
syten::Tensor< rank >::Tensor ( )
inline

Default ctor, initialised with invalid leg directions.

◆ Tensor() [2/3]

template<Rank rank>
syten::Tensor< rank >::Tensor ( std::array< Direction, rank > const &  dirs_)
inline

Zero-tensor with the specified directions.

◆ Tensor() [3/3]

template<Rank rank>
syten::Tensor< rank >::Tensor ( std::array< Direction, rank > const &  dirs_,
Index  size 
)
inline

Zero-tensor with the specified directions and default-constructed blocks.

Member Function Documentation

◆ add() [1/3]

◆ add() [2/3]

template<Rank rank>
void syten::Tensor< rank >::add ( TensorBlock< rank > const &  t)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ add() [3/3]

template<Rank rank>
template<typename... Args>
void syten::Tensor< rank >::add ( Args &&...  args)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ allocSize()

template<Rank rank>
MemoryUsage::MemorySize syten::Tensor< rank >::allocSize ( ) const
inline

allocSize()/memory_size.h support.

◆ at() [1/2]

template<Rank rank>
Block& syten::Tensor< rank >::at ( Index  i)
inline

Vector-like interface.

Referenced by syten::Pyten::init_tensor().

+ Here is the caller graph for this function:

◆ at() [2/2]

template<Rank rank>
Block const& syten::Tensor< rank >::at ( Index  i) const
inline

Vector-like interface.

◆ b()

◆ begin() [1/2]

template<Rank rank>
std::vector<Block>::iterator syten::Tensor< rank >::begin ( )
inline

Vector-like interface.

Referenced by syten::MPS::apply_op_orthogonalise_fit(), syten::avgAbs(), syten::TensorBlocks::sort_VecIdx_single(), and syten::TensorBlocks::sort_VecRepIdx_some().

+ Here is the caller graph for this function:

◆ begin() [2/2]

template<Rank rank>
std::vector<Block>::const_iterator syten::Tensor< rank >::begin ( ) const
inline

Vector-like interface.

◆ cbegin()

template<Rank rank>
std::vector<Block>::const_iterator syten::Tensor< rank >::cbegin ( ) const
inline

Vector-like interface.

◆ cend()

template<Rank rank>
std::vector<Block>::const_iterator syten::Tensor< rank >::cend ( ) const
inline

Vector-like interface.

◆ clear()

◆ emplace_back()

template<Rank rank>
template<typename... Types>
void syten::Tensor< rank >::emplace_back ( Types &&...  args)
inline

Vector-like interface.

Referenced by syten::expansion(), syten::genCombinator(), syten::insertDummy(), syten::multi_transpose(), and syten::project().

+ Here is the caller graph for this function:

◆ empty()

template<Rank rank>
bool syten::Tensor< rank >::empty ( ) const
inline

Vector-like interface.

Referenced by syten::BTT::Operator::anorm_node(), syten::BTT::Operator::bnorm_node(), syten::Deparallelise::cols(), syten::Delinearise::cols(), syten::QR::qr(), syten::BTT::Operator::rnorm_node(), syten::Deparallelise::rows(), syten::TensorBlocks::sort_VecIdx_single(), syten::TensorBlocks::sort_VecRepIdx_some(), and syten::SVD::svd().

+ Here is the caller graph for this function:

◆ end() [1/2]

template<Rank rank>
std::vector<Block>::iterator syten::Tensor< rank >::end ( )
inline

Vector-like interface.

Referenced by syten::MPS::apply_op_orthogonalise_fit(), and syten::avgAbs().

+ Here is the caller graph for this function:

◆ end() [2/2]

template<Rank rank>
std::vector<Block>::const_iterator syten::Tensor< rank >::end ( ) const
inline

Vector-like interface.

◆ erase() [1/2]

template<Rank rank>
std::vector<Block>::iterator syten::Tensor< rank >::erase ( typename std::vector< Block >::const_iterator  x)
inline

Vector-like interface.

◆ erase() [2/2]

template<Rank rank>
std::vector<Block>::iterator syten::Tensor< rank >::erase ( typename std::vector< Block >::const_iterator  x,
typename std::vector< Block >::const_iterator  y 
)
inline

Vector-like interface.

◆ getAddedBasis()

template<Rank rank>
Basis syten::Tensor< rank >::getAddedBasis ( Index  leg) const
inline

Constructs the maximal basis on the specified leg.

Rather than assuming that all blocks in a sector are ‘overlays’ of each other, assume that they are ‘put next to’ each other. Only useful to decide what the maximal currently achievable blocksize is.

◆ getAvgBlocksize()

template<Rank rank>
Index syten::Tensor< rank >::getAvgBlocksize ( Index  leg) const
inline

get averaged sidelength of blocks as \( \left[\frac{1}{N} \sum_i m_i^3 \right]^{1/3} \)

This is a fairly good measure of computational cost as matrix-matrix multiplication tends to scale with the third power of the blocksize. One block of the resulting size will then likely cost as much as all blocks of the current size.

Referenced by syten::btt_operator_fbasis().

+ Here is the caller graph for this function:

◆ getBasis()

◆ getBasisMap()

template<Rank rank>
BasisMap syten::Tensor< rank >::getBasisMap ( Index  leg) const
inline

Constructs a basis map on the specified leg, suitable to quickly check for the existence of sectors.

Referenced by syten::compat_exact_equal(), syten::MPS::LBOState::dropUnmatchedM(), syten::MPS::LBOState::dropUnmatchedV(), syten::exponentialTensorSym(), syten::MPS::left_complement(), and syten::MPS::right_complement().

+ Here is the caller graph for this function:

◆ getDenseSize()

template<Rank rank>
std::size_t syten::Tensor< rank >::getDenseSize ( ) const
inline

Returns the total number of dense tensor entries.

Referenced by syten::operator==().

+ Here is the caller graph for this function:

◆ getMaxBlocksize()

template<Rank rank>
Index syten::Tensor< rank >::getMaxBlocksize ( Index  leg) const
inline

gets the sidelength of the largest block on the specified leg

Referenced by syten::btt_operator_fbasis(), and syten::MPS::DMRG::LBOWorker::singleUpdate().

+ Here is the caller graph for this function:

◆ getReducedDim()

template<Rank rank>
Index syten::Tensor< rank >::getReducedDim ( Index  leg) const
inline

Get the sum of all reduced tensor dimensions on the specified leg.

Referenced by syten::btt_operator_fbasis(), syten::Tensor< 6 >::getReducedDims(), and syten::MPS::DMRG::LBOWorker::singleUpdate().

+ Here is the caller graph for this function:

◆ getReducedDims()

template<Rank rank>
std::array<Index, rank> syten::Tensor< rank >::getReducedDims ( ) const
inline

c.f. getReducedDim(), for all legs

◆ getTotalDim()

template<Rank rank>
Index syten::Tensor< rank >::getTotalDim ( Index  leg) const
inline

Get the sum of the tensor-producted block dimensions on the specified leg.

Equivalent to getReducedDim() if only Abelian symmetries are used.

Referenced by syten::btt_operator_fbasis(), syten::correct_cgc_tensors(), syten::Tensor< 6 >::getTotalDims(), and syten::MPS::DMRG::LBOWorker::singleUpdate().

+ Here is the caller graph for this function:

◆ getTotalDims()

template<Rank rank>
std::array<Index, rank> syten::Tensor< rank >::getTotalDims ( ) const
inline

c.f. getTotalDim(), for all legs

◆ hasCGC()

template<Rank rank>
bool syten::Tensor< rank >::hasCGC ( ) const
inline

Returns true if the tensor a symmetry which has a CGC space (typically) attached, e.g.

SU(2) etc.

Referenced by syten::correct_cgc_tensors().

+ Here is the caller graph for this function:

◆ operator[]() [1/2]

template<Rank rank>
Block& syten::Tensor< rank >::operator[] ( Index  i)
inline

Vector-like interface.

◆ operator[]() [2/2]

template<Rank rank>
Block const& syten::Tensor< rank >::operator[] ( Index  i) const
inline

Vector-like interface.

◆ push_back() [1/2]

◆ push_back() [2/2]

template<Rank rank>
void syten::Tensor< rank >::push_back ( Block &&  b)
inline

Vector-like interface.

◆ reduce()

template<Rank rank>
void syten::Tensor< rank >::reduce ( EliminateZeros const  ezeros = EliminateZeros::Yes,
bool const  add_cgc = false,
bool const  no_para = false,
bool const  no_zero_check_dense = false 
)

Reduce the number of blocks in the tensor by adding parallel blocks together.

Discards zero-blocks (i.e. blocks where norm(reduced) or norm(cgc) is smaller than SYTEN_ZNORM_THRESHOLD).

When building a tensor from many blocks, first push_back() all blocks and then call reduce() to minimise the overhead from comparisons.

Parameters
ezerosif EliminateZeros::Yes, small tensors arising from large tensors will be removed
add_cgcif true, CGC spaces will be added together if the dense spaces are parallel
no_paraif true, tensor-level parallelisation will be disabled
no_zero_check_denseif true, assumes that dense tensors are never zero unless isZero is set on the block (true e.g. for products)

Finally, in every bin, check all blocks left over. If they are sufficiently large, move them into *this, otherwise drop them.

Referenced by syten::addScaled(), syten::Deparallelise::cols(), syten::Delinearise::cols(), syten::MPS::Lat::U1U1::genFermiBoseLattice(), syten::MPS::Lat::U1U1::genFermiHubbard(), syten::MPS::Lat::U1U1Z::genFermiHubbardKNS(), syten::MPS::Lat::U1U1::genKondoModel(), syten::Tensor< 6 >::hasCGC(), syten::BTT::operator*=(), syten::IPEPS::ATwoOp::operator+(), syten::operator+=(), syten::IPEPS::SumOp::operator+=(), syten::operator-=(), syten::project(), syten::QR::qr(), syten::Deparallelise::rows(), and syten::SVD::svd().

+ Here is the caller graph for this function:

◆ reserve()

template<Rank rank>
void syten::Tensor< rank >::reserve ( Index  i)
inline

◆ resize()

template<Rank rank>
void syten::Tensor< rank >::resize ( Index  i)
inline

Vector-like interface.

◆ serialize()

template<Rank rank>
template<typename Archive >
void syten::Tensor< rank >::serialize ( Archive &  ar,
unsigned int const  in_version 
)
inline

Boost serialisation.

◆ shrink_to_fit()

template<Rank rank>
void syten::Tensor< rank >::shrink_to_fit ( )
inline

Vector-like interface.

Referenced by syten::Tensor< 6 >::clear().

+ Here is the caller graph for this function:

◆ size()

Member Data Documentation

◆ blocks

template<Rank rank>
std::vector<Block> syten::Tensor< rank >::blocks

Blocks composing this tensor.

Referenced by syten::operator-=(), and syten::Tensor< 6 >::serialize().

◆ dirs

◆ this_rank

template<Rank rank>
constexpr Rank syten::Tensor< rank >::this_rank = rank
static

Helper to retrieve the tensor rank from an object of this type.

Referenced by syten::STensorImpl::delinearise(), and syten::STensorImpl::deparallelise().

◆ version

template<Rank rank>
constexpr unsigned int syten::Tensor< rank >::version = 1
static

Bump this if one of the above changes.


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