xerus
a general purpose tensor library
xerus::internal::TTStack< isOperator > Class Template Referencefinal

Internal class used to represent stacks of (possibly multiply) applications of TTOperators to either a TTTensor or TTOperator. More...

#include <ttStack.h>

Inheritance diagram for xerus::internal::TTStack< isOperator >:
Collaboration diagram for xerus::internal::TTStack< isOperator >:

Public Member Functions

 TTStack (const bool _canno, const size_t _corePos=0)
 
 TTStack (const TTStack &_other)=default
 
 TTStack (TTStack &&_other)=default
 
virtual value_t frob_norm () const override
 Calculates the frobenious norm of the TensorNetwork. More...
 
virtual TensorNetworkget_copy () const override
 Returns a new copy of the network. More...
 
 operator TTNetwork< isOperator > ()
 
virtual void operator*= (const value_t _factor) override
 Performs the entrywise multiplication with a constant _factor. More...
 
virtual void operator/= (const value_t _divisor) override
 Performs the entrywise divison by a constant _divisor. More...
 
TTStackoperator= (const TTStack &_other)=delete
 
TTStackoperator= (TTStack &&_other)=delete
 
virtual bool specialized_contraction (std::unique_ptr< IndexedTensorMoveable< TensorNetwork >> &_out, IndexedTensorReadOnly< TensorNetwork > &&_me, IndexedTensorReadOnly< TensorNetwork > &&_other) const override
 (Internal) Calculates the contraction between _me and _other and stores the result in _out. Requires that *this is the tensorObjectReadOnly of _me. More...
 
virtual void specialized_evaluation (IndexedTensorWritable< TensorNetwork > &&, IndexedTensorReadOnly< TensorNetwork > &&) override
 (Internal) Evaluates _other into _me. Requires that *this is the tensorObjectReadOnly of _me. More...
 
virtual bool specialized_sum (std::unique_ptr< IndexedTensorMoveable< TensorNetwork >> &_out, IndexedTensorReadOnly< TensorNetwork > &&_me, IndexedTensorReadOnly< TensorNetwork > &&_other) const override
 (Internal) Calculates the sum between _me and _other and stores the result in _out. Requires that *this is the tensorObjectReadOnly of _me. More...
 
- Public Member Functions inherited from xerus::TensorNetwork
 TensorNetwork ()
 Constructs an order zero TensorNetwork. More...
 
 TensorNetwork (const TensorNetwork &_cpy)=default
 Copy Constructor. More...
 
 TensorNetwork (TensorNetwork &&_mv) noexcept=default
 Move Constructor. More...
 
 TensorNetwork (Tensor _other)
 Constructs the trivial TensorNetwork containing the given Tensor as single node. More...
 
 TensorNetwork (std::unique_ptr< Tensor > &&_tensor)
 Constructs the trivial TensorNetwork containing the given Tensor as single node. The TN takes the ownership of the pointer. More...
 
 TensorNetwork (size_t _degree)
 Constructs the trivial TensorNetwork containing a Tensor with the given degree. More...
 
 TensorNetwork (const ZeroNode _nodeStatus)
 (Internal) Constructs an order zero TensorNetwork. More...
 
virtual ~TensorNetwork ()=default
 Destructor. More...
 
void contract (const size_t _nodeId1, const size_t _nodeId2)
 Contracts the nodes with indices _nodeId1 and _nodeId2. More...
 
size_t contract (const std::set< size_t > &_ids)
 Contracts the nodes with with indices included in the given set _ids. More...
 
double contraction_cost (const size_t _nodeId1, const size_t _nodeId2) const
 Approximates the cost of contraction two given nodes. More...
 
size_t datasize () const
 Calculates the storage requirement of the current representation. More...
 
size_t degree () const
 Gets the degree of the TensorNetwork. More...
 
void draw (const std::string &_filename) const
 Draws a graph representation of the TensorNetwork. More...
 
std::pair< size_t, size_t > find_common_edge (const size_t _nodeA, const size_t _nodeB) const
 Finds the position of a single common edge between two nodes. More...
 
virtual void fix_mode (const size_t _mode, const size_t _slatePosition)
 Fixes a specific mode to a specific value, effectively reducing the order by one. More...
 
 operator Tensor () const
 Explicit cast to Tensor. More...
 
template<typename... args>
internal::IndexedTensor< TensorNetworkoperator() (args... _args)
 Indexes the TensorNetwork for read/write use. More...
 
template<typename... args>
internal::IndexedTensorReadOnly< TensorNetworkoperator() (args... _args) const
 Indexes the TensorNetwork for read only use. More...
 
internal::IndexedTensor< TensorNetworkoperator() (const std::vector< Index > &_indices)
 Indexes the TensorNetwork for read/write use. More...
 
internal::IndexedTensor< TensorNetworkoperator() (std::vector< Index > &&_indices)
 Indexes the TensorNetwork for read/write use. More...
 
internal::IndexedTensorReadOnly< TensorNetworkoperator() (const std::vector< Index > &_indices) const
 Indexes the TensorNetwork for read only use. More...
 
internal::IndexedTensorReadOnly< TensorNetworkoperator() (std::vector< Index > &&_indices) const
 Indexes the TensorNetwork for read only use. More...
 
TensorNetworkoperator= (const TensorNetwork &_cpy)=default
 TensorNetworks are copy assignable. More...
 
TensorNetworkoperator= (TensorNetwork &&_mv)=default
 TensorNetworks are move assignable. More...
 
value_t operator[] (const size_t _position) const
 Read the value at a specific position. More...
 
value_t operator[] (const std::vector< size_t > &_positions) const
 Read the value at a specific position. More...
 
void reduce_representation ()
 Contracts all nodes that are joined by a full-rank edge. More...
 
virtual void remove_slate (const size_t _mode, const size_t _slatePosition)
 removes the given _slatePosition from the _mode. this reduces the given dimension by one More...
 
virtual void require_correct_format () const
 Sanity check for the TensorNetwork and if applicable for the specific format. More...
 
void require_valid_network (const bool _check_erased=true) const
 Sanity checks the network. More...
 
void reshuffle_nodes (const std::function< size_t(size_t)> &_f)
 reshuffled the nodes according to the given function More...
 
virtual void resize_mode (const size_t _mode, const size_t _newDim, const size_t _cutPos=~0ul)
 Resizes a specific mode of the TensorNetwork. More...
 
virtual void round_edge (const size_t _nodeA, const size_t _nodeB, const size_t _maxRank, const double _eps, const double _softThreshold)
 Thresholds the rank between two given nodes. More...
 
void sanitize ()
 Removes all erased nodes from the TensorNetwork. More...
 
void swap_external_links (const size_t _i, const size_t _j)
 Swaps the external indices _i and _j, effectively changing those indices for the represented Tensor (e.g. a transposition for matrices). More...
 
virtual void transfer_core (const size_t _from, const size_t _to, const bool _allowRankReduction=true)
 Transfers the core from one given node to another. More...
 

Static Public Member Functions

static void contract_stack (IndexedTensorWritable< TensorNetwork > &&_me)
 
- Static Public Member Functions inherited from xerus::TensorNetwork
static void add_network_to_network (internal::IndexedTensorWritable< TensorNetwork > &&_base, internal::IndexedTensorReadOnly< TensorNetwork > &&_toInsert)
 Inserts all nodes from _toInsert into _base, creating links where demanded by the indices. More...
 
static void link_traces_and_fix (internal::IndexedTensorWritable< TensorNetwork > &&_base)
 Finds traces defined by the indices and internally links the corresponding indices. Also applys all fixed indices. More...
 

Public Attributes

const bool cannonicalization_required
 
const size_t futureCorePosition
 
- Public Attributes inherited from xerus::TensorNetwork
std::vector< size_t > dimensions
 Dimensions of the external indices, i.e. the dimensions of the tensor represented by the network. More...
 
std::vector< LinkexternalLinks
 The open links of the network in order. More...
 
std::vector< TensorNodenodes
 The nodes constituting the network. The order determines the ids of the nodes. More...
 

Static Public Attributes

static constexpr const size_t N = isOperator?2:1
 The number of external links in each node, i.e. one for TTTensors and two for TTOperators. More...
 

Additional Inherited Members

- Public Types inherited from xerus::TensorNetwork
using RankTuple = std::vector< size_t >
 : Represention of the ranks of a TensorNetwork. More...
 
- Protected Types inherited from xerus::TensorNetwork
enum  ZeroNode : bool { ZeroNode::None, ZeroNode::Add }
 Internal indicator to prevent the creation of an degree zero node in TensorNetwork constructor. More...
 
- Protected Member Functions inherited from xerus::TensorNetwork
virtual void contract_unconnected_subnetworks ()
 Contracts all nodes that are not connected to any external links. More...
 
std::vector< Linkinit_from_dimension_array ()
 : Sets the externalLinks and returns an Link vector for a node, assuming that this node is the only node there is and all given dimensions are open. More...
 
void perform_traces (const size_t _nodeId)
 Performs all traces in the given node. More...
 
TensorNetwork stripped_subnet (const std::function< bool(size_t)> &_idF=[](size_t){ return true;}) const
 Creates a dataless copy of a subnet. More...
 

Detailed Description

template<bool isOperator>
class xerus::internal::TTStack< isOperator >

Internal class used to represent stacks of (possibly multiply) applications of TTOperators to either a TTTensor or TTOperator.

Definition at line 38 of file ttStack.h.

Constructor & Destructor Documentation

◆ TTStack() [1/3]

template<bool isOperator>
xerus::internal::TTStack< isOperator >::TTStack ( const bool  _canno,
const size_t  _corePos = 0 
)
explicit

Definition at line 38 of file ttStack.cpp.

◆ TTStack() [2/3]

template<bool isOperator>
xerus::internal::TTStack< isOperator >::TTStack ( const TTStack< isOperator > &  _other)
default

◆ TTStack() [3/3]

template<bool isOperator>
xerus::internal::TTStack< isOperator >::TTStack ( TTStack< isOperator > &&  _other)
default

Member Function Documentation

◆ contract_stack()

template<bool isOperator>
void xerus::internal::TTStack< isOperator >::contract_stack ( IndexedTensorWritable< TensorNetwork > &&  _me)
static

Definition at line 197 of file ttStack.cpp.

◆ frob_norm()

template<bool isOperator>
value_t xerus::internal::TTStack< isOperator >::frob_norm ( ) const
overridevirtual

Calculates the frobenious norm of the TensorNetwork.

Returns
the frobenious norm of the TensorNetwork.

Reimplemented from xerus::TensorNetwork.

Definition at line 331 of file ttStack.cpp.

◆ get_copy()

template<bool isOperator>
TensorNetwork * xerus::internal::TTStack< isOperator >::get_copy ( ) const
overridevirtual

Returns a new copy of the network.

Reimplemented from xerus::TensorNetwork.

Definition at line 42 of file ttStack.cpp.

◆ operator TTNetwork< isOperator >()

template<bool isOperator>
xerus::internal::TTStack< isOperator >::operator TTNetwork< isOperator > ( )
explicit

Definition at line 48 of file ttStack.cpp.

◆ operator*=()

template<bool isOperator>
void xerus::internal::TTStack< isOperator >::operator*= ( const value_t  _factor)
overridevirtual

Performs the entrywise multiplication with a constant _factor.

Internally this only results in a change in the global factor.

Parameters
_factorthe factor,

Reimplemented from xerus::TensorNetwork.

Definition at line 176 of file ttStack.cpp.

◆ operator/=()

template<bool isOperator>
void xerus::internal::TTStack< isOperator >::operator/= ( const value_t  _divisor)
overridevirtual

Performs the entrywise divison by a constant _divisor.

Internally this only results in a change in the global factor.

Parameters
_divisorthe divisor,

Reimplemented from xerus::TensorNetwork.

Definition at line 190 of file ttStack.cpp.

◆ operator=() [1/2]

template<bool isOperator>
TTStack& xerus::internal::TTStack< isOperator >::operator= ( const TTStack< isOperator > &  _other)
delete

◆ operator=() [2/2]

template<bool isOperator>
TTStack& xerus::internal::TTStack< isOperator >::operator= ( TTStack< isOperator > &&  _other)
delete

◆ specialized_contraction()

template<bool isOperator>
bool xerus::internal::TTStack< isOperator >::specialized_contraction ( std::unique_ptr< IndexedTensorMoveable< TensorNetwork >> &  _out,
IndexedTensorReadOnly< TensorNetwork > &&  _me,
IndexedTensorReadOnly< TensorNetwork > &&  _other 
) const
overridevirtual

(Internal) Calculates the contraction between _me and _other and stores the result in _out. Requires that *this is the tensorObjectReadOnly of _me.

Reimplemented from xerus::TensorNetwork.

Definition at line 319 of file ttStack.cpp.

◆ specialized_evaluation()

template<bool isOperator>
void xerus::internal::TTStack< isOperator >::specialized_evaluation ( IndexedTensorWritable< TensorNetwork > &&  _me,
IndexedTensorReadOnly< TensorNetwork > &&  _other 
)
overridevirtual

(Internal) Evaluates _other into _me. Requires that *this is the tensorObjectReadOnly of _me.

Reimplemented from xerus::TensorNetwork.

Definition at line 313 of file ttStack.cpp.

◆ specialized_sum()

template<bool isOperator>
bool xerus::internal::TTStack< isOperator >::specialized_sum ( std::unique_ptr< IndexedTensorMoveable< TensorNetwork >> &  _out,
IndexedTensorReadOnly< TensorNetwork > &&  _me,
IndexedTensorReadOnly< TensorNetwork > &&  _other 
) const
overridevirtual

(Internal) Calculates the sum between _me and _other and stores the result in _out. Requires that *this is the tensorObjectReadOnly of _me.

Reimplemented from xerus::TensorNetwork.

Definition at line 325 of file ttStack.cpp.

Member Data Documentation

◆ cannonicalization_required

template<bool isOperator>
const bool xerus::internal::TTStack< isOperator >::cannonicalization_required

Definition at line 43 of file ttStack.h.

◆ futureCorePosition

template<bool isOperator>
const size_t xerus::internal::TTStack< isOperator >::futureCorePosition

Definition at line 45 of file ttStack.h.

◆ N

template<bool isOperator>
constexpr const size_t xerus::internal::TTStack< isOperator >::N = isOperator?2:1
static

The number of external links in each node, i.e. one for TTTensors and two for TTOperators.

Definition at line 41 of file ttStack.h.


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