xerus
a general purpose tensor library
ttStack.h
Go to the documentation of this file.
1 // Xerus - A General Purpose Tensor Library
2 // Copyright (C) 2014-2017 Benjamin Huber and Sebastian Wolf.
3 //
4 // Xerus is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as published
6 // by the Free Software Foundation, either version 3 of the License,
7 // or (at your option) any later version.
8 //
9 // Xerus is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
13 //
14 // You should have received a copy of the GNU Affero General Public License
15 // along with Xerus. If not, see <http://www.gnu.org/licenses/>.
16 //
17 // For further information on Xerus visit https://libXerus.org
18 // or contact us at contact@libXerus.org.
19 
25 #pragma once
26 
27 #include "misc/check.h"
28 
29 #include "tensorNetwork.h"
30 #include "indexedTensorMoveable.h"
31 
32 namespace xerus {
33  template<bool isOperator> class TTNetwork;
34 
35  namespace internal {
36  template<bool isOperator>
38  class TTStack final : public TensorNetwork {
39  public:
41  static constexpr const size_t N = isOperator?2:1;
42 
44 
45  const size_t futureCorePosition;
46 
47  explicit TTStack(const bool _canno, const size_t _corePos = 0);
48 
49  TTStack(const TTStack& _other) = default;
50 
51  TTStack( TTStack&& _other) = default;
52 
53  virtual TensorNetwork* get_copy() const override;
54 
55  TTStack& operator= (const TTStack& _other) = delete;
56 
57  TTStack& operator= ( TTStack&& _other) = delete;
58 
59  explicit operator TTNetwork<isOperator>();
60 
61  virtual void operator*=(const value_t _factor) override;
62 
63  virtual void operator/=(const value_t _divisor) override;
64 
65 
66  /*- - - - - - - - - - - - - - - - - - - - - - - - - - Operator specializations - - - - - - - - - - - - - - - - - - - - - - - - - - */
68 
70 
72 
74 
75  virtual value_t frob_norm() const override;
76  };
77  }
78 }
Header file for CHECK and REQUIRE macros.
Internal representation of an read and write and moveable indexed Tensor or TensorNetwork.
const bool cannonicalization_required
Definition: ttStack.h:43
static void contract_stack(IndexedTensorWritable< TensorNetwork > &&_me)
Definition: ttStack.cpp:197
Header file for the IndexedTensorMoveable class.
Very general class used to represent arbitary tensor networks.
Definition: tensorNetwork.h:42
Internal representation of an readable indexed Tensor or TensorNetwork.
Specialized TensorNetwork class used to represent TTTensor and TToperators.
The main namespace of xerus.
Definition: basic.h:37
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.
Definition: ttStack.cpp:325
virtual void specialized_evaluation(IndexedTensorWritable< TensorNetwork > &&, IndexedTensorReadOnly< TensorNetwork > &&) override
(Internal) Evaluates _other into _me. Requires that *this is the tensorObjectReadOnly of _me...
Definition: ttStack.cpp:313
const size_t futureCorePosition
Definition: ttStack.h:45
Abstract internal representation of an read and writeable indexed Tensor or TensorNetwork.
double value_t
The type of values to be used by xerus.
Definition: basic.h:43
virtual void operator/=(const value_t _divisor) override
Performs the entrywise divison by a constant _divisor.
Definition: ttStack.cpp:190
TTStack & operator=(const TTStack &_other)=delete
virtual void operator*=(const value_t _factor) override
Performs the entrywise multiplication with a constant _factor.
Definition: ttStack.cpp:176
static constexpr const size_t N
The number of external links in each node, i.e. one for TTTensors and two for TTOperators.
Definition: ttStack.h:41
virtual value_t frob_norm() const override
Calculates the frobenious norm of the TensorNetwork.
Definition: ttStack.cpp:331
virtual TensorNetwork * get_copy() const override
Returns a new copy of the network.
Definition: ttStack.cpp:42
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...
Definition: ttStack.cpp:319
Header file for the TensorNetwork class.
Internal class used to represent stacks of (possibly multiply) applications of TTOperators to either ...
Definition: ttStack.h:38
TTStack(const bool _canno, const size_t _corePos=0)
Definition: ttStack.cpp:38