xerus
a general purpose tensor library
indexedTensorMoveable.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 "indexedTensorWritable.h"
28 #include <type_traits>
29 
30 namespace xerus {
31  namespace internal {
37  template<class tensor_type>
38  class IndexedTensorMoveable final : public IndexedTensorWritable<tensor_type> {
39  public:
42 
44  IndexedTensorMoveable(const IndexedTensorMoveable &_other ) = delete;
45 
47  IndexedTensorMoveable( IndexedTensorMoveable &&_other ) noexcept;
48 
50  IndexedTensorMoveable(tensor_type* const _tensorObject, const std::vector<Index>& _indices);
51 
53  IndexedTensorMoveable(tensor_type* const _tensorObject, std::vector<Index>&& _indices);
54 
57 
59  template<class X = tensor_type, typename std::enable_if<std::is_base_of<Tensor, typename std::decay<X>::type>::value, int>::type = 0>
61 
63  #if __GNUC__ > 4
64  template<class X = tensor_type, typename std::enable_if<std::is_base_of<TensorNetwork, typename std::decay<X>::type>::value, int>::type = 0>
65  #else
66  template<class X = tensor_type>
67  #endif
69 
70  #if __GNUC__ > 4
71  template<class X = tensor_type, typename std::enable_if<std::is_base_of<TensorNetwork, typename std::decay<X>::type>::value, int>::type = 0>
72  #else
73  template<class X = tensor_type>
74  #endif
76  };
77 
78 
79  /*- - - - - - - - - - - - - - - - - - - - - - - - - - Aritmetic Operators - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
80 
81  template<class tensor_type>
83  IndexedTensorMoveable<tensor_type> result(std::move(_tensor));
84  *result.tensorObject *= _factor;
85  return result;
86  }
87 
88  template<class tensor_type>
90  return operator*(_factor, std::move(_tensor));
91  }
92 
93  template<class tensor_type>
95  IndexedTensorMoveable<tensor_type> result(std::move(_tensor));
96  *result.tensorObject /= _divisor;
97  return result;
98  }
99  }
100 }
Internal representation of an read and write and moveable indexed Tensor or TensorNetwork.
Internal representation of an readable indexed Tensor or TensorNetwork.
IndexedTensorMoveable()
Creates an empty indexed Tensor, should only be used internally.
The main namespace of xerus.
Definition: basic.h:37
STL namespace.
IndexedTensorMoveable(IndexedTensorReadOnly< Tensor > &_other)
IndexedTensorMoveable< tensor_type > operator/(IndexedTensorMoveable< tensor_type > &&_tensor, const value_t _divisor)
tensor_type * tensorObject
Non-const pointer to the tensor object.
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
Header file for the IndexedTensorWritable class.
IndexedTensorMoveable< tensor_type > operator*(const value_t _factor, IndexedTensorMoveable< tensor_type > &&_tensor)