xerus
a general purpose tensor library
indexedTensorReadOnly.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 "basic.h"
28 #include <vector>
29 
30 namespace xerus {
31  // Necessary forward declaritons
32  class Index;
33  class Tensor;
34  class TensorNetwork;
35 
36  namespace internal {
37  // Necessary forward declaritons
38  template<class tensor_type> class IndexedTensorWritable;
39  template<class tensor_type> class IndexedTensorMoveable;
40  template<class tensor_type> class IndexedTensor;
41 
42 
48  template<class tensor_type>
49  class IndexedTensorReadOnly {
50  public:
52  const tensor_type* tensorObjectReadOnly;
53 
55  std::vector<Index> indices;
56 
58  bool indicesAssigned = false;
59 
60  /*- - - - - - - - - - - - - - - - - - - - - - - - - - Constructors - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
61 
63  IndexedTensorReadOnly() = delete;
64 
66  IndexedTensorReadOnly(const IndexedTensorReadOnly& _other ) = delete;
67 
70 
72  IndexedTensorReadOnly(const tensor_type* const _tensorObjectReadOnly, std::vector<Index> _indices);
73 
75  virtual ~IndexedTensorReadOnly();
76 
77 
78  /*- - - - - - - - - - - - - - - - - - - - - - - - - - Standard operators - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
79 
81  void operator=(const IndexedTensorReadOnly& _rhs) = delete;
82 
84  void operator=( IndexedTensorReadOnly&& _rhs) = delete;
85 
86 
87  /*- - - - - - - - - - - - - - - - - - - - - - - - - - Others - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
88 
90  explicit operator value_t() const;
91 
93  bool uses_tensor(const tensor_type* _otherTensor) const;
94 
96  size_t degree() const;
97 
99  void assign_indices();
100 
102  void assign_indices(const size_t _degree);
103 
106 
108  std::vector<size_t> get_evaluated_dimensions(const std::vector<Index>& _indexOrder);
109  };
110 
111 
112  /*- - - - - - - - - - - - - - - - - - - - - - - - - - Aritmetic Operators - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
113 
114  template<class tensor_type>
116 
117  template<class tensor_type>
119 
120  template<class tensor_type>
122 
127 
132 
137 
138 
141 
146 
147 
148  /*- - - - - - - - - - - - - - - - - - - - - - - - - - Higher functions - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
149 
150 
151 
153  template<class tensor_type>
155 
158 
159  size_t get_eval_degree(const std::vector<Index>& _indices);
160  }
161 
162 
164 
165 
167 }
Internal representation of an read and write and moveable indexed Tensor or TensorNetwork.
void operator=(const IndexedTensorReadOnly &_rhs)=delete
: IndexedTensorReadOnly cannot be assigned as they are read only.
IndexedTensorMoveable< Tensor > operator+(IndexedTensorReadOnly< Tensor > &&_lhs, IndexedTensorReadOnly< Tensor > &&_rhs)
Internal representation of an readable indexed Tensor or TensorNetwork.
The main namespace of xerus.
Definition: basic.h:37
void assign_index_dimensions()
Assignes the indices using the current tensorObejct.
virtual ~IndexedTensorReadOnly()
Destructor must be virtual.
void solve(internal::IndexedTensorWritable< Tensor > &&_x, internal::IndexedTensorReadOnly< Tensor > &&_A, internal::IndexedTensorReadOnly< Tensor > &&_b)
IndexedTensorMoveable< tensor_type > operator/(IndexedTensorMoveable< tensor_type > &&_tensor, const value_t _divisor)
Internal representation of an readable and writeable indexed Tensor or TensorNetwork.
Definition: indexedTensor.h:37
std::vector< Index > indices
Vector of the associates indices.
size_t get_eval_degree(const std::vector< Index > &_indices)
IndexedTensorMoveable< Tensor > operator-(IndexedTensorReadOnly< Tensor > &&_lhs, IndexedTensorReadOnly< Tensor > &&_rhs)
size_t degree() const
Returns the degree of the associated tensorObejct.
value_t frob_norm(const IndexedTensorReadOnly< tensor_type > &_idxTensor)
Returns the frobenious norm of the associated tensorObejct.
Abstract internal representation of an read and writeable indexed Tensor or TensorNetwork.
bool uses_tensor(const tensor_type *_otherTensor) const
Checks whether _otherTensor is the tensorObejct of this IndexTensor.
Header file for shorthand notations that are xerus specific but used throughout the library...
double value_t
The type of values to be used by xerus.
Definition: basic.h:43
void assign_indices()
Assignes the indices using the degree of the tensorObejct.
value_t one_norm(const IndexedTensorReadOnly< Tensor > &_idxTensor)
Returns the one-norm of the associated tensor Obejct.
std::vector< size_t > get_evaluated_dimensions(const std::vector< Index > &_indexOrder)
Returns the dimensionTuple the evaluation of this IndexedTensor to the given indices would have...
const tensor_type * tensorObjectReadOnly
Pointer to the associated Tensor/TensorNetwork object.
IndexedTensorReadOnly()=delete
There is no usefull default constructor.
IndexedTensorMoveable< tensor_type > operator*(const value_t _factor, IndexedTensorMoveable< tensor_type > &&_tensor)
bool indicesAssigned
Flag indicating whether the indices are assinged.