Eigen-unsupported  3.4.1 (git rev 28ded8800c26864e537852658428ab44c8399e87)
 
Loading...
Searching...
No Matches
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
14#if EIGEN_HAS_CONSTEXPR && EIGEN_HAS_VARIADIC_TEMPLATES
15
16#define EIGEN_HAS_INDEX_LIST
17
18namespace Eigen {
19
20template <Index n>
21struct type2index {
22 static const Index value = n;
23 EIGEN_DEVICE_FUNC constexpr operator Index() const { return n; }
24 EIGEN_DEVICE_FUNC void set(Index val) {
25 eigen_assert(val == n);
26 }
27};
28
29// This can be used with IndexPairList to get compile-time constant pairs,
30// such as IndexPairList<type2indexpair<1,2>, type2indexpair<3,4>>().
31template <Index f, Index s>
32struct type2indexpair {
33 static const Index first = f;
34 static const Index second = s;
35
36 constexpr EIGEN_DEVICE_FUNC operator IndexPair<Index>() const {
37 return IndexPair<Index>(f, s);
38 }
39
40 EIGEN_DEVICE_FUNC void set(const IndexPair<Index>& val) {
41 eigen_assert(val.first == f);
42 eigen_assert(val.second == s);
43 }
44};
45
46
47template<Index n> struct NumTraits<type2index<n> >
48{
49 typedef Index Real;
50 enum {
51 IsComplex = 0,
52 RequireInitialization = false,
53 ReadCost = 1,
54 AddCost = 1,
55 MulCost = 1
56 };
57
58 EIGEN_DEVICE_FUNC static EIGEN_CONSTEXPR EIGEN_STRONG_INLINE Real epsilon() { return 0; }
59 EIGEN_DEVICE_FUNC static EIGEN_CONSTEXPR EIGEN_STRONG_INLINE Real dummy_precision() { return 0; }
60 EIGEN_DEVICE_FUNC static EIGEN_CONSTEXPR EIGEN_STRONG_INLINE Real highest() { return n; }
61 EIGEN_DEVICE_FUNC static EIGEN_CONSTEXPR EIGEN_STRONG_INLINE Real lowest() { return n; }
62};
63
64namespace internal {
65template <typename T>
66EIGEN_DEVICE_FUNC void update_value(T& val, Index new_val) {
67 val = internal::convert_index<T>(new_val);
68}
69template <Index n>
70EIGEN_DEVICE_FUNC void update_value(type2index<n>& val, Index new_val) {
71 val.set(new_val);
72}
73
74template <typename T>
75EIGEN_DEVICE_FUNC void update_value(T& val, IndexPair<Index> new_val) {
76 val = new_val;
77}
78template <Index f, Index s>
79EIGEN_DEVICE_FUNC void update_value(type2indexpair<f, s>& val, IndexPair<Index> new_val) {
80 val.set(new_val);
81}
82
83
84template <typename T>
85struct is_compile_time_constant {
86 static constexpr bool value = false;
87};
88
89template <Index idx>
90struct is_compile_time_constant<type2index<idx> > {
91 static constexpr bool value = true;
92};
93template <Index idx>
94struct is_compile_time_constant<const type2index<idx> > {
95 static constexpr bool value = true;
96};
97template <Index idx>
98struct is_compile_time_constant<type2index<idx>& > {
99 static constexpr bool value = true;
100};
101template <Index idx>
102struct is_compile_time_constant<const type2index<idx>& > {
103 static constexpr bool value = true;
104};
105
106template <Index f, Index s>
107struct is_compile_time_constant<type2indexpair<f, s> > {
108 static constexpr bool value = true;
109};
110template <Index f, Index s>
111struct is_compile_time_constant<const type2indexpair<f, s> > {
112 static constexpr bool value = true;
113};
114template <Index f, Index s>
115struct is_compile_time_constant<type2indexpair<f, s>& > {
116 static constexpr bool value = true;
117};
118template <Index f, Index s>
119struct is_compile_time_constant<const type2indexpair<f, s>& > {
120 static constexpr bool value = true;
121};
122
123
124template<typename... T>
125struct IndexTuple;
126
127template<typename T, typename... O>
128struct IndexTuple<T, O...> {
129 EIGEN_DEVICE_FUNC constexpr IndexTuple() : head(), others() { }
130 EIGEN_DEVICE_FUNC constexpr IndexTuple(const T& v, const O... o) : head(v), others(o...) { }
131
132 constexpr static int count = 1 + sizeof...(O);
133 T head;
134 IndexTuple<O...> others;
135 typedef T Head;
136 typedef IndexTuple<O...> Other;
137};
138
139template<typename T>
140 struct IndexTuple<T> {
141 EIGEN_DEVICE_FUNC constexpr IndexTuple() : head() { }
142 EIGEN_DEVICE_FUNC constexpr IndexTuple(const T& v) : head(v) { }
143
144 constexpr static int count = 1;
145 T head;
146 typedef T Head;
147};
148
149
150template<int N, typename... T>
151struct IndexTupleExtractor;
152
153template<int N, typename T, typename... O>
154struct IndexTupleExtractor<N, T, O...> {
155
156 typedef typename IndexTupleExtractor<N-1, O...>::ValType ValType;
157
158 EIGEN_DEVICE_FUNC static constexpr ValType& get_val(IndexTuple<T, O...>& val) {
159 return IndexTupleExtractor<N-1, O...>::get_val(val.others);
160 }
161
162 EIGEN_DEVICE_FUNC static constexpr const ValType& get_val(const IndexTuple<T, O...>& val) {
163 return IndexTupleExtractor<N-1, O...>::get_val(val.others);
164 }
165 template <typename V>
166 EIGEN_DEVICE_FUNC static void set_val(IndexTuple<T, O...>& val, V& new_val) {
167 IndexTupleExtractor<N-1, O...>::set_val(val.others, new_val);
168 }
169
170};
171
172template<typename T, typename... O>
173 struct IndexTupleExtractor<0, T, O...> {
174
175 typedef T ValType;
176
177 EIGEN_DEVICE_FUNC static constexpr ValType& get_val(IndexTuple<T, O...>& val) {
178 return val.head;
179 }
180 EIGEN_DEVICE_FUNC static constexpr const ValType& get_val(const IndexTuple<T, O...>& val) {
181 return val.head;
182 }
183 template <typename V>
184 EIGEN_DEVICE_FUNC static void set_val(IndexTuple<T, O...>& val, V& new_val) {
185 val.head = new_val;
186 }
187};
188
189
190
191template <int N, typename T, typename... O>
192EIGEN_DEVICE_FUNC constexpr typename IndexTupleExtractor<N, T, O...>::ValType& array_get(IndexTuple<T, O...>& tuple) {
193 return IndexTupleExtractor<N, T, O...>::get_val(tuple);
194}
195template <int N, typename T, typename... O>
196EIGEN_DEVICE_FUNC constexpr const typename IndexTupleExtractor<N, T, O...>::ValType& array_get(const IndexTuple<T, O...>& tuple) {
197 return IndexTupleExtractor<N, T, O...>::get_val(tuple);
198}
199template <typename T, typename... O>
200 struct array_size<IndexTuple<T, O...> > {
201 static const size_t value = IndexTuple<T, O...>::count;
202};
203template <typename T, typename... O>
204 struct array_size<const IndexTuple<T, O...> > {
205 static const size_t value = IndexTuple<T, O...>::count;
206};
207
208
209
210
211template <Index Idx, typename ValueT>
212struct tuple_coeff {
213 template <typename... T>
214 EIGEN_DEVICE_FUNC static constexpr ValueT get(const Index i, const IndexTuple<T...>& t) {
215 // return array_get<Idx>(t) * (i == Idx) + tuple_coeff<Idx-1>::get(i, t) * (i != Idx);
216 return (i == Idx ? array_get<Idx>(t) : tuple_coeff<Idx-1, ValueT>::get(i, t));
217 }
218 template <typename... T>
219 EIGEN_DEVICE_FUNC static void set(const Index i, IndexTuple<T...>& t, const ValueT& value) {
220 if (i == Idx) {
221 update_value(array_get<Idx>(t), value);
222 } else {
223 tuple_coeff<Idx-1, ValueT>::set(i, t, value);
224 }
225 }
226
227 template <typename... T>
228 EIGEN_DEVICE_FUNC static constexpr bool value_known_statically(const Index i, const IndexTuple<T...>& t) {
229 return ((i == Idx) && is_compile_time_constant<typename IndexTupleExtractor<Idx, T...>::ValType>::value) ||
230 tuple_coeff<Idx-1, ValueT>::value_known_statically(i, t);
231 }
232
233 template <typename... T>
234 EIGEN_DEVICE_FUNC static constexpr bool values_up_to_known_statically(const IndexTuple<T...>& t) {
235 return is_compile_time_constant<typename IndexTupleExtractor<Idx, T...>::ValType>::value &&
236 tuple_coeff<Idx-1, ValueT>::values_up_to_known_statically(t);
237 }
238
239 template <typename... T>
240 EIGEN_DEVICE_FUNC static constexpr bool values_up_to_statically_known_to_increase(const IndexTuple<T...>& t) {
241 return is_compile_time_constant<typename IndexTupleExtractor<Idx, T...>::ValType>::value &&
242 is_compile_time_constant<typename IndexTupleExtractor<Idx, T...>::ValType>::value &&
243 array_get<Idx>(t) > array_get<Idx-1>(t) &&
244 tuple_coeff<Idx-1, ValueT>::values_up_to_statically_known_to_increase(t);
245 }
246};
247
248template <typename ValueT>
249struct tuple_coeff<0, ValueT> {
250 template <typename... T>
251 EIGEN_DEVICE_FUNC static constexpr ValueT get(const Index /*i*/, const IndexTuple<T...>& t) {
252 // eigen_assert (i == 0); // gcc fails to compile assertions in constexpr
253 return array_get<0>(t)/* * (i == 0)*/;
254 }
255 template <typename... T>
256 EIGEN_DEVICE_FUNC static void set(const Index i, IndexTuple<T...>& t, const ValueT value) {
257 eigen_assert (i == 0);
258 update_value(array_get<0>(t), value);
259 }
260 template <typename... T>
261 EIGEN_DEVICE_FUNC static constexpr bool value_known_statically(const Index i, const IndexTuple<T...>&) {
262 return is_compile_time_constant<typename IndexTupleExtractor<0, T...>::ValType>::value && (i == 0);
263 }
264
265 template <typename... T>
266 EIGEN_DEVICE_FUNC static constexpr bool values_up_to_known_statically(const IndexTuple<T...>&) {
267 return is_compile_time_constant<typename IndexTupleExtractor<0, T...>::ValType>::value;
268 }
269
270 template <typename... T>
271 EIGEN_DEVICE_FUNC static constexpr bool values_up_to_statically_known_to_increase(const IndexTuple<T...>&) {
272 return true;
273 }
274};
275} // namespace internal
276
295
296template <typename FirstType, typename... OtherTypes>
297struct 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_DEVICE_FUNC constexpr IndexList(const internal::IndexTuple<FirstType, OtherTypes...>& other) : internal::IndexTuple<FirstType, OtherTypes...>(other) { }
309 EIGEN_DEVICE_FUNC constexpr IndexList(FirstType& first, OtherTypes... other) : internal::IndexTuple<FirstType, OtherTypes...>(first, other...) { }
310 EIGEN_DEVICE_FUNC constexpr IndexList() : internal::IndexTuple<FirstType, OtherTypes...>() { }
311
312 EIGEN_DEVICE_FUNC constexpr bool value_known_statically(const Index i) const {
313 return internal::tuple_coeff<internal::array_size<internal::IndexTuple<FirstType, OtherTypes...> >::value-1, Index>::value_known_statically(i, *this);
314 }
315 EIGEN_DEVICE_FUNC constexpr bool all_values_known_statically() const {
316 return internal::tuple_coeff<internal::array_size<internal::IndexTuple<FirstType, OtherTypes...> >::value-1, Index>::values_up_to_known_statically(*this);
317 }
318
319 EIGEN_DEVICE_FUNC constexpr bool values_statically_known_to_increase() const {
320 return internal::tuple_coeff<internal::array_size<internal::IndexTuple<FirstType, OtherTypes...> >::value-1, Index>::values_up_to_statically_known_to_increase(*this);
321 }
322};
323
324template <typename FirstType, typename... OtherTypes>
325std::ostream& operator<<(std::ostream& os,
326 const IndexList<FirstType, OtherTypes...>& dims) {
327 os << "[";
328 for (size_t i = 0; i < 1 + sizeof...(OtherTypes); ++i) {
329 if (i > 0) os << ", ";
330 os << dims[i];
331 }
332 os << "]";
333 return os;
334}
335
336template<typename FirstType, typename... OtherTypes>
337constexpr IndexList<FirstType, OtherTypes...> make_index_list(FirstType val1, OtherTypes... other_vals) {
338 return IndexList<FirstType, OtherTypes...>(val1, other_vals...);
339}
340
341
342template<typename FirstType, typename... OtherTypes>
343struct IndexPairList : internal::IndexTuple<FirstType, OtherTypes...> {
344 EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC constexpr IndexPair<Index> operator[] (const Index i) const {
345 return internal::tuple_coeff<internal::array_size<internal::IndexTuple<FirstType, OtherTypes...> >::value-1, IndexPair<Index>>::get(i, *this);
346 }
347 EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC void set(const Index i, const IndexPair<Index> value) {
348 return internal::tuple_coeff<internal::array_size<internal::IndexTuple<FirstType, OtherTypes...>>::value-1, IndexPair<Index> >::set(i, *this, value);
349 }
350
351 EIGEN_DEVICE_FUNC constexpr IndexPairList(const internal::IndexTuple<FirstType, OtherTypes...>& other) : internal::IndexTuple<FirstType, OtherTypes...>(other) { }
352 EIGEN_DEVICE_FUNC constexpr IndexPairList() : internal::IndexTuple<FirstType, OtherTypes...>() { }
353
354 EIGEN_DEVICE_FUNC constexpr bool value_known_statically(const Index i) const {
355 return internal::tuple_coeff<internal::array_size<internal::IndexTuple<FirstType, OtherTypes...> >::value-1, Index>::value_known_statically(i, *this);
356 }
357};
358
359namespace internal {
360
361template<typename FirstType, typename... OtherTypes>
362EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index array_prod(const IndexList<FirstType, OtherTypes...>& sizes) {
363 Index result = 1;
364 EIGEN_UNROLL_LOOP
365 for (size_t i = 0; i < array_size<IndexList<FirstType, OtherTypes...> >::value; ++i) {
366 result *= sizes[i];
367 }
368 return result;
369}
370
371template<typename FirstType, typename... OtherTypes> struct array_size<IndexList<FirstType, OtherTypes...> > {
372 static const size_t value = array_size<IndexTuple<FirstType, OtherTypes...> >::value;
373};
374template<typename FirstType, typename... OtherTypes> struct array_size<const IndexList<FirstType, OtherTypes...> > {
375 static const size_t value = array_size<IndexTuple<FirstType, OtherTypes...> >::value;
376};
377
378template<typename FirstType, typename... OtherTypes> struct array_size<IndexPairList<FirstType, OtherTypes...> > {
379 static const size_t value = std::tuple_size<std::tuple<FirstType, OtherTypes...> >::value;
380};
381template<typename FirstType, typename... OtherTypes> struct array_size<const IndexPairList<FirstType, OtherTypes...> > {
382 static const size_t value = std::tuple_size<std::tuple<FirstType, OtherTypes...> >::value;
383};
384
385template<Index N, typename FirstType, typename... OtherTypes> EIGEN_DEVICE_FUNC constexpr Index array_get(IndexList<FirstType, OtherTypes...>& a) {
386 return IndexTupleExtractor<N, FirstType, OtherTypes...>::get_val(a);
387}
388template<Index N, typename FirstType, typename... OtherTypes> EIGEN_DEVICE_FUNC constexpr Index array_get(const IndexList<FirstType, OtherTypes...>& a) {
389 return IndexTupleExtractor<N, FirstType, OtherTypes...>::get_val(a);
390}
391
392template <typename T>
393struct index_known_statically_impl {
394 EIGEN_DEVICE_FUNC static constexpr bool run(const Index) {
395 return false;
396 }
397};
398
399template <typename FirstType, typename... OtherTypes>
400struct index_known_statically_impl<IndexList<FirstType, OtherTypes...> > {
401 EIGEN_DEVICE_FUNC static constexpr bool run(const Index i) {
402 return IndexList<FirstType, OtherTypes...>().value_known_statically(i);
403 }
404};
405
406template <typename FirstType, typename... OtherTypes>
407struct index_known_statically_impl<const IndexList<FirstType, OtherTypes...> > {
408 EIGEN_DEVICE_FUNC static constexpr bool run(const Index i) {
409 return IndexList<FirstType, OtherTypes...>().value_known_statically(i);
410 }
411};
412
413
414template <typename T>
415struct all_indices_known_statically_impl {
416 static constexpr bool run() {
417 return false;
418 }
419};
420
421template <typename FirstType, typename... OtherTypes>
422struct all_indices_known_statically_impl<IndexList<FirstType, OtherTypes...> > {
423 EIGEN_DEVICE_FUNC static constexpr bool run() {
424 return IndexList<FirstType, OtherTypes...>().all_values_known_statically();
425 }
426};
427
428template <typename FirstType, typename... OtherTypes>
429struct all_indices_known_statically_impl<const IndexList<FirstType, OtherTypes...> > {
430 EIGEN_DEVICE_FUNC static constexpr bool run() {
431 return IndexList<FirstType, OtherTypes...>().all_values_known_statically();
432 }
433};
434
435
436template <typename T>
437struct indices_statically_known_to_increase_impl {
438 EIGEN_DEVICE_FUNC static constexpr bool run() {
439 return false;
440 }
441};
442
443template <typename FirstType, typename... OtherTypes>
444 struct indices_statically_known_to_increase_impl<IndexList<FirstType, OtherTypes...> > {
445 EIGEN_DEVICE_FUNC static constexpr bool run() {
446 return Eigen::IndexList<FirstType, OtherTypes...>().values_statically_known_to_increase();
447 }
448};
449
450template <typename FirstType, typename... OtherTypes>
451 struct indices_statically_known_to_increase_impl<const IndexList<FirstType, OtherTypes...> > {
452 EIGEN_DEVICE_FUNC static constexpr bool run() {
453 return Eigen::IndexList<FirstType, OtherTypes...>().values_statically_known_to_increase();
454 }
455};
456
457
458template <typename Tx>
459struct index_statically_eq_impl {
460 EIGEN_DEVICE_FUNC static constexpr bool run(Index, Index) {
461 return false;
462 }
463};
464
465template <typename FirstType, typename... OtherTypes>
466struct index_statically_eq_impl<IndexList<FirstType, OtherTypes...> > {
467 EIGEN_DEVICE_FUNC static constexpr bool run(const Index i, const Index value) {
468 return IndexList<FirstType, OtherTypes...>().value_known_statically(i) &&
469 (IndexList<FirstType, OtherTypes...>().get(i) == value);
470 }
471};
472
473template <typename FirstType, typename... OtherTypes>
474struct index_statically_eq_impl<const IndexList<FirstType, OtherTypes...> > {
475 EIGEN_DEVICE_FUNC static constexpr bool run(const Index i, const Index value) {
476 return IndexList<FirstType, OtherTypes...>().value_known_statically(i) &&
477 (IndexList<FirstType, OtherTypes...>().get(i) == value);
478 }
479};
480
481
482template <typename T>
483struct index_statically_ne_impl {
484 EIGEN_DEVICE_FUNC static constexpr bool run(Index, Index) {
485 return false;
486 }
487};
488
489template <typename FirstType, typename... OtherTypes>
490struct index_statically_ne_impl<IndexList<FirstType, OtherTypes...> > {
491 EIGEN_DEVICE_FUNC static constexpr bool run(const Index i, const Index value) {
492 return IndexList<FirstType, OtherTypes...>().value_known_statically(i) &&
493 (IndexList<FirstType, OtherTypes...>().get(i) != value);
494 }
495};
496
497template <typename FirstType, typename... OtherTypes>
498struct index_statically_ne_impl<const IndexList<FirstType, OtherTypes...> > {
499 EIGEN_DEVICE_FUNC static constexpr bool run(const Index i, const Index value) {
500 return IndexList<FirstType, OtherTypes...>().value_known_statically(i) &&
501 (IndexList<FirstType, OtherTypes...>().get(i) != value);
502 }
503};
504
505
506template <typename T>
507struct index_statically_gt_impl {
508 EIGEN_DEVICE_FUNC static constexpr bool run(Index, Index) {
509 return false;
510 }
511};
512
513template <typename FirstType, typename... OtherTypes>
514struct index_statically_gt_impl<IndexList<FirstType, OtherTypes...> > {
515 EIGEN_DEVICE_FUNC static constexpr bool run(const Index i, const Index value) {
516 return IndexList<FirstType, OtherTypes...>().value_known_statically(i) &&
517 (IndexList<FirstType, OtherTypes...>().get(i) > value);
518 }
519};
520
521template <typename FirstType, typename... OtherTypes>
522struct index_statically_gt_impl<const IndexList<FirstType, OtherTypes...> > {
523 EIGEN_DEVICE_FUNC static constexpr bool run(const Index i, const Index value) {
524 return IndexList<FirstType, OtherTypes...>().value_known_statically(i) &&
525 (IndexList<FirstType, OtherTypes...>().get(i) > value);
526 }
527};
528
529
530
531template <typename T>
532struct index_statically_lt_impl {
533 EIGEN_DEVICE_FUNC static constexpr bool run(Index, Index) {
534 return false;
535 }
536};
537
538template <typename FirstType, typename... OtherTypes>
539struct index_statically_lt_impl<IndexList<FirstType, OtherTypes...> > {
540 EIGEN_DEVICE_FUNC static constexpr bool run(const Index i, const Index value) {
541 return IndexList<FirstType, OtherTypes...>().value_known_statically(i) &&
542 (IndexList<FirstType, OtherTypes...>().get(i) < value);
543 }
544};
545
546template <typename FirstType, typename... OtherTypes>
547struct index_statically_lt_impl<const IndexList<FirstType, OtherTypes...> > {
548 EIGEN_DEVICE_FUNC static constexpr bool run(const Index i, const Index value) {
549 return IndexList<FirstType, OtherTypes...>().value_known_statically(i) &&
550 (IndexList<FirstType, OtherTypes...>().get(i) < value);
551 }
552};
553
554
555
556template <typename Tx>
557struct index_pair_first_statically_eq_impl {
558 EIGEN_DEVICE_FUNC static constexpr bool run(Index, Index) {
559 return false;
560 }
561};
562
563template <typename FirstType, typename... OtherTypes>
564struct index_pair_first_statically_eq_impl<IndexPairList<FirstType, OtherTypes...> > {
565 EIGEN_DEVICE_FUNC static constexpr bool run(const Index i, const Index value) {
566 return IndexPairList<FirstType, OtherTypes...>().value_known_statically(i) &&
567 (IndexPairList<FirstType, OtherTypes...>().operator[](i).first == value);
568 }
569};
570
571template <typename FirstType, typename... OtherTypes>
572struct index_pair_first_statically_eq_impl<const IndexPairList<FirstType, OtherTypes...> > {
573 EIGEN_DEVICE_FUNC static constexpr bool run(const Index i, const Index value) {
574 return IndexPairList<FirstType, OtherTypes...>().value_known_statically(i) &&
575 (IndexPairList<FirstType, OtherTypes...>().operator[](i).first == value);
576 }
577};
578
579
580
581template <typename Tx>
582struct index_pair_second_statically_eq_impl {
583 EIGEN_DEVICE_FUNC static constexpr bool run(Index, Index) {
584 return false;
585 }
586};
587
588template <typename FirstType, typename... OtherTypes>
589struct index_pair_second_statically_eq_impl<IndexPairList<FirstType, OtherTypes...> > {
590 EIGEN_DEVICE_FUNC static constexpr bool run(const Index i, const Index value) {
591 return IndexPairList<FirstType, OtherTypes...>().value_known_statically(i) &&
592 (IndexPairList<FirstType, OtherTypes...>().operator[](i).second == value);
593 }
594};
595
596template <typename FirstType, typename... OtherTypes>
597struct index_pair_second_statically_eq_impl<const IndexPairList<FirstType, OtherTypes...> > {
598 EIGEN_DEVICE_FUNC static constexpr bool run(const Index i, const Index value) {
599 return IndexPairList<FirstType, OtherTypes...>().value_known_statically(i) &&
600 (IndexPairList<FirstType, OtherTypes...>().operator[](i).second == value);
601 }
602};
603
604
605} // end namespace internal
606} // end namespace Eigen
607
608#else
609
610namespace Eigen {
611namespace internal {
612
613template <typename T>
614struct index_known_statically_impl {
615 static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(const Index) {
616 return false;
617 }
618};
619
620template <typename T>
621struct all_indices_known_statically_impl {
622 static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run() {
623 return false;
624 }
625};
626
627template <typename T>
628struct indices_statically_known_to_increase_impl {
629 static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run() {
630 return false;
631 }
632};
633
634template <typename T>
635struct index_statically_eq_impl {
636 static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(Index, Index) {
637 return false;
638 }
639};
640
641template <typename T>
642struct index_statically_ne_impl {
643 static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(Index, Index) {
644 return false;
645 }
646};
647
648template <typename T>
649struct index_statically_gt_impl {
650 static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(Index, Index) {
651 return false;
652 }
653};
654
655template <typename T>
656struct index_statically_lt_impl {
657 static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(Index, Index) {
658 return false;
659 }
660};
661
662template <typename Tx>
663struct index_pair_first_statically_eq_impl {
664 static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(Index, Index) {
665 return false;
666 }
667};
668
669template <typename Tx>
670struct index_pair_second_statically_eq_impl {
671 static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(Index, Index) {
672 return false;
673 }
674};
675
676
677
678} // end namespace internal
679} // end namespace Eigen
680
681#endif
682
683
684namespace Eigen {
685namespace internal {
686template <typename T>
687static EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR bool index_known_statically(Index i) {
688 return index_known_statically_impl<T>::run(i);
689}
690
691template <typename T>
692static EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR bool all_indices_known_statically() {
693 return all_indices_known_statically_impl<T>::run();
694}
695
696template <typename T>
697static EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR bool indices_statically_known_to_increase() {
698 return indices_statically_known_to_increase_impl<T>::run();
699}
700
701template <typename T>
702static EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR bool index_statically_eq(Index i, Index value) {
703 return index_statically_eq_impl<T>::run(i, value);
704}
705
706template <typename T>
707static EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR bool index_statically_ne(Index i, Index value) {
708 return index_statically_ne_impl<T>::run(i, value);
709}
710
711template <typename T>
712static EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR bool index_statically_gt(Index i, Index value) {
713 return index_statically_gt_impl<T>::run(i, value);
714}
715
716template <typename T>
717static EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR bool index_statically_lt(Index i, Index value) {
718 return index_statically_lt_impl<T>::run(i, value);
719}
720
721template <typename T>
722static EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR bool index_pair_first_statically_eq(Index i, Index value) {
723 return index_pair_first_statically_eq_impl<T>::run(i, value);
724}
725
726template <typename T>
727static EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR bool index_pair_second_statically_eq(Index i, Index value) {
728 return index_pair_second_statically_eq_impl<T>::run(i, value);
729}
730
731} // end namespace internal
732} // end namespace Eigen
733
734
735#endif // EIGEN_CXX11_TENSOR_TENSOR_INDEX_LIST_H
Namespace containing all symbols from the Eigen library.
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index