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