xerus
a general purpose tensor library
|
Specialized TensorNetwork class used to represent TTTensor and TToperators. More...
#include <performanceData.h>
Public Member Functions | |
TTNetwork () | |
Constructs an order zero TTNetwork. More... | |
TTNetwork (const TTNetwork &_cpy)=default | |
TTNetworks are default copy constructable. More... | |
TTNetwork (TTNetwork &&_mov) noexcept=default | |
TTNetworks are default move constructable. More... | |
TTNetwork (const size_t _degree) | |
Constructs an zero initialized TTNetwork with the given degree and ranks all equal to one. More... | |
TTNetwork (Tensor::DimensionTuple _dimensions) | |
Constructs an zero initialized TTNetwork with the given dimensions and ranks all equal to one. More... | |
TTNetwork (const Tensor &_tensor, const double _eps=EPSILON, const size_t _maxRank=std::numeric_limits< size_t >::max()) | |
Constructs a TTNetwork from the given Tensor. More... | |
TTNetwork (const Tensor &_tensor, const double _eps, const RankTuple &_maxRanks) | |
Constructs a TTNetwork from the given Tensor. More... | |
void | assume_core_position (const size_t _pos) |
stores _pos as the current core position without verifying of ensuring that this is the case More... | |
void | canonicalize_left () |
Move the core to the left. More... | |
void | canonicalize_right () |
Move the core to the left. More... | |
std::pair< TensorNetwork, TensorNetwork > | chop (const size_t _position) const |
Splits the TTNetwork into two parts by removing the node. More... | |
Tensor & | component (const size_t _idx) |
Complete access to a specific component of the TT decomposition. More... | |
virtual void | contract_unconnected_subnetworks () override |
Contracts all nodes that are not connected to any external links. More... | |
size_t | degrees_of_freedom () |
calculates the number of degrees of freedom of the manifold of fixed tt-rank that the given TTTensor is part of More... | |
virtual void | fix_mode (const size_t _mode, const size_t _slatePosition) override |
Fixes a specific mode to a specific value, effectively reducing the order by one. More... | |
virtual value_t | frob_norm () const override |
Calculates the frobenious norm of the TensorNetwork. More... | |
const Tensor & | get_component (const size_t _idx) const |
Read access to a specific component of the TT decomposition. More... | |
virtual TensorNetwork * | get_copy () const override |
Returns a new copy of the network. More... | |
template<> | |
TTNetwork< true > | identity (const std::vector< size_t > &_dimensions) |
void | move_core (const size_t _position, const bool _keepRank=false) |
Move the core to a new position. More... | |
virtual void | operator*= (const value_t _factor) override |
Calculates the entrywise multiplication of this TensorNetwork with a constant _factor. More... | |
TTNetwork & | operator+= (const TTNetwork &_other) |
Adds a given TTNetwork to this one. More... | |
TTNetwork & | operator-= (const TTNetwork &_other) |
Subtracts the _other TTNetwork entrywise from this one. More... | |
virtual void | operator/= (const value_t _divisor) override |
Calculates the entrywise divison of this TensorNetwork by a constant _divisor. More... | |
TTNetwork & | operator= (const TTNetwork &_other)=default |
TTNetworks are default assignable. More... | |
TTNetwork & | operator= (TTNetwork &&_other)=default |
TTNetworks are default move-assignable. More... | |
size_t | rank (const size_t _i) const |
Gets the rank of a specific egde of the TTNetwork. More... | |
std::vector< size_t > | ranks () const |
Gets the ranks of the TTNetwork. More... | |
virtual void | require_correct_format () const override |
Tests whether the network resembles that of a TTTensor and checks consistency with the underlying tensor objects. More... | |
virtual void | resize_mode (const size_t _mode, const size_t _newDim, const size_t _cutPos=~0ul) override |
Resizes a specific mode of the TensorNetwork. More... | |
void | round (const std::vector< size_t > &_maxRanks, const double _eps=EPSILON) |
Reduce all ranks up to a given accuracy and maximal number. More... | |
void | round (const size_t _maxRank) |
Reduce all ranks to the given number. More... | |
void | round (const int _maxRank) |
Reduce all ranks to the given number. More... | |
void | round (const value_t _eps) |
Reduce all ranks up to a given accuracy. More... | |
void | set_component (const size_t _idx, Tensor _T) |
Sets a specific component of the TT decomposition. More... | |
void | soft_threshold (const double _tau, const bool _preventZero=false) |
Applies the soft threshholding operation to all ranks. More... | |
void | soft_threshold (const std::vector< double > &_taus, const bool _preventZero=false) |
Applies soft threshholding operations to all ranks. More... | |
virtual bool | specialized_contraction (std::unique_ptr< internal::IndexedTensorMoveable< TensorNetwork >> &_out, internal::IndexedTensorReadOnly< TensorNetwork > &&_me, internal::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... | |
template<> | |
bool | specialized_contraction_f (std::unique_ptr< internal::IndexedTensorMoveable< TensorNetwork >> &, internal::IndexedTensorReadOnly< TensorNetwork > &&, internal::IndexedTensorReadOnly< TensorNetwork > &&) |
template<> | |
bool | specialized_contraction_f (std::unique_ptr< internal::IndexedTensorMoveable< TensorNetwork >> &_out, internal::IndexedTensorReadOnly< TensorNetwork > &&_me, internal::IndexedTensorReadOnly< TensorNetwork > &&_other) |
virtual void | specialized_evaluation (internal::IndexedTensorWritable< TensorNetwork > &&_me, internal::IndexedTensorReadOnly< TensorNetwork > &&_other) override |
(Internal) Evaluates _other into _me. Requires that *this is the tensorObjectReadOnly of _me. More... | |
virtual bool | specialized_sum (std::unique_ptr< internal::IndexedTensorMoveable< TensorNetwork >> &_out, internal::IndexedTensorReadOnly< TensorNetwork > &&_me, internal::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... | |
template<bool B = isOperator, typename std::enable_if< B, int >::type = 0> | |
void | transpose () |
Transpose the TTOperator. More... | |
void | use_dense_representations () |
Converts all components to use dense representations. 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... | |
operator Tensor () const | |
Explicit cast to Tensor. More... | |
template<typename... args> | |
internal::IndexedTensor< TensorNetwork > | operator() (args... _args) |
Indexes the TensorNetwork for read/write use. More... | |
template<typename... args> | |
internal::IndexedTensorReadOnly< TensorNetwork > | operator() (args... _args) const |
Indexes the TensorNetwork for read only use. More... | |
internal::IndexedTensor< TensorNetwork > | operator() (const std::vector< Index > &_indices) |
Indexes the TensorNetwork for read/write use. More... | |
internal::IndexedTensor< TensorNetwork > | operator() (std::vector< Index > &&_indices) |
Indexes the TensorNetwork for read/write use. More... | |
internal::IndexedTensorReadOnly< TensorNetwork > | operator() (const std::vector< Index > &_indices) const |
Indexes the TensorNetwork for read only use. More... | |
internal::IndexedTensorReadOnly< TensorNetwork > | operator() (std::vector< Index > &&_indices) const |
Indexes the TensorNetwork for read only use. More... | |
TensorNetwork & | operator= (const TensorNetwork &_cpy)=default |
TensorNetworks are copy assignable. More... | |
TensorNetwork & | operator= (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... | |
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 | 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 size_t | degrees_of_freedom (const std::vector< size_t > &_dimensions, const std::vector< size_t > &_ranks) |
calculates the number of degrees of freedom of the manifold of fixed tt-rank _ranks with the given _dimensions More... | |
static TTNetwork XERUS_warn_unused | dirac (std::vector< size_t > _dimensions, const std::vector< size_t > &_position) |
: Returns a TTNetwork with a single entry equals oen and all other zero. More... | |
static TTNetwork XERUS_warn_unused | dirac (std::vector< size_t > _dimensions, const size_t _position) |
: Returns a Tensor with a single entry equals oen and all other zero. More... | |
template<bool B = isOperator, typename std::enable_if< B, int >::type = 0> | |
static TTNetwork XERUS_warn_unused | identity (const std::vector< size_t > &_dimensions) |
: Construct a TTOperator with the given dimensions representing the identity. More... | |
static TTNetwork XERUS_warn_unused | kronecker (const std::vector< size_t > &_dimensions) |
: Returns a TTNetwork representation of the kronecker delta. More... | |
static TTNetwork XERUS_warn_unused | ones (const std::vector< size_t > &_dimensions) |
: Returns a the (rank one) TT-Tensor with all entries equal to one. More... | |
template<class distribution = std::normal_distribution<value_t>, class generator = std::mt19937_64> | |
static TTNetwork XERUS_warn_unused | random (std::vector< size_t > _dimensions, const std::vector< size_t > &_ranks, distribution &_dist=xerus::misc::defaultNormalDistribution, generator &_rnd=xerus::misc::randomEngine) |
Transforms a given TensorNetwork to a TTNetwork. More... | |
template<class distribution = std::normal_distribution<value_t>, class generator = std::mt19937_64> | |
static TTNetwork XERUS_warn_unused | random (const std::vector< size_t > &_dimensions, const size_t _rank, distribution &_dist=xerus::misc::defaultNormalDistribution, generator &_rnd=xerus::misc::randomEngine) |
Random constructs a TTNetwork with the given dimensions and ranks limited by the given rank. More... | |
template<class distribution = std::normal_distribution<value_t>, class generator = std::mt19937_64> | |
static TTNetwork XERUS_warn_unused | random (const std::vector< size_t > &_dimensions, const std::vector< size_t > &_ranks, const std::function< void(Tensor &)> &_modifySingularValues, distribution &_dist=xerus::misc::defaultNormalDistribution, generator &_rnd=xerus::misc::randomEngine) |
Random constructs a TTNetwork with the given dimensions and ranks. More... | |
static std::vector< size_t > | reduce_to_maximal_ranks (std::vector< size_t > _ranks, const std::vector< size_t > &_dimensions) |
Reduces the given ranks to the maximal possible. More... | |
static bool | specialized_contraction_f (std::unique_ptr< internal::IndexedTensorMoveable< TensorNetwork >> &_out, internal::IndexedTensorReadOnly< TensorNetwork > &&_me, internal::IndexedTensorReadOnly< TensorNetwork > &&_other) |
static bool | specialized_sum_f (std::unique_ptr< internal::IndexedTensorMoveable< TensorNetwork >> &_out, internal::IndexedTensorReadOnly< TensorNetwork > &&_me, internal::IndexedTensorReadOnly< TensorNetwork > &&_other) |
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 | |
bool | canonicalized |
Flag indicating whether the TTNetwork is canonicalized. More... | |
size_t | corePosition |
The position of the core. More... | |
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< Link > | externalLinks |
The open links of the network in order. More... | |
std::vector< TensorNode > | nodes |
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... | |
Protected Member Functions | |
bool | exceeds_maximal_ranks () const |
Tests whether any rank exceeds the theoretic maximal value it should have. More... | |
size_t | num_ranks () const |
Return the number of ranks, i.e. 0 for degree zero and degree()/N-1 otherwise. More... | |
Protected Member Functions inherited from xerus::TensorNetwork | |
std::vector< Link > | init_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... | |
Static Protected Member Functions | |
static void | construct_train_from_full (TensorNetwork &_out, const Tensor &_A, const double _eps) |
Constructs a TTNetwork in _out by decomposing the given Tensor _A. 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... | |
Specialized TensorNetwork class used to represent TTTensor and TToperators.
TTTensors correspond to isOperator=FALSE and TTOperators correspond to isOperator=FALSE.
Definition at line 37 of file performanceData.h.
|
explicit |
Constructs an order zero TTNetwork.
This is an empty TensorNetwork. Internally the network contains one order zero node with entry zero.
Definition at line 46 of file ttNetwork.cpp.
|
default |
TTNetworks are default copy constructable.
|
defaultnoexcept |
TTNetworks are default move constructable.
|
explicit |
Constructs an zero initialized TTNetwork with the given degree and ranks all equal to one.
Naturally for TTOperators the degree must be even.
Definition at line 55 of file ttNetwork.cpp.
|
explicit |
Constructs an zero initialized TTNetwork with the given dimensions and ranks all equal to one.
Naturally for TTOperators the degree must be even.
Definition at line 58 of file ttNetwork.cpp.
|
explicit |
Constructs a TTNetwork from the given Tensor.
The higher order SVD algorithm is used to decompose the given Tensor into the TT format.
_tensor | The Tensor to decompose. |
_eps | the accuracy to be used in the decomposition. |
_maxRank | the maximal allowed rank (applies to all positions). |
Definition at line 50 of file ttNetwork.cpp.
|
explicit |
Constructs a TTNetwork from the given Tensor.
The higher order SVD algorithm is used to decompose the given Tensor into the TT format.
_tensor | The Tensor to decompose. |
_eps | the accuracy to be used in the decomposition. |
_maxRanks | maximal ranks to be used |
Definition at line 112 of file ttNetwork.cpp.
void xerus::TTNetwork< isOperator >::assume_core_position | ( | const size_t | _pos | ) |
stores _pos as the current core position without verifying of ensuring that this is the case
this is particularly useful after constructing an own TT tensor with set_component calls as these will assume that all orthogonalities are destroyed
Definition at line 735 of file ttNetwork.cpp.
void xerus::TTNetwork< isOperator >::canonicalize_left | ( | ) |
Move the core to the left.
Basically calls move_core() with _position = 0
Definition at line 632 of file ttNetwork.cpp.
void xerus::TTNetwork< isOperator >::canonicalize_right | ( | ) |
Move the core to the left.
Basically calls move_core() with _position = degree()-1
Definition at line 638 of file ttNetwork.cpp.
std::pair< TensorNetwork, TensorNetwork > xerus::TTNetwork< isOperator >::chop | ( | const size_t | _position | ) | const |
Splits the TTNetwork into two parts by removing the node.
_position | index of the component to be removed, thereby also defining the position of the split. |
Definition at line 515 of file ttNetwork.cpp.
Tensor & xerus::TTNetwork< isOperator >::component | ( | const size_t | _idx | ) |
Complete access to a specific component of the TT decomposition.
This function gives complete access to the components, only intended for internal use.
_idx | index of the component to access. |
Definition at line 457 of file ttNetwork.cpp.
|
staticprotected |
|
overridevirtual |
Contracts all nodes that are not connected to any external links.
Reimplemented from xerus::TensorNetwork.
Definition at line 748 of file ttNetwork.cpp.
|
static |
calculates the number of degrees of freedom of the manifold of fixed tt-rank _ranks with the given _dimensions
Definition at line 406 of file ttNetwork.cpp.
size_t xerus::TTNetwork< isOperator >::degrees_of_freedom | ( | ) |
calculates the number of degrees of freedom of the manifold of fixed tt-rank that the given TTTensor is part of
Definition at line 426 of file ttNetwork.cpp.
|
static |
: Returns a TTNetwork with a single entry equals oen and all other zero.
_dimensions | the dimensions of the new tensor. |
_position | The position of the one |
Definition at line 257 of file ttNetwork.cpp.
|
static |
: Returns a Tensor with a single entry equals oen and all other zero.
_dimensions | the dimensions of the new tensor. |
_position | The position of the one |
Definition at line 281 of file ttNetwork.cpp.
|
protected |
Tests whether any rank exceeds the theoretic maximal value it should have.
Does not check for the actual minimal rank for this tensor. But if any rank exceeds the theoretic maximum it is guaranteed not to be the minimal rank.
Definition at line 349 of file ttNetwork.cpp.
|
overridevirtual |
Fixes a specific mode to a specific value, effectively reducing the order by one.
_mode | the mode in which the slate shall be fixed, e.g. 0 to fix the first mode. |
_slatePosition | the position in the corresponding mode that shall be used. |
Reimplemented from xerus::TensorNetwork.
Definition at line 432 of file ttNetwork.cpp.
|
overridevirtual |
Calculates the frobenious norm of the TensorNetwork.
Reimplemented from xerus::TensorNetwork.
Definition at line 782 of file ttNetwork.cpp.
const Tensor & xerus::TTNetwork< isOperator >::get_component | ( | const size_t | _idx | ) | const |
Read access to a specific component of the TT decomposition.
This function should be used to access the components, instead of direct access via nodes[...], because the implementation does not store the first component in nodes[0] but rather as nodes[1] etc. nodes[0] is an order one node with dimension one only used to allow the first component to be an order three tensor.
_idx | index of the component to access. |
Definition at line 464 of file ttNetwork.cpp.
|
overridevirtual |
Returns a new copy of the network.
Reimplemented from xerus::TensorNetwork.
Definition at line 743 of file ttNetwork.cpp.
TTNetwork< true > xerus::TTNetwork< true >::identity | ( | const std::vector< size_t > & | _dimensions | ) |
Definition at line 195 of file ttNetwork.cpp.
|
static |
: Construct a TTOperator with the given dimensions representing the identity.
Only applicable for TTOperators, i.e. not for TTtensors
_dimensions | the dimensions of the new TTOperator. |
|
static |
: Returns a TTNetwork representation of the kronecker delta.
That is each entry is one if all indices are equal and zero otherwise. Note iff d=2 this coincides with identity.
_dimensions | the dimensions of the new tensor. |
Definition at line 224 of file ttNetwork.cpp.
void xerus::TTNetwork< isOperator >::move_core | ( | const size_t | _position, |
const bool | _keepRank = false |
||
) |
Move the core to a new position.
The core is moved to _position and the nodes between the old and the new position are orthogonalized accordingly. If the TTNetwork is not yet canonicalized it will be with _position as new corePosition.
_position | the new core position. |
_keepRank | by default a rank revealing QR decomposition is used to move the core and the ranks are reduced accordingly. If _keepRank is set the rank is not reduced, this is need e.g. in the ALS. |
Definition at line 582 of file ttNetwork.cpp.
|
protected |
Return the number of ranks, i.e. 0 for degree zero and degree()/N-1 otherwise.
Definition at line 363 of file ttNetwork.cpp.
|
static |
: Returns a the (rank one) TT-Tensor with all entries equal to one.
_dimensions | the dimensions of the new tensor. |
Definition at line 170 of file ttNetwork.cpp.
|
overridevirtual |
Calculates the entrywise multiplication of this TensorNetwork with a constant _factor.
Internally this only results in a change in the global factor.
_factor | the factor. |
Reimplemented from xerus::TensorNetwork.
Definition at line 860 of file ttNetwork.cpp.
TTNetwork< isOperator > & xerus::TTNetwork< isOperator >::operator+= | ( | const TTNetwork< isOperator > & | _other | ) |
Adds a given TTNetwork to this one.
To be well-defined it is required that the dimensions of this and _other coincide. The rank of the result are in general the entrywise sum of the ranks of this and _other.
_other | the TTNetwork to add. |
Definition at line 797 of file ttNetwork.cpp.
TTNetwork< isOperator > & xerus::TTNetwork< isOperator >::operator-= | ( | const TTNetwork< isOperator > & | _other | ) |
Subtracts the _other TTNetwork entrywise from this one.
To be well-defined it is required that the dimensions of this and _other coincide. The rank of the result are in general the entrywise sum of the ranks of this and _other.
_other | the Tensor to be subtracted to this one. |
Definition at line 851 of file ttNetwork.cpp.
|
overridevirtual |
Calculates the entrywise divison of this TensorNetwork by a constant _divisor.
Internally this only results in a change in the global factor.
_divisor | the divisor. |
Reimplemented from xerus::TensorNetwork.
Definition at line 872 of file ttNetwork.cpp.
|
default |
TTNetworks are default assignable.
|
default |
TTNetworks are default move-assignable.
|
inlinestatic |
Transforms a given TensorNetwork to a TTNetwork.
This is not yet implemented different from casting to Tensor and then using a HOSVD.
_network | The network to transform. |
_eps | the accuracy to be used in the transformation. Random constructs a TTNetwork with the given dimensions and ranks. |
The entries of the componend tensors are sampled independendly using the provided random generator and distribution.
_dimensions | the dimensions of the to be created TTNetwork. |
_ranks | the ranks of the to be created TTNetwork. |
_rnd | the random engine to be passed to the constructor of the component tensors. |
_dist | the random distribution to be passed to the constructor of the component tensors. |
Definition at line 129 of file ttNetwork.h.
|
inlinestatic |
Random constructs a TTNetwork with the given dimensions and ranks limited by the given rank.
The entries of the componend tensors are sampled independendly using the provided random generator and distribution.
_dimensions | the dimensions of the to be created TTNetwork. |
_rank | the maximal allowed rank. |
_rnd | the random engine to be passed to the constructor of the component tensors. |
_dist | the random distribution to be passed to the constructor of the component tensors. |
Definition at line 167 of file ttNetwork.h.
|
inlinestatic |
Random constructs a TTNetwork with the given dimensions and ranks.
The entries of the componend tensors are sampled independendly using the provided random generator and distribution. the singular values of all matricisations M(1..n,n+1..N) are fixed according to the given function a posteriori The callback function is assumed to take a reference to a diagonal tensor and modify it to represent the desired singular values.
Definition at line 179 of file ttNetwork.h.
size_t xerus::TTNetwork< isOperator >::rank | ( | const size_t | _i | ) | const |
Gets the rank of a specific egde of the TTNetwork.
_i | Position of the edge in question. |
Definition at line 728 of file ttNetwork.cpp.
std::vector< size_t > xerus::TTNetwork< isOperator >::ranks | ( | ) | const |
Gets the ranks of the TTNetwork.
Definition at line 717 of file ttNetwork.cpp.
|
static |
Reduces the given ranks to the maximal possible.
If a given rank is already smaller or equal it is left unchanged.
_ranks | the inital ranks to be reduced. |
_dimensions | the dimensions used to calculate the maximal ranks. |
Definition at line 370 of file ttNetwork.cpp.
|
overridevirtual |
Tests whether the network resembles that of a TTTensor and checks consistency with the underlying tensor objects.
Note that this will NOT check for orthogonality of canonicalized TTNetworks.
Reimplemented from xerus::TensorNetwork.
Definition at line 290 of file ttNetwork.cpp.
|
overridevirtual |
Resizes a specific mode of the TensorNetwork.
_mode | the mode to resize. |
_newDim | the new value that resized mode shall have. |
_cutPos | the position within the selected mode in front of which slates are inserted or removed. By default the current dimension, i.e new slates are added after the last current one and removed starting from the last one. |
Reimplemented from xerus::TensorNetwork.
Definition at line 438 of file ttNetwork.cpp.
void xerus::TTNetwork< isOperator >::round | ( | const std::vector< size_t > & | _maxRanks, |
const double | _eps = EPSILON |
||
) |
Reduce all ranks up to a given accuracy and maximal number.
_maxRanks | maximal allowed ranks. All current ranks that are larger than the given ones are reduced by truncation. |
_eps | the accuracy to use for truncation in the individual SVDs. |
Definition at line 644 of file ttNetwork.cpp.
void xerus::TTNetwork< isOperator >::round | ( | const size_t | _maxRank | ) |
Reduce all ranks to the given number.
_maxRank | maximal allowed rank. All current ranks that are larger than this are reduced by truncation. |
Definition at line 669 of file ttNetwork.cpp.
void xerus::TTNetwork< isOperator >::round | ( | const int | _maxRank | ) |
Reduce all ranks to the given number.
_maxRank | maximal allowed rank. All current ranks that are larger than this are reduced by truncation. |
Definition at line 675 of file ttNetwork.cpp.
void xerus::TTNetwork< isOperator >::round | ( | const value_t | _eps | ) |
Reduce all ranks up to a given accuracy.
_eps | the accuracy to use for truncation in the individual SVDs. |
Definition at line 682 of file ttNetwork.cpp.
void xerus::TTNetwork< isOperator >::set_component | ( | const size_t | _idx, |
Tensor | _T | ||
) |
Sets a specific component of the TT decomposition.
This function also takes care of adjusting the corresponding link dimensions and external dimensions if needed. However this might still leave the TTNetwork in an invalid if the rank is changed. In this case it is the callers responsibility to also update the other component tensors consistently to account for that rank change.
_idx | index of the component to set. |
_T | Tensor to use as the new component tensor. |
Definition at line 471 of file ttNetwork.cpp.
void xerus::TTNetwork< isOperator >::soft_threshold | ( | const double | _tau, |
const bool | _preventZero = false |
||
) |
Applies the soft threshholding operation to all ranks.
_tau | the soft threshholding parameter to be applied. I.e. all singular values are reduced to max(0, Lambda_ui - _tau). |
Definition at line 711 of file ttNetwork.cpp.
void xerus::TTNetwork< isOperator >::soft_threshold | ( | const std::vector< double > & | _taus, |
const bool | _preventZero = false |
||
) |
Applies soft threshholding operations to all ranks.
_taus | the soft threshholding parameters to be applied. I.e. all singular values of the j-th matrification are reduced to max(0, Lambda_ui - _tau[j]). |
Definition at line 688 of file ttNetwork.cpp.
|
inlineoverridevirtual |
(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 506 of file ttNetwork.h.
|
static |
bool xerus::TTNetwork< false >::specialized_contraction_f | ( | std::unique_ptr< internal::IndexedTensorMoveable< TensorNetwork >> & | , |
internal::IndexedTensorReadOnly< TensorNetwork > && | , | ||
internal::IndexedTensorReadOnly< TensorNetwork > && | |||
) |
Definition at line 883 of file ttNetwork.cpp.
bool xerus::TTNetwork< true >::specialized_contraction_f | ( | std::unique_ptr< internal::IndexedTensorMoveable< TensorNetwork >> & | _out, |
internal::IndexedTensorReadOnly< TensorNetwork > && | _me, | ||
internal::IndexedTensorReadOnly< TensorNetwork > && | _other | ||
) |
Definition at line 889 of file ttNetwork.cpp.
|
overridevirtual |
(Internal) Evaluates _other into _me. Requires that *this is the tensorObjectReadOnly of _me.
Reimplemented from xerus::TensorNetwork.
Definition at line 1064 of file ttNetwork.cpp.
|
inlineoverridevirtual |
(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 510 of file ttNetwork.h.
|
static |
Definition at line 982 of file ttNetwork.cpp.
|
inline |
Transpose the TTOperator.
Swaps all external indices to create the transposed operator.
Definition at line 443 of file ttNetwork.h.
void xerus::TTNetwork< isOperator >::use_dense_representations | ( | ) |
Converts all components to use dense representations.
Definition at line 450 of file ttNetwork.cpp.
bool xerus::TTNetwork< isOperator >::canonicalized |
Flag indicating whether the TTNetwork is canonicalized.
Definition at line 51 of file ttNetwork.h.
size_t xerus::TTNetwork< isOperator >::corePosition |
The position of the core.
If canonicalized is TRUE, corePosition gives the position of the core tensor. All components with smaller index are then left-orthogonalized and all components with larger index right-orthogonalized.
Definition at line 58 of file ttNetwork.h.
|
static |
The number of external links in each node, i.e. one for TTTensors and two for TTOperators.
Definition at line 48 of file ttNetwork.h.