10#ifndef EIGEN_CXX11_TENSOR_TENSOR_INDEX_LIST_H
11#define EIGEN_CXX11_TENSOR_TENSOR_INDEX_LIST_H
14#if EIGEN_HAS_CONSTEXPR && EIGEN_HAS_VARIADIC_TEMPLATES
16#define EIGEN_HAS_INDEX_LIST
42 static const Index value =
n;
51template <Index f, Index s>
52struct type2indexpair {
67template<Index n>
struct NumTraits<type2index<
n> >
87 val = internal::convert_index<T>(new_val);
98template <Index f, Index s>
105struct is_compile_time_constant {
106 static constexpr bool value =
false;
110struct is_compile_time_constant<type2index<idx> > {
111 static constexpr bool value =
true;
114struct is_compile_time_constant<const type2index<idx> > {
115 static constexpr bool value =
true;
118struct is_compile_time_constant<type2index<idx>& > {
119 static constexpr bool value =
true;
122struct is_compile_time_constant<const type2index<idx>& > {
123 static constexpr bool value =
true;
126template <Index f, Index s>
127struct is_compile_time_constant<type2indexpair<f,
s> > {
128 static constexpr bool value =
true;
130template <Index f, Index s>
131struct is_compile_time_constant<const type2indexpair<f,
s> > {
132 static constexpr bool value =
true;
134template <Index f, Index s>
135struct is_compile_time_constant<type2indexpair<f,
s>& > {
136 static constexpr bool value =
true;
138template <Index f, Index s>
139struct is_compile_time_constant<const type2indexpair<f,
s>& > {
140 static constexpr bool value =
true;
144template<
typename...
T>
147template<
typename T,
typename... O>
148struct IndexTuple<
T, O...> {
152 constexpr static int count = 1 +
sizeof...(O);
154 IndexTuple<O...> others;
156 typedef IndexTuple<O...> Other;
160 struct IndexTuple<
T> {
164 constexpr static int count = 1;
170template<
int N,
typename...
T>
171struct IndexTupleExtractor;
173template<
int N,
typename T,
typename... O>
174struct IndexTupleExtractor<
N,
T, O...> {
176 typedef typename IndexTupleExtractor<
N-1, O...>::ValType ValType;
179 return IndexTupleExtractor<N-1, O...>::get_val(val.others);
182 EIGEN_DEVICE_FUNC static constexpr const ValType& get_val(
const IndexTuple<T, O...>& val) {
183 return IndexTupleExtractor<N-1, O...>::get_val(val.others);
185 template <
typename V>
187 IndexTupleExtractor<N-1, O...>::set_val(val.others, new_val);
192template<
typename T,
typename... O>
193 struct IndexTupleExtractor<0,
T, O...> {
200 EIGEN_DEVICE_FUNC static constexpr const ValType& get_val(
const IndexTuple<T, O...>& val) {
203 template <
typename V>
211template <
int N,
typename T,
typename... O>
213 return IndexTupleExtractor<N, T, O...>::get_val(tuple);
215template <
int N,
typename T,
typename... O>
217 return IndexTupleExtractor<N, T, O...>::get_val(tuple);
219template <
typename T,
typename... O>
220 struct array_size<IndexTuple<
T, O...> > {
223template <
typename T,
typename... O>
224 struct array_size<const IndexTuple<
T, O...> > {
231template <Index Idx,
typename ValueT>
233 template <
typename...
T>
236 return (
i == Idx ? array_get<Idx>(t) : tuple_coeff<Idx-1, ValueT>::
get(
i, t));
238 template <
typename...
T>
241 update_value(array_get<Idx>(t), value);
243 tuple_coeff<Idx-1, ValueT>::set(
i, t, value);
247 template <
typename...
T>
249 return ((
i == Idx) & is_compile_time_constant<
typename IndexTupleExtractor<Idx, T...>::ValType>::value) ||
250 tuple_coeff<Idx-1, ValueT>::value_known_statically(
i, t);
253 template <
typename...
T>
254 EIGEN_DEVICE_FUNC static constexpr bool values_up_to_known_statically(
const IndexTuple<T...>& t) {
255 return is_compile_time_constant<
typename IndexTupleExtractor<Idx,
T...>::ValType>::value &&
256 tuple_coeff<Idx-1, ValueT>::values_up_to_known_statically(t);
259 template <
typename...
T>
260 EIGEN_DEVICE_FUNC static constexpr bool values_up_to_statically_known_to_increase(
const IndexTuple<T...>& t) {
261 return is_compile_time_constant<
typename IndexTupleExtractor<Idx,
T...>::ValType>::value &&
262 is_compile_time_constant<
typename IndexTupleExtractor<Idx,
T...>::ValType>::value &&
263 array_get<Idx>(t) >
array_get<Idx-1>(t) &&
264 tuple_coeff<Idx-1, ValueT>::values_up_to_statically_known_to_increase(t);
268template <
typename ValueT>
269struct tuple_coeff<0, ValueT> {
270 template <
typename...
T>
273 return array_get<0>(t);
275 template <
typename...
T>
278 update_value(array_get<0>(t), value);
280 template <
typename...
T>
282 return is_compile_time_constant<
typename IndexTupleExtractor<0,
T...>::ValType>::value && (
i == 0);
285 template <
typename...
T>
286 EIGEN_DEVICE_FUNC static constexpr bool values_up_to_known_statically(
const IndexTuple<T...>&) {
287 return is_compile_time_constant<
typename IndexTupleExtractor<0,
T...>::ValType>::value;
290 template <
typename...
T>
291 EIGEN_DEVICE_FUNC static constexpr bool values_up_to_statically_known_to_increase(
const IndexTuple<T...>&) {
299template<
typename FirstType,
typename... OtherTypes>
300struct IndexList : internal::IndexTuple<FirstType, OtherTypes...> {
302 return internal::tuple_coeff<internal::array_size<internal::IndexTuple<FirstType, OtherTypes...> >::value-1,
Index>
::get(
i, *
this);
305 return internal::tuple_coeff<internal::array_size<internal::IndexTuple<FirstType, OtherTypes...> >::value-1,
Index>
::get(
i, *
this);
308 return internal::tuple_coeff<internal::array_size<internal::IndexTuple<FirstType, OtherTypes...> >::value-1,
Index>
::set(
i, *
this, value);
311 EIGEN_DEVICE_FUNC constexpr IndexList(
const internal::IndexTuple<FirstType, OtherTypes...>& other) :
internal::IndexTuple<FirstType, OtherTypes...>(other) { }
312 EIGEN_DEVICE_FUNC constexpr IndexList(FirstType& first, OtherTypes... other) :
internal::IndexTuple<FirstType, OtherTypes...>(
first, other...) { }
316 return internal::tuple_coeff<internal::array_size<internal::IndexTuple<FirstType, OtherTypes...> >::value-1,
Index>::value_known_statically(
i, *
this);
319 return internal::tuple_coeff<internal::array_size<internal::IndexTuple<FirstType, OtherTypes...> >::value-1,
Index>::values_up_to_known_statically(*
this);
323 return internal::tuple_coeff<internal::array_size<internal::IndexTuple<FirstType, OtherTypes...> >::value-1,
Index>::values_up_to_statically_known_to_increase(*
this);
327template <
typename FirstType,
typename... OtherTypes>
329 const IndexList<FirstType, OtherTypes...>& dims) {
331 for (
size_t i = 0;
i < 1 +
sizeof...(OtherTypes); ++
i) {
332 if (
i > 0) os <<
", ";
339template<
typename FirstType,
typename... OtherTypes>
340constexpr IndexList<FirstType, OtherTypes...> make_index_list(FirstType val1, OtherTypes... other_vals) {
341 return IndexList<FirstType, OtherTypes...>(val1, other_vals...);
345template<
typename FirstType,
typename... OtherTypes>
346struct IndexPairList : internal::IndexTuple<FirstType, OtherTypes...> {
348 return internal::tuple_coeff<internal::array_size<internal::IndexTuple<FirstType, OtherTypes...> >::value-1,
IndexPair<Index>>
::get(
i, *
this);
351 return internal::tuple_coeff<internal::array_size<internal::IndexTuple<FirstType, OtherTypes...>>::value-1,
IndexPair<Index> >
::set(
i, *
this, value);
354 EIGEN_DEVICE_FUNC constexpr IndexPairList(
const internal::IndexTuple<FirstType, OtherTypes...>& other) :
internal::IndexTuple<FirstType, OtherTypes...>(other) { }
358 return internal::tuple_coeff<internal::array_size<internal::IndexTuple<FirstType, OtherTypes...> >::value-1,
Index>::value_known_statically(
i, *
this);
364template<
typename FirstType,
typename... OtherTypes>
368 for (
size_t i = 0;
i < array_size<IndexList<FirstType, OtherTypes...> >::value; ++
i) {
374template<
typename FirstType,
typename... OtherTypes>
struct array_size<IndexList<FirstType, OtherTypes...> > {
375 static const size_t value = array_size<IndexTuple<FirstType, OtherTypes...> >
::value;
377template<
typename FirstType,
typename... OtherTypes>
struct array_size<const IndexList<FirstType, OtherTypes...> > {
378 static const size_t value = array_size<IndexTuple<FirstType, OtherTypes...> >
::value;
381template<
typename FirstType,
typename... OtherTypes>
struct array_size<IndexPairList<FirstType, OtherTypes...> > {
382 static const size_t value = std::tuple_size<std::tuple<FirstType, OtherTypes...> >
::value;
384template<
typename FirstType,
typename... OtherTypes>
struct array_size<const IndexPairList<FirstType, OtherTypes...> > {
385 static const size_t value = std::tuple_size<std::tuple<FirstType, OtherTypes...> >
::value;
389 return IndexTupleExtractor<N, FirstType, OtherTypes...>::get_val(
a);
392 return IndexTupleExtractor<N, FirstType, OtherTypes...>::get_val(
a);
396struct index_known_statically_impl {
402template <
typename FirstType,
typename... OtherTypes>
403struct index_known_statically_impl<IndexList<FirstType, OtherTypes...> > {
405 return IndexList<FirstType, OtherTypes...>().value_known_statically(
i);
409template <
typename FirstType,
typename... OtherTypes>
410struct index_known_statically_impl<const IndexList<FirstType, OtherTypes...> > {
412 return IndexList<FirstType, OtherTypes...>().value_known_statically(
i);
418struct all_indices_known_statically_impl {
419 static constexpr bool run() {
424template <
typename FirstType,
typename... OtherTypes>
425struct all_indices_known_statically_impl<IndexList<FirstType, OtherTypes...> > {
427 return IndexList<FirstType, OtherTypes...>().all_values_known_statically();
431template <
typename FirstType,
typename... OtherTypes>
432struct all_indices_known_statically_impl<const IndexList<FirstType, OtherTypes...> > {
434 return IndexList<FirstType, OtherTypes...>().all_values_known_statically();
440struct indices_statically_known_to_increase_impl {
446template <
typename FirstType,
typename... OtherTypes>
447 struct indices_statically_known_to_increase_impl<IndexList<FirstType, OtherTypes...> > {
449 return Eigen::IndexList<FirstType, OtherTypes...>().values_statically_known_to_increase();
453template <
typename FirstType,
typename... OtherTypes>
454 struct indices_statically_known_to_increase_impl<const IndexList<FirstType, OtherTypes...> > {
456 return Eigen::IndexList<FirstType, OtherTypes...>().values_statically_known_to_increase();
461template <
typename Tx>
462struct index_statically_eq_impl {
468template <
typename FirstType,
typename... OtherTypes>
469struct index_statically_eq_impl<IndexList<FirstType, OtherTypes...> > {
471 return IndexList<FirstType, OtherTypes...>().value_known_statically(
i) &
472 (IndexList<FirstType, OtherTypes...>().
get(
i) == value);
476template <
typename FirstType,
typename... OtherTypes>
477struct index_statically_eq_impl<const IndexList<FirstType, OtherTypes...> > {
479 return IndexList<FirstType, OtherTypes...>().value_known_statically(
i) &
480 (IndexList<FirstType, OtherTypes...>().
get(
i) == value);
486struct index_statically_ne_impl {
492template <
typename FirstType,
typename... OtherTypes>
493struct index_statically_ne_impl<IndexList<FirstType, OtherTypes...> > {
495 return IndexList<FirstType, OtherTypes...>().value_known_statically(
i) &
496 (IndexList<FirstType, OtherTypes...>().
get(
i) != value);
500template <
typename FirstType,
typename... OtherTypes>
501struct index_statically_ne_impl<const IndexList<FirstType, OtherTypes...> > {
503 return IndexList<FirstType, OtherTypes...>().value_known_statically(
i) &
504 (IndexList<FirstType, OtherTypes...>().
get(
i) != value);
510struct index_statically_gt_impl {
516template <
typename FirstType,
typename... OtherTypes>
517struct index_statically_gt_impl<IndexList<FirstType, OtherTypes...> > {
519 return IndexList<FirstType, OtherTypes...>().value_known_statically(
i) &
520 (IndexList<FirstType, OtherTypes...>().
get(
i) > value);
524template <
typename FirstType,
typename... OtherTypes>
525struct index_statically_gt_impl<const IndexList<FirstType, OtherTypes...> > {
527 return IndexList<FirstType, OtherTypes...>().value_known_statically(
i) &
528 (IndexList<FirstType, OtherTypes...>().
get(
i) > value);
535struct index_statically_lt_impl {
541template <
typename FirstType,
typename... OtherTypes>
542struct index_statically_lt_impl<IndexList<FirstType, OtherTypes...> > {
544 return IndexList<FirstType, OtherTypes...>().value_known_statically(
i) &
545 (IndexList<FirstType, OtherTypes...>().
get(
i) < value);
549template <
typename FirstType,
typename... OtherTypes>
550struct index_statically_lt_impl<const IndexList<FirstType, OtherTypes...> > {
552 return IndexList<FirstType, OtherTypes...>().value_known_statically(
i) &
553 (IndexList<FirstType, OtherTypes...>().
get(
i) < value);
559template <
typename Tx>
560struct index_pair_first_statically_eq_impl {
566template <
typename FirstType,
typename... OtherTypes>
567struct index_pair_first_statically_eq_impl<IndexPairList<FirstType, OtherTypes...> > {
569 return IndexPairList<FirstType, OtherTypes...>().value_known_statically(
i) &
570 (IndexPairList<FirstType, OtherTypes...>().
operator[](
i).first == value);
574template <
typename FirstType,
typename... OtherTypes>
575struct index_pair_first_statically_eq_impl<const IndexPairList<FirstType, OtherTypes...> > {
577 return IndexPairList<FirstType, OtherTypes...>().value_known_statically(
i) &
578 (IndexPairList<FirstType, OtherTypes...>().
operator[](
i).first == value);
584template <
typename Tx>
585struct index_pair_second_statically_eq_impl {
591template <
typename FirstType,
typename... OtherTypes>
592struct index_pair_second_statically_eq_impl<IndexPairList<FirstType, OtherTypes...> > {
594 return IndexPairList<FirstType, OtherTypes...>().value_known_statically(
i) &
595 (IndexPairList<FirstType, OtherTypes...>().
operator[](
i).second == value);
599template <
typename FirstType,
typename... OtherTypes>
600struct index_pair_second_statically_eq_impl<const IndexPairList<FirstType, OtherTypes...> > {
602 return IndexPairList<FirstType, OtherTypes...>().value_known_statically(
i) &
603 (IndexPairList<FirstType, OtherTypes...>().
operator[](
i).second == value);
665template <
typename Tx>
672template <
typename Tx>
ArrayXXi a
Definition Array_initializer_list_23_cxx11.cpp:1
Array< int, Dynamic, 1 > v
Definition Array_initializer_list_vector_cxx11.cpp:1
int n
Definition BiCGSTAB_simple.cpp:1
int i
Definition BiCGSTAB_step_by_step.cpp:9
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE FixedSegmentReturnType< internal::get_fixed_value< NType >::value >::Type head(NType n)
Definition BlockMethods.h:1208
MatrixXcd V
Definition EigenSolver_EigenSolver_MatrixType.cpp:15
#define EIGEN_ALWAYS_INLINE
Definition Macros.h:932
#define EIGEN_UNROLL_LOOP
Definition Macros.h:1461
#define EIGEN_CONSTEXPR
Definition Macros.h:787
#define EIGEN_DEVICE_FUNC
Definition Macros.h:976
#define eigen_assert(x)
Definition Macros.h:1037
#define EIGEN_STRONG_INLINE
Definition Macros.h:917
Eigen::Triplet< double > T
Definition Tutorial_sparse_example.cpp:6
mp::number< mp::cpp_dec_float< 100 >, mp::et_on > Real
Definition boostmultiprec.cpp:78
@ N
Definition constructor.cpp:23
std::vector< Array2i > sizes
Definition dense_solvers.cpp:12
std::pair< Index, Index > IndexPair
Definition indexed_view.cpp:43
RealScalar s
Definition level1_cplx_impl.h:126
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::ptrdiff_t array_prod(const Sizes< Indices... > &)
Definition TensorDimensions.h:140
const Index array_get(DimensionList< Index, Rank > &)
Definition TensorDimensionList.h:39
EIGEN_CONSTEXPR Index first(const T &x) EIGEN_NOEXCEPT
Definition IndexedViewHelper.h:81
Namespace containing all symbols from the Eigen library.
Definition bench_norm.cpp:85
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:74
std::ostream & operator<<(std::ostream &os, const DSizes< IndexType, NumDims > &dims)
Definition TensorDimensions.h:387
Definition BandTriangularSolver.h:13
uint8_t count
Definition ref_serial.h:256
real function second()
SECOND returns nothing
Definition second_NONE.f:39
Container::iterator get(Container &c, Position position)
Definition stdlist_overload.cpp:29
void set(Container &c, Position position, const Value &value)
Definition stdlist_overload.cpp:37
T Real
Definition NumTraits.h:164
@ RequireInitialization
Definition NumTraits.h:158
@ ReadCost
Definition NumTraits.h:159
@ AddCost
Definition NumTraits.h:160
@ IsComplex
Definition NumTraits.h:157
@ MulCost
Definition NumTraits.h:161
Definition TensorIndexList.h:624
static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run()
Definition TensorIndexList.h:625
@ value
Definition Meta.h:446
Definition TensorIndexList.h:617
static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(const Index)
Definition TensorIndexList.h:618
Definition TensorIndexList.h:666
static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(Index, Index)
Definition TensorIndexList.h:667
Definition TensorIndexList.h:673
static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(Index, Index)
Definition TensorIndexList.h:674
Definition TensorIndexList.h:638
static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(Index, Index)
Definition TensorIndexList.h:639
Definition TensorIndexList.h:652
static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(Index, Index)
Definition TensorIndexList.h:653
Definition TensorIndexList.h:659
static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(Index, Index)
Definition TensorIndexList.h:660
Definition TensorIndexList.h:645
static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(Index, Index)
Definition TensorIndexList.h:646
Definition TensorIndexList.h:631
static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run()
Definition TensorIndexList.h:632