TensorDimensionList.h
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2015 Benoit Steiner <benoit.steiner.goog@gmail.com>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #ifndef EIGEN_CXX11_TENSOR_TENSOR_DIMENSION_LIST_H
11 #define EIGEN_CXX11_TENSOR_TENSOR_DIMENSION_LIST_H
12 
13 namespace Eigen {
14 
25 template <typename Index, std::size_t Rank> struct DimensionList {
26  const Index operator[] (const Index i) const { return i; }
27 };
28 
29 namespace internal {
30 
31 template<typename Index, std::size_t Rank> struct array_size<DimensionList<Index, Rank> > {
32  static const size_t value = Rank;
33 };
34 template<typename Index, std::size_t Rank> struct array_size<const DimensionList<Index, Rank> > {
35  static const size_t value = Rank;
36 };
37 
38 template<DenseIndex n, typename Index, std::size_t Rank> const Index array_get(DimensionList<Index, Rank>&) {
39  return n;
40 }
41 template<DenseIndex n, typename Index, std::size_t Rank> const Index array_get(const DimensionList<Index, Rank>&) {
42  return n;
43 }
44 
45 
46 #if defined(EIGEN_HAS_CONSTEXPR)
47 template <typename Index, std::size_t Rank>
48 struct index_known_statically<DimensionList<Index, Rank> > {
49  constexpr bool operator() (const DenseIndex) const {
50  return true;
51  }
52 };
53 template <typename Index, std::size_t Rank>
54 struct index_known_statically<const DimensionList<Index, Rank> > {
55  constexpr bool operator() (const DenseIndex) const {
56  return true;
57  }
58 };
59 
60 template <typename Index, std::size_t Rank>
61 struct all_indices_known_statically<DimensionList<Index, Rank> > {
62  constexpr bool operator() () const {
63  return true;
64  }
65 };
66 template <typename Index, std::size_t Rank>
67 struct all_indices_known_statically<const DimensionList<Index, Rank> > {
68  constexpr bool operator() () const {
69  return true;
70  }
71 };
72 
73 template <typename Index, std::size_t Rank>
74 struct indices_statically_known_to_increase<DimensionList<Index, Rank> > {
75  constexpr bool operator() () const {
76  return true;
77  }
78 };
79 template <typename Index, std::size_t Rank>
80 struct indices_statically_known_to_increase<const DimensionList<Index, Rank> > {
81  constexpr bool operator() () const {
82  return true;
83  }
84 };
85 
86 template <typename Index, std::size_t Rank>
87 struct index_statically_eq<DimensionList<Index, Rank> > {
88  constexpr bool operator() (const DenseIndex i, const DenseIndex value) const {
89  return i == value;
90  }
91 };
92 template <typename Index, std::size_t Rank>
93 struct index_statically_eq<const DimensionList<Index, Rank> > {
94  constexpr bool operator() (const DenseIndex i, const DenseIndex value) const {
95  return i == value;
96  }
97 };
98 
99 template <typename Index, std::size_t Rank>
100 struct index_statically_ne<DimensionList<Index, Rank> > {
101  constexpr bool operator() (const DenseIndex i, const DenseIndex value) const {
102  return i != value;
103  }
104 };
105 template <typename Index, std::size_t Rank>
106 struct index_statically_ne<const DimensionList<Index, Rank> > {
107  constexpr bool operator() (const DenseIndex i, const DenseIndex value) const {
108  return i != value;
109  }
110 };
111 
112 template <typename Index, std::size_t Rank>
113 struct index_statically_gt<DimensionList<Index, Rank> > {
114  constexpr bool operator() (const DenseIndex i, const DenseIndex value) const {
115  return i > value;
116  }
117 };
118 template <typename Index, std::size_t Rank>
119 struct index_statically_gt<const DimensionList<Index, Rank> > {
120  constexpr bool operator() (const DenseIndex i, const DenseIndex value) const {
121  return i > value;
122  }
123 };
124 
125 template <typename Index, std::size_t Rank>
126 struct index_statically_lt<DimensionList<Index, Rank> > {
127  constexpr bool operator() (const DenseIndex i, const DenseIndex value) const {
128  return i < value;
129  }
130 };
131 template <typename Index, std::size_t Rank>
132 struct index_statically_lt<const DimensionList<Index, Rank> > {
133  constexpr bool operator() (const DenseIndex i, const DenseIndex value) const {
134  return i < value;
135  }
136 };
137 
138 #else
139 template <typename Index, std::size_t Rank>
140 struct index_known_statically<DimensionList<Index, Rank> > {
141  EIGEN_ALWAYS_INLINE bool operator() (const DenseIndex) const {
142  return true;
143  }
144 };
145 template <typename Index, std::size_t Rank>
146 struct index_known_statically<const DimensionList<Index, Rank> > {
147  EIGEN_ALWAYS_INLINE bool operator() (const DenseIndex) const {
148  return true;
149  }
150 };
151 
152 template <typename Index, std::size_t Rank>
153 struct all_indices_known_statically<DimensionList<Index, Rank> > {
154  EIGEN_ALWAYS_INLINE bool operator() () const {
155  return true;
156  }
157 };
158 template <typename Index, std::size_t Rank>
159 struct all_indices_known_statically<const DimensionList<Index, Rank> > {
160  EIGEN_ALWAYS_INLINE bool operator() () const {
161  return true;
162  }
163 };
164 
165 template <typename Index, std::size_t Rank>
166 struct indices_statically_known_to_increase<DimensionList<Index, Rank> > {
167  EIGEN_ALWAYS_INLINE bool operator() () const {
168  return true;
169  }
170 };
171 template <typename Index, std::size_t Rank>
172 struct indices_statically_known_to_increase<const DimensionList<Index, Rank> > {
173  EIGEN_ALWAYS_INLINE bool operator() () const {
174  return true;
175  }
176 };
177 
178 template <typename Index, std::size_t Rank>
179 struct index_statically_eq<DimensionList<Index, Rank> > {
180  EIGEN_ALWAYS_INLINE bool operator() (const DenseIndex, const DenseIndex) const {
181  return false;
182  }
183 };
184 template <typename Index, std::size_t Rank>
185 struct index_statically_eq<const DimensionList<Index, Rank> > {
186  EIGEN_ALWAYS_INLINE bool operator() (const DenseIndex, const DenseIndex) const {
187  return false;
188  }
189 };
190 
191 template <typename Index, std::size_t Rank>
192 struct index_statically_ne<DimensionList<Index, Rank> > {
193  EIGEN_ALWAYS_INLINE bool operator() (const DenseIndex, const DenseIndex) const {
194  return false;
195  }
196 };
197 template <typename Index, std::size_t Rank>
198 struct index_statically_ne<const DimensionList<Index, Rank> > {
199  EIGEN_ALWAYS_INLINE bool operator() (const DenseIndex, const DenseIndex) const {
200  return false;
201  }
202 };
203 
204 template <typename Index, std::size_t Rank>
205 struct index_statically_gt<DimensionList<Index, Rank> > {
206  EIGEN_ALWAYS_INLINE bool operator() (const DenseIndex, const DenseIndex) const {
207  return false;
208  }
209 };
210 template <typename Index, std::size_t Rank>
211 struct index_statically_gt<const DimensionList<Index, Rank> > {
212  EIGEN_ALWAYS_INLINE bool operator() (const DenseIndex, const DenseIndex) const {
213  return false;
214  }
215 };
216 
217 template <typename Index, std::size_t Rank>
218 struct index_statically_lt<DimensionList<Index, Rank> > {
219  EIGEN_ALWAYS_INLINE bool operator() (const DenseIndex, const DenseIndex) const {
220  return false;
221  }
222 };
223 template <typename Index, std::size_t Rank>
224 struct index_statically_lt<const DimensionList<Index, Rank> > {
225  EIGEN_ALWAYS_INLINE bool operator() (const DenseIndex, const DenseIndex) const {
226  return false;
227  }
228 };
229 #endif
230 
231 } // end namespace internal
232 } // end namespace Eigen
233 
234 
235 #endif // EIGEN_CXX11_TENSOR_TENSOR_DIMENSION_LIST_H
Namespace containing all symbols from the Eigen library.
Definition: CXX11Meta.h:13