Eigen-unsupported  5.0.1-dev+284dcc12
 
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// IWYU pragma: private
14#include "./InternalHeaderCheck.h"
15
16namespace Eigen {
17
18template <Index n>
19struct 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>>().
27template <Index f, Index s>
28struct 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
40template <Index n>
41struct 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
51namespace internal {
52template <typename T>
53EIGEN_DEVICE_FUNC void update_value(T& val, Index new_val) {
54 val = internal::convert_index<T>(new_val);
55}
56template <Index n>
57EIGEN_DEVICE_FUNC void update_value(type2index<n>& val, Index new_val) {
58 val.set(new_val);
59}
60
61template <typename T>
62EIGEN_DEVICE_FUNC void update_value(T& val, IndexPair<Index> new_val) {
63 val = new_val;
64}
65template <Index f, Index s>
66EIGEN_DEVICE_FUNC void update_value(type2indexpair<f, s>& val, IndexPair<Index> new_val) {
67 val.set(new_val);
68}
69
70template <typename T>
71struct is_compile_time_constant {
72 static constexpr bool value = false;
73};
74
75template <Index idx>
76struct is_compile_time_constant<type2index<idx>> {
77 static constexpr bool value = true;
78};
79template <Index idx>
80struct is_compile_time_constant<const type2index<idx>> {
81 static constexpr bool value = true;
82};
83template <Index idx>
84struct is_compile_time_constant<type2index<idx>&> {
85 static constexpr bool value = true;
86};
87template <Index idx>
88struct is_compile_time_constant<const type2index<idx>&> {
89 static constexpr bool value = true;
90};
91
92template <Index f, Index s>
93struct is_compile_time_constant<type2indexpair<f, s>> {
94 static constexpr bool value = true;
95};
96template <Index f, Index s>
97struct is_compile_time_constant<const type2indexpair<f, s>> {
98 static constexpr bool value = true;
99};
100template <Index f, Index s>
101struct is_compile_time_constant<type2indexpair<f, s>&> {
102 static constexpr bool value = true;
103};
104template <Index f, Index s>
105struct is_compile_time_constant<const type2indexpair<f, s>&> {
106 static constexpr bool value = true;
107};
108
109template <typename... T>
110struct IndexTuple;
111
112template <typename T, typename... O>
113struct 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
124template <typename T>
125struct 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
134template <int N, typename... T>
135struct IndexTupleExtractor;
136
137template <int N, typename T, typename... O>
138struct 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
154template <typename T, typename... O>
155struct 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
166template <int N, typename T, typename... O>
167EIGEN_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}
170template <int N, typename T, typename... O>
171EIGEN_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}
175template <typename T, typename... O>
176struct array_size<IndexTuple<T, O...>> {
177 static constexpr size_t value = IndexTuple<T, O...>::count;
178};
179template <typename T, typename... O>
180struct array_size<const IndexTuple<T, O...>> {
181 static constexpr size_t value = IndexTuple<T, O...>::count;
182};
183
184template <Index Idx, typename ValueT>
185struct 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
221template <typename ValueT>
222struct 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
268
269template <typename FirstType, typename... OtherTypes>
270struct 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
307template <typename FirstType, typename... OtherTypes>
308std::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
318template <typename FirstType, typename... OtherTypes>
319constexpr IndexList<FirstType, OtherTypes...> make_index_list(FirstType val1, OtherTypes... other_vals) {
320 return IndexList<FirstType, OtherTypes...>(val1, other_vals...);
321}
322
323template <typename FirstType, typename... OtherTypes>
324struct 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
344namespace internal {
345
346template <typename FirstType, typename... OtherTypes>
347EIGEN_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
356template <typename FirstType, typename... OtherTypes>
357struct array_size<IndexList<FirstType, OtherTypes...>> {
358 static const size_t value = array_size<IndexTuple<FirstType, OtherTypes...>>::value;
359};
360template <typename FirstType, typename... OtherTypes>
361struct array_size<const IndexList<FirstType, OtherTypes...>> {
362 static const size_t value = array_size<IndexTuple<FirstType, OtherTypes...>>::value;
363};
364
365template <typename FirstType, typename... OtherTypes>
366struct array_size<IndexPairList<FirstType, OtherTypes...>> {
367 static const size_t value = 1 + sizeof...(OtherTypes);
368};
369template <typename FirstType, typename... OtherTypes>
370struct array_size<const IndexPairList<FirstType, OtherTypes...>> {
371 static const size_t value = 1 + sizeof...(OtherTypes);
372};
373
374template <Index N, typename FirstType, typename... OtherTypes>
375EIGEN_DEVICE_FUNC constexpr Index array_get(IndexList<FirstType, OtherTypes...>& a) {
376 return IndexTupleExtractor<N, FirstType, OtherTypes...>::get_val(a);
377}
378template <Index N, typename FirstType, typename... OtherTypes>
379EIGEN_DEVICE_FUNC constexpr Index array_get(const IndexList<FirstType, OtherTypes...>& a) {
380 return IndexTupleExtractor<N, FirstType, OtherTypes...>::get_val(a);
381}
382
383template <typename T>
384struct index_known_statically_impl {
385 EIGEN_DEVICE_FUNC static constexpr bool run(const Index) { return false; }
386};
387
388template <typename FirstType, typename... OtherTypes>
389struct 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
395template <typename FirstType, typename... OtherTypes>
396struct 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
402template <typename T>
403struct all_indices_known_statically_impl {
404 static constexpr bool run() { return false; }
405};
406
407template <typename FirstType, typename... OtherTypes>
408struct 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
414template <typename FirstType, typename... OtherTypes>
415struct 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
421template <typename T>
422struct indices_statically_known_to_increase_impl {
423 EIGEN_DEVICE_FUNC static constexpr bool run() { return false; }
424};
425
426template <typename FirstType, typename... OtherTypes>
427struct 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
433template <typename FirstType, typename... OtherTypes>
434struct 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
440template <typename Tx>
441struct index_statically_eq_impl {
442 EIGEN_DEVICE_FUNC static constexpr bool run(Index, Index) { return false; }
443};
444
445template <typename FirstType, typename... OtherTypes>
446struct 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
453template <typename FirstType, typename... OtherTypes>
454struct 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
461template <typename T>
462struct index_statically_ne_impl {
463 EIGEN_DEVICE_FUNC static constexpr bool run(Index, Index) { return false; }
464};
465
466template <typename FirstType, typename... OtherTypes>
467struct 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
474template <typename FirstType, typename... OtherTypes>
475struct 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
482template <typename T>
483struct index_statically_gt_impl {
484 EIGEN_DEVICE_FUNC static constexpr bool run(Index, Index) { return false; }
485};
486
487template <typename FirstType, typename... OtherTypes>
488struct 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
495template <typename FirstType, typename... OtherTypes>
496struct 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
503template <typename T>
504struct index_statically_lt_impl {
505 EIGEN_DEVICE_FUNC static constexpr bool run(Index, Index) { return false; }
506};
507
508template <typename FirstType, typename... OtherTypes>
509struct 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
516template <typename FirstType, typename... OtherTypes>
517struct 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
524template <typename Tx>
525struct index_pair_first_statically_eq_impl {
526 EIGEN_DEVICE_FUNC static constexpr bool run(Index, Index) { return false; }
527};
528
529template <typename FirstType, typename... OtherTypes>
530struct 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
537template <typename FirstType, typename... OtherTypes>
538struct 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
545template <typename Tx>
546struct index_pair_second_statically_eq_impl {
547 EIGEN_DEVICE_FUNC static constexpr bool run(Index, Index) { return false; }
548};
549
550template <typename FirstType, typename... OtherTypes>
551struct 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
558template <typename FirstType, typename... OtherTypes>
559struct 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
569namespace Eigen {
570namespace internal {
571template <typename T>
572static EIGEN_DEVICE_FUNC constexpr bool index_known_statically(Index i) {
573 return index_known_statically_impl<T>::run(i);
574}
575
576template <typename T>
577static EIGEN_DEVICE_FUNC constexpr bool all_indices_known_statically() {
578 return all_indices_known_statically_impl<T>::run();
579}
580
581template <typename T>
582static EIGEN_DEVICE_FUNC constexpr bool indices_statically_known_to_increase() {
583 return indices_statically_known_to_increase_impl<T>::run();
584}
585
586template <typename T>
587static EIGEN_DEVICE_FUNC constexpr bool index_statically_eq(Index i, Index value) {
588 return index_statically_eq_impl<T>::run(i, value);
589}
590
591template <typename T>
592static EIGEN_DEVICE_FUNC constexpr bool index_statically_ne(Index i, Index value) {
593 return index_statically_ne_impl<T>::run(i, value);
594}
595
596template <typename T>
597static EIGEN_DEVICE_FUNC constexpr bool index_statically_gt(Index i, Index value) {
598 return index_statically_gt_impl<T>::run(i, value);
599}
600
601template <typename T>
602static EIGEN_DEVICE_FUNC constexpr bool index_statically_lt(Index i, Index value) {
603 return index_statically_lt_impl<T>::run(i, value);
604}
605
606template <typename T>
607static 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
611template <typename T>
612static 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