$darkmode
Eigen-unsupported  5.0.1-dev
TensorIndexList.h
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2014 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_INDEX_LIST_H
11 #define EIGEN_CXX11_TENSOR_TENSOR_INDEX_LIST_H
12 
13 // IWYU pragma: private
14 #include "./InternalHeaderCheck.h"
15 
16 namespace Eigen {
17 
18 template <Index n>
19 struct type2index {
20  static constexpr Index value = n;
21  EIGEN_DEVICE_FUNC constexpr operator Index() const { return n; }
22  EIGEN_DEVICE_FUNC void set(Index val) { eigen_assert(val == n); }
23 };
24 
25 // This can be used with IndexPairList to get compile-time constant pairs,
26 // such as IndexPairList<type2indexpair<1,2>, type2indexpair<3,4>>().
27 template <Index f, Index s>
28 struct type2indexpair {
29  static constexpr Index first = f;
30  static constexpr Index second = s;
31 
32  constexpr EIGEN_DEVICE_FUNC operator IndexPair<Index>() const { return IndexPair<Index>(f, s); }
33 
34  EIGEN_DEVICE_FUNC void set(const IndexPair<Index>& val) {
35  eigen_assert(val.first == f);
36  eigen_assert(val.second == s);
37  }
38 };
39 
40 template <Index n>
41 struct NumTraits<type2index<n>> {
42  typedef Index Real;
43  enum { IsComplex = 0, RequireInitialization = false, ReadCost = 1, AddCost = 1, MulCost = 1 };
44 
45  EIGEN_DEVICE_FUNC static constexpr EIGEN_STRONG_INLINE Real epsilon() { return 0; }
46  EIGEN_DEVICE_FUNC static constexpr EIGEN_STRONG_INLINE Real dummy_precision() { return 0; }
47  EIGEN_DEVICE_FUNC static constexpr EIGEN_STRONG_INLINE Real highest() { return n; }
48  EIGEN_DEVICE_FUNC static constexpr EIGEN_STRONG_INLINE Real lowest() { return n; }
49 };
50 
51 namespace internal {
52 template <typename T>
53 EIGEN_DEVICE_FUNC void update_value(T& val, Index new_val) {
54  val = internal::convert_index<T>(new_val);
55 }
56 template <Index n>
57 EIGEN_DEVICE_FUNC void update_value(type2index<n>& val, Index new_val) {
58  val.set(new_val);
59 }
60 
61 template <typename T>
62 EIGEN_DEVICE_FUNC void update_value(T& val, IndexPair<Index> new_val) {
63  val = new_val;
64 }
65 template <Index f, Index s>
66 EIGEN_DEVICE_FUNC void update_value(type2indexpair<f, s>& val, IndexPair<Index> new_val) {
67  val.set(new_val);
68 }
69 
70 template <typename T>
71 struct is_compile_time_constant {
72  static constexpr bool value = false;
73 };
74 
75 template <Index idx>
76 struct is_compile_time_constant<type2index<idx>> {
77  static constexpr bool value = true;
78 };
79 template <Index idx>
80 struct is_compile_time_constant<const type2index<idx>> {
81  static constexpr bool value = true;
82 };
83 template <Index idx>
84 struct is_compile_time_constant<type2index<idx>&> {
85  static constexpr bool value = true;
86 };
87 template <Index idx>
88 struct is_compile_time_constant<const type2index<idx>&> {
89  static constexpr bool value = true;
90 };
91 
92 template <Index f, Index s>
93 struct is_compile_time_constant<type2indexpair<f, s>> {
94  static constexpr bool value = true;
95 };
96 template <Index f, Index s>
97 struct is_compile_time_constant<const type2indexpair<f, s>> {
98  static constexpr bool value = true;
99 };
100 template <Index f, Index s>
101 struct is_compile_time_constant<type2indexpair<f, s>&> {
102  static constexpr bool value = true;
103 };
104 template <Index f, Index s>
105 struct is_compile_time_constant<const type2indexpair<f, s>&> {
106  static constexpr bool value = true;
107 };
108 
109 template <typename... T>
110 struct IndexTuple;
111 
112 template <typename T, typename... O>
113 struct IndexTuple<T, O...> {
114  EIGEN_DEVICE_FUNC constexpr IndexTuple() : head(), others() {}
115  EIGEN_DEVICE_FUNC constexpr IndexTuple(const T& v, const O... o) : head(v), others(o...) {}
116 
117  static constexpr int count = 1 + sizeof...(O);
118  T head;
119  IndexTuple<O...> others;
120  typedef T Head;
121  typedef IndexTuple<O...> Other;
122 };
123 
124 template <typename T>
125 struct IndexTuple<T> {
126  EIGEN_DEVICE_FUNC constexpr IndexTuple() : head() {}
127  EIGEN_DEVICE_FUNC constexpr IndexTuple(const T& v) : head(v) {}
128 
129  constexpr static int count = 1;
130  T head;
131  typedef T Head;
132 };
133 
134 template <int N, typename... T>
135 struct IndexTupleExtractor;
136 
137 template <int N, typename T, typename... O>
138 struct IndexTupleExtractor<N, T, O...> {
139  typedef typename IndexTupleExtractor<N - 1, O...>::ValType ValType;
140 
141  EIGEN_DEVICE_FUNC static constexpr ValType& get_val(IndexTuple<T, O...>& val) {
142  return IndexTupleExtractor<N - 1, O...>::get_val(val.others);
143  }
144 
145  EIGEN_DEVICE_FUNC static constexpr const ValType& get_val(const IndexTuple<T, O...>& val) {
146  return IndexTupleExtractor<N - 1, O...>::get_val(val.others);
147  }
148  template <typename V>
149  EIGEN_DEVICE_FUNC static void set_val(IndexTuple<T, O...>& val, V& new_val) {
150  IndexTupleExtractor<N - 1, O...>::set_val(val.others, new_val);
151  }
152 };
153 
154 template <typename T, typename... O>
155 struct IndexTupleExtractor<0, T, O...> {
156  typedef T ValType;
157 
158  EIGEN_DEVICE_FUNC static constexpr ValType& get_val(IndexTuple<T, O...>& val) { return val.head; }
159  EIGEN_DEVICE_FUNC static constexpr const ValType& get_val(const IndexTuple<T, O...>& val) { return val.head; }
160  template <typename V>
161  EIGEN_DEVICE_FUNC static void set_val(IndexTuple<T, O...>& val, V& new_val) {
162  val.head = new_val;
163  }
164 };
165 
166 template <int N, typename T, typename... O>
167 EIGEN_DEVICE_FUNC constexpr typename IndexTupleExtractor<N, T, O...>::ValType& array_get(IndexTuple<T, O...>& tuple) {
168  return IndexTupleExtractor<N, T, O...>::get_val(tuple);
169 }
170 template <int N, typename T, typename... O>
171 EIGEN_DEVICE_FUNC constexpr const typename IndexTupleExtractor<N, T, O...>::ValType& array_get(
172  const IndexTuple<T, O...>& tuple) {
173  return IndexTupleExtractor<N, T, O...>::get_val(tuple);
174 }
175 template <typename T, typename... O>
176 struct array_size<IndexTuple<T, O...>> {
177  static constexpr size_t value = IndexTuple<T, O...>::count;
178 };
179 template <typename T, typename... O>
180 struct array_size<const IndexTuple<T, O...>> {
181  static constexpr size_t value = IndexTuple<T, O...>::count;
182 };
183 
184 template <Index Idx, typename ValueT>
185 struct tuple_coeff {
186  template <typename... T>
187  EIGEN_DEVICE_FUNC static constexpr ValueT get(const Index i, const IndexTuple<T...>& t) {
188  // return array_get<Idx>(t) * (i == Idx) + tuple_coeff<Idx-1>::get(i, t) * (i != Idx);
189  return (i == Idx ? array_get<Idx>(t) : tuple_coeff<Idx - 1, ValueT>::get(i, t));
190  }
191  template <typename... T>
192  EIGEN_DEVICE_FUNC static void set(const Index i, IndexTuple<T...>& t, const ValueT& value) {
193  if (i == Idx) {
194  update_value(array_get<Idx>(t), value);
195  } else {
196  tuple_coeff<Idx - 1, ValueT>::set(i, t, value);
197  }
198  }
199 
200  template <typename... T>
201  EIGEN_DEVICE_FUNC static constexpr bool value_known_statically(const Index i, const IndexTuple<T...>& t) {
202  return ((i == Idx) && is_compile_time_constant<typename IndexTupleExtractor<Idx, T...>::ValType>::value) ||
203  tuple_coeff<Idx - 1, ValueT>::value_known_statically(i, t);
204  }
205 
206  template <typename... T>
207  EIGEN_DEVICE_FUNC static constexpr bool values_up_to_known_statically(const IndexTuple<T...>& t) {
208  return is_compile_time_constant<typename IndexTupleExtractor<Idx, T...>::ValType>::value &&
209  tuple_coeff<Idx - 1, ValueT>::values_up_to_known_statically(t);
210  }
211 
212  template <typename... T>
213  EIGEN_DEVICE_FUNC static constexpr bool values_up_to_statically_known_to_increase(const IndexTuple<T...>& t) {
214  return is_compile_time_constant<typename IndexTupleExtractor<Idx, T...>::ValType>::value &&
215  is_compile_time_constant<typename IndexTupleExtractor<Idx, T...>::ValType>::value &&
216  array_get<Idx>(t) > array_get<Idx - 1>(t) &&
217  tuple_coeff<Idx - 1, ValueT>::values_up_to_statically_known_to_increase(t);
218  }
219 };
220 
221 template <typename ValueT>
222 struct tuple_coeff<0, ValueT> {
223  template <typename... T>
224  EIGEN_DEVICE_FUNC static constexpr ValueT get(const Index /*i*/, const IndexTuple<T...>& t) {
225  // eigen_assert (i == 0); // gcc fails to compile assertions in constexpr
226  return array_get<0>(t) /* * (i == 0)*/;
227  }
228  template <typename... T>
229  EIGEN_DEVICE_FUNC static void set(const Index i, IndexTuple<T...>& t, const ValueT value) {
230  eigen_assert(i == 0);
231  update_value(array_get<0>(t), value);
232  }
233  template <typename... T>
234  EIGEN_DEVICE_FUNC static constexpr bool value_known_statically(const Index i, const IndexTuple<T...>&) {
235  return is_compile_time_constant<typename IndexTupleExtractor<0, T...>::ValType>::value && (i == 0);
236  }
237 
238  template <typename... T>
239  EIGEN_DEVICE_FUNC static constexpr bool values_up_to_known_statically(const IndexTuple<T...>&) {
240  return is_compile_time_constant<typename IndexTupleExtractor<0, T...>::ValType>::value;
241  }
242 
243  template <typename... T>
244  EIGEN_DEVICE_FUNC static constexpr bool values_up_to_statically_known_to_increase(const IndexTuple<T...>&) {
245  return true;
246  }
247 };
248 } // namespace internal
249 
269 template <typename FirstType, typename... OtherTypes>
270 struct IndexList : internal::IndexTuple<FirstType, OtherTypes...> {
271  EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC constexpr Index operator[](const Index i) const {
272  return internal::tuple_coeff<internal::array_size<internal::IndexTuple<FirstType, OtherTypes...>>::value - 1,
273  Index>::get(i, *this);
274  }
275  EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC constexpr Index get(const Index i) const {
276  return internal::tuple_coeff<internal::array_size<internal::IndexTuple<FirstType, OtherTypes...>>::value - 1,
277  Index>::get(i, *this);
278  }
279  EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC void set(const Index i, const Index value) {
280  return internal::tuple_coeff<internal::array_size<internal::IndexTuple<FirstType, OtherTypes...>>::value - 1,
281  Index>::set(i, *this, value);
282  }
283 
284  EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC constexpr std::size_t size() const { return 1 + sizeof...(OtherTypes); };
285 
286  EIGEN_DEVICE_FUNC constexpr IndexList(const internal::IndexTuple<FirstType, OtherTypes...>& other)
287  : internal::IndexTuple<FirstType, OtherTypes...>(other) {}
288  EIGEN_DEVICE_FUNC constexpr IndexList(FirstType& first, OtherTypes... other)
289  : internal::IndexTuple<FirstType, OtherTypes...>(first, other...) {}
290  EIGEN_DEVICE_FUNC constexpr IndexList() : internal::IndexTuple<FirstType, OtherTypes...>() {}
291 
292  EIGEN_DEVICE_FUNC constexpr bool value_known_statically(const Index i) const {
293  return internal::tuple_coeff<internal::array_size<internal::IndexTuple<FirstType, OtherTypes...>>::value - 1,
294  Index>::value_known_statically(i, *this);
295  }
296  EIGEN_DEVICE_FUNC constexpr bool all_values_known_statically() const {
297  return internal::tuple_coeff<internal::array_size<internal::IndexTuple<FirstType, OtherTypes...>>::value - 1,
298  Index>::values_up_to_known_statically(*this);
299  }
300 
301  EIGEN_DEVICE_FUNC constexpr bool values_statically_known_to_increase() const {
302  return internal::tuple_coeff<internal::array_size<internal::IndexTuple<FirstType, OtherTypes...>>::value - 1,
303  Index>::values_up_to_statically_known_to_increase(*this);
304  }
305 };
306 
307 template <typename FirstType, typename... OtherTypes>
308 std::ostream& operator<<(std::ostream& os, const IndexList<FirstType, OtherTypes...>& dims) {
309  os << "[";
310  for (size_t i = 0; i < 1 + sizeof...(OtherTypes); ++i) {
311  if (i > 0) os << ", ";
312  os << dims[i];
313  }
314  os << "]";
315  return os;
316 }
317 
318 template <typename FirstType, typename... OtherTypes>
319 constexpr IndexList<FirstType, OtherTypes...> make_index_list(FirstType val1, OtherTypes... other_vals) {
320  return IndexList<FirstType, OtherTypes...>(val1, other_vals...);
321 }
322 
323 template <typename FirstType, typename... OtherTypes>
324 struct IndexPairList : internal::IndexTuple<FirstType, OtherTypes...> {
325  EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC constexpr IndexPair<Index> operator[](const Index i) const {
326  return internal::tuple_coeff<internal::array_size<internal::IndexTuple<FirstType, OtherTypes...>>::value - 1,
327  IndexPair<Index>>::get(i, *this);
328  }
329  EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC void set(const Index i, const IndexPair<Index> value) {
330  return internal::tuple_coeff<internal::array_size<internal::IndexTuple<FirstType, OtherTypes...>>::value - 1,
331  IndexPair<Index>>::set(i, *this, value);
332  }
333 
334  EIGEN_DEVICE_FUNC constexpr IndexPairList(const internal::IndexTuple<FirstType, OtherTypes...>& other)
335  : internal::IndexTuple<FirstType, OtherTypes...>(other) {}
336  EIGEN_DEVICE_FUNC constexpr IndexPairList() : internal::IndexTuple<FirstType, OtherTypes...>() {}
337 
338  EIGEN_DEVICE_FUNC constexpr bool value_known_statically(const Index i) const {
339  return internal::tuple_coeff<internal::array_size<internal::IndexTuple<FirstType, OtherTypes...>>::value - 1,
340  Index>::value_known_statically(i, *this);
341  }
342 };
343 
344 namespace internal {
345 
346 template <typename FirstType, typename... OtherTypes>
347 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index array_prod(const IndexList<FirstType, OtherTypes...>& sizes) {
348  Index result = 1;
349  EIGEN_UNROLL_LOOP
350  for (size_t i = 0; i < array_size<IndexList<FirstType, OtherTypes...>>::value; ++i) {
351  result *= sizes[i];
352  }
353  return result;
354 }
355 
356 template <typename FirstType, typename... OtherTypes>
357 struct array_size<IndexList<FirstType, OtherTypes...>> {
358  static const size_t value = array_size<IndexTuple<FirstType, OtherTypes...>>::value;
359 };
360 template <typename FirstType, typename... OtherTypes>
361 struct array_size<const IndexList<FirstType, OtherTypes...>> {
362  static const size_t value = array_size<IndexTuple<FirstType, OtherTypes...>>::value;
363 };
364 
365 template <typename FirstType, typename... OtherTypes>
366 struct array_size<IndexPairList<FirstType, OtherTypes...>> {
367  static const size_t value = 1 + sizeof...(OtherTypes);
368 };
369 template <typename FirstType, typename... OtherTypes>
370 struct array_size<const IndexPairList<FirstType, OtherTypes...>> {
371  static const size_t value = 1 + sizeof...(OtherTypes);
372 };
373 
374 template <Index N, typename FirstType, typename... OtherTypes>
375 EIGEN_DEVICE_FUNC constexpr Index array_get(IndexList<FirstType, OtherTypes...>& a) {
376  return IndexTupleExtractor<N, FirstType, OtherTypes...>::get_val(a);
377 }
378 template <Index N, typename FirstType, typename... OtherTypes>
379 EIGEN_DEVICE_FUNC constexpr Index array_get(const IndexList<FirstType, OtherTypes...>& a) {
380  return IndexTupleExtractor<N, FirstType, OtherTypes...>::get_val(a);
381 }
382 
383 template <typename T>
384 struct index_known_statically_impl {
385  EIGEN_DEVICE_FUNC static constexpr bool run(const Index) { return false; }
386 };
387 
388 template <typename FirstType, typename... OtherTypes>
389 struct index_known_statically_impl<IndexList<FirstType, OtherTypes...>> {
390  EIGEN_DEVICE_FUNC static constexpr bool run(const Index i) {
391  return IndexList<FirstType, OtherTypes...>().value_known_statically(i);
392  }
393 };
394 
395 template <typename FirstType, typename... OtherTypes>
396 struct index_known_statically_impl<const IndexList<FirstType, OtherTypes...>> {
397  EIGEN_DEVICE_FUNC static constexpr bool run(const Index i) {
398  return IndexList<FirstType, OtherTypes...>().value_known_statically(i);
399  }
400 };
401 
402 template <typename T>
403 struct all_indices_known_statically_impl {
404  static constexpr bool run() { return false; }
405 };
406 
407 template <typename FirstType, typename... OtherTypes>
408 struct all_indices_known_statically_impl<IndexList<FirstType, OtherTypes...>> {
409  EIGEN_DEVICE_FUNC static constexpr bool run() {
410  return IndexList<FirstType, OtherTypes...>().all_values_known_statically();
411  }
412 };
413 
414 template <typename FirstType, typename... OtherTypes>
415 struct all_indices_known_statically_impl<const IndexList<FirstType, OtherTypes...>> {
416  EIGEN_DEVICE_FUNC static constexpr bool run() {
417  return IndexList<FirstType, OtherTypes...>().all_values_known_statically();
418  }
419 };
420 
421 template <typename T>
422 struct indices_statically_known_to_increase_impl {
423  EIGEN_DEVICE_FUNC static constexpr bool run() { return false; }
424 };
425 
426 template <typename FirstType, typename... OtherTypes>
427 struct indices_statically_known_to_increase_impl<IndexList<FirstType, OtherTypes...>> {
428  EIGEN_DEVICE_FUNC static constexpr bool run() {
429  return Eigen::IndexList<FirstType, OtherTypes...>().values_statically_known_to_increase();
430  }
431 };
432 
433 template <typename FirstType, typename... OtherTypes>
434 struct indices_statically_known_to_increase_impl<const IndexList<FirstType, OtherTypes...>> {
435  EIGEN_DEVICE_FUNC static constexpr bool run() {
436  return Eigen::IndexList<FirstType, OtherTypes...>().values_statically_known_to_increase();
437  }
438 };
439 
440 template <typename Tx>
441 struct index_statically_eq_impl {
442  EIGEN_DEVICE_FUNC static constexpr bool run(Index, Index) { return false; }
443 };
444 
445 template <typename FirstType, typename... OtherTypes>
446 struct index_statically_eq_impl<IndexList<FirstType, OtherTypes...>> {
447  EIGEN_DEVICE_FUNC static constexpr bool run(const Index i, const Index value) {
448  return IndexList<FirstType, OtherTypes...>().value_known_statically(i) &&
449  (IndexList<FirstType, OtherTypes...>().get(i) == value);
450  }
451 };
452 
453 template <typename FirstType, typename... OtherTypes>
454 struct index_statically_eq_impl<const IndexList<FirstType, OtherTypes...>> {
455  EIGEN_DEVICE_FUNC static constexpr bool run(const Index i, const Index value) {
456  return IndexList<FirstType, OtherTypes...>().value_known_statically(i) &&
457  (IndexList<FirstType, OtherTypes...>().get(i) == value);
458  }
459 };
460 
461 template <typename T>
462 struct index_statically_ne_impl {
463  EIGEN_DEVICE_FUNC static constexpr bool run(Index, Index) { return false; }
464 };
465 
466 template <typename FirstType, typename... OtherTypes>
467 struct index_statically_ne_impl<IndexList<FirstType, OtherTypes...>> {
468  EIGEN_DEVICE_FUNC static constexpr bool run(const Index i, const Index value) {
469  return IndexList<FirstType, OtherTypes...>().value_known_statically(i) &&
470  (IndexList<FirstType, OtherTypes...>().get(i) != value);
471  }
472 };
473 
474 template <typename FirstType, typename... OtherTypes>
475 struct index_statically_ne_impl<const IndexList<FirstType, OtherTypes...>> {
476  EIGEN_DEVICE_FUNC static constexpr bool run(const Index i, const Index value) {
477  return IndexList<FirstType, OtherTypes...>().value_known_statically(i) &&
478  (IndexList<FirstType, OtherTypes...>().get(i) != value);
479  }
480 };
481 
482 template <typename T>
483 struct index_statically_gt_impl {
484  EIGEN_DEVICE_FUNC static constexpr bool run(Index, Index) { return false; }
485 };
486 
487 template <typename FirstType, typename... OtherTypes>
488 struct index_statically_gt_impl<IndexList<FirstType, OtherTypes...>> {
489  EIGEN_DEVICE_FUNC static constexpr bool run(const Index i, const Index value) {
490  return IndexList<FirstType, OtherTypes...>().value_known_statically(i) &&
491  (IndexList<FirstType, OtherTypes...>().get(i) > value);
492  }
493 };
494 
495 template <typename FirstType, typename... OtherTypes>
496 struct index_statically_gt_impl<const IndexList<FirstType, OtherTypes...>> {
497  EIGEN_DEVICE_FUNC static constexpr bool run(const Index i, const Index value) {
498  return IndexList<FirstType, OtherTypes...>().value_known_statically(i) &&
499  (IndexList<FirstType, OtherTypes...>().get(i) > value);
500  }
501 };
502 
503 template <typename T>
504 struct index_statically_lt_impl {
505  EIGEN_DEVICE_FUNC static constexpr bool run(Index, Index) { return false; }
506 };
507 
508 template <typename FirstType, typename... OtherTypes>
509 struct index_statically_lt_impl<IndexList<FirstType, OtherTypes...>> {
510  EIGEN_DEVICE_FUNC static constexpr bool run(const Index i, const Index value) {
511  return IndexList<FirstType, OtherTypes...>().value_known_statically(i) &&
512  (IndexList<FirstType, OtherTypes...>().get(i) < value);
513  }
514 };
515 
516 template <typename FirstType, typename... OtherTypes>
517 struct index_statically_lt_impl<const IndexList<FirstType, OtherTypes...>> {
518  EIGEN_DEVICE_FUNC static constexpr bool run(const Index i, const Index value) {
519  return IndexList<FirstType, OtherTypes...>().value_known_statically(i) &&
520  (IndexList<FirstType, OtherTypes...>().get(i) < value);
521  }
522 };
523 
524 template <typename Tx>
525 struct index_pair_first_statically_eq_impl {
526  EIGEN_DEVICE_FUNC static constexpr bool run(Index, Index) { return false; }
527 };
528 
529 template <typename FirstType, typename... OtherTypes>
530 struct index_pair_first_statically_eq_impl<IndexPairList<FirstType, OtherTypes...>> {
531  EIGEN_DEVICE_FUNC static constexpr bool run(const Index i, const Index value) {
532  return IndexPairList<FirstType, OtherTypes...>().value_known_statically(i) &&
533  (IndexPairList<FirstType, OtherTypes...>().operator[](i).first == value);
534  }
535 };
536 
537 template <typename FirstType, typename... OtherTypes>
538 struct index_pair_first_statically_eq_impl<const IndexPairList<FirstType, OtherTypes...>> {
539  EIGEN_DEVICE_FUNC static constexpr bool run(const Index i, const Index value) {
540  return IndexPairList<FirstType, OtherTypes...>().value_known_statically(i) &&
541  (IndexPairList<FirstType, OtherTypes...>().operator[](i).first == value);
542  }
543 };
544 
545 template <typename Tx>
546 struct index_pair_second_statically_eq_impl {
547  EIGEN_DEVICE_FUNC static constexpr bool run(Index, Index) { return false; }
548 };
549 
550 template <typename FirstType, typename... OtherTypes>
551 struct index_pair_second_statically_eq_impl<IndexPairList<FirstType, OtherTypes...>> {
552  EIGEN_DEVICE_FUNC static constexpr bool run(const Index i, const Index value) {
553  return IndexPairList<FirstType, OtherTypes...>().value_known_statically(i) &&
554  (IndexPairList<FirstType, OtherTypes...>().operator[](i).second == value);
555  }
556 };
557 
558 template <typename FirstType, typename... OtherTypes>
559 struct index_pair_second_statically_eq_impl<const IndexPairList<FirstType, OtherTypes...>> {
560  EIGEN_DEVICE_FUNC static constexpr bool run(const Index i, const Index value) {
561  return IndexPairList<FirstType, OtherTypes...>().value_known_statically(i) &&
562  (IndexPairList<FirstType, OtherTypes...>().operator[](i).second == value);
563  }
564 };
565 
566 } // end namespace internal
567 } // end namespace Eigen
568 
569 namespace Eigen {
570 namespace internal {
571 template <typename T>
572 static EIGEN_DEVICE_FUNC constexpr bool index_known_statically(Index i) {
573  return index_known_statically_impl<T>::run(i);
574 }
575 
576 template <typename T>
577 static EIGEN_DEVICE_FUNC constexpr bool all_indices_known_statically() {
578  return all_indices_known_statically_impl<T>::run();
579 }
580 
581 template <typename T>
582 static EIGEN_DEVICE_FUNC constexpr bool indices_statically_known_to_increase() {
583  return indices_statically_known_to_increase_impl<T>::run();
584 }
585 
586 template <typename T>
587 static EIGEN_DEVICE_FUNC constexpr bool index_statically_eq(Index i, Index value) {
588  return index_statically_eq_impl<T>::run(i, value);
589 }
590 
591 template <typename T>
592 static EIGEN_DEVICE_FUNC constexpr bool index_statically_ne(Index i, Index value) {
593  return index_statically_ne_impl<T>::run(i, value);
594 }
595 
596 template <typename T>
597 static EIGEN_DEVICE_FUNC constexpr bool index_statically_gt(Index i, Index value) {
598  return index_statically_gt_impl<T>::run(i, value);
599 }
600 
601 template <typename T>
602 static EIGEN_DEVICE_FUNC constexpr bool index_statically_lt(Index i, Index value) {
603  return index_statically_lt_impl<T>::run(i, value);
604 }
605 
606 template <typename T>
607 static EIGEN_DEVICE_FUNC constexpr bool index_pair_first_statically_eq(Index i, Index value) {
608  return index_pair_first_statically_eq_impl<T>::run(i, value);
609 }
610 
611 template <typename T>
612 static EIGEN_DEVICE_FUNC constexpr bool index_pair_second_statically_eq(Index i, Index value) {
613  return index_pair_second_statically_eq_impl<T>::run(i, value);
614 }
615 
616 } // end namespace internal
617 } // end namespace Eigen
618 
619 #endif // EIGEN_CXX11_TENSOR_TENSOR_INDEX_LIST_H
Namespace containing all symbols from the Eigen library.
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index