TensorDimensionList.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) 2015 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_DIMENSION_LIST_H
11 #define EIGEN_CXX11_TENSOR_TENSOR_DIMENSION_LIST_H
12 
13 #include "./InternalHeaderCheck.h"
14 
15 namespace Eigen {
16 
27 template <typename Index, std::size_t Rank> struct DimensionList {
29  const Index operator[] (const Index i) const { return i; }
30 };
31 
32 namespace internal {
33 
34 template<typename Index, std::size_t Rank> struct array_size<DimensionList<Index, Rank> > {
35  static const size_t value = Rank;
36 };
37 template<typename Index, std::size_t Rank> struct array_size<const DimensionList<Index, Rank> > {
38  static const size_t value = Rank;
39 };
40 
41 template<DenseIndex n, typename Index, std::size_t Rank> const Index array_get(DimensionList<Index, Rank>&) {
42  return n;
43 }
44 template<DenseIndex n, typename Index, std::size_t Rank> const Index array_get(const DimensionList<Index, Rank>&) {
45  return n;
46 }
47 
48 template <typename Index, std::size_t Rank>
49 struct index_known_statically_impl<DimensionList<Index, Rank> > {
50  EIGEN_DEVICE_FUNC static constexpr bool run(const DenseIndex) {
51  return true;
52  }
53 };
54 template <typename Index, std::size_t Rank>
55 struct index_known_statically_impl<const DimensionList<Index, Rank> > {
56  EIGEN_DEVICE_FUNC static constexpr bool run(const DenseIndex) {
57  return true;
58  }
59 };
60 
61 template <typename Index, std::size_t Rank>
62 struct all_indices_known_statically_impl<DimensionList<Index, Rank> > {
63  EIGEN_DEVICE_FUNC static constexpr bool run() {
64  return true;
65  }
66 };
67 template <typename Index, std::size_t Rank>
68 struct all_indices_known_statically_impl<const DimensionList<Index, Rank> > {
69  EIGEN_DEVICE_FUNC static constexpr bool run() {
70  return true;
71  }
72 };
73 
74 template <typename Index, std::size_t Rank>
75 struct indices_statically_known_to_increase_impl<DimensionList<Index, Rank> > {
76  EIGEN_DEVICE_FUNC static constexpr bool run() {
77  return true;
78  }
79 };
80 template <typename Index, std::size_t Rank>
81 struct indices_statically_known_to_increase_impl<const DimensionList<Index, Rank> > {
82  EIGEN_DEVICE_FUNC static constexpr bool run() {
83  return true;
84  }
85 };
86 
87 template <typename Index, std::size_t Rank>
88 struct index_statically_eq_impl<DimensionList<Index, Rank> > {
89  static constexpr bool run(const DenseIndex i, const DenseIndex value) {
90  return i == value;
91  }
92 };
93 template <typename Index, std::size_t Rank>
94 struct index_statically_eq_impl<const DimensionList<Index, Rank> > {
95  EIGEN_DEVICE_FUNC static constexpr bool run(const DenseIndex i, const DenseIndex value) {
96  return i == value;
97  }
98 };
99 
100 template <typename Index, std::size_t Rank>
101 struct index_statically_ne_impl<DimensionList<Index, Rank> > {
102  EIGEN_DEVICE_FUNC static constexpr bool run(const DenseIndex i, const DenseIndex value) {
103  return i != value;
104  }
105 };
106 template <typename Index, std::size_t Rank>
107 struct index_statically_ne_impl<const DimensionList<Index, Rank> > {
108  static constexpr bool run(const DenseIndex i, const DenseIndex value) {
109  return i != value;
110  }
111 };
112 
113 template <typename Index, std::size_t Rank>
114 struct index_statically_gt_impl<DimensionList<Index, Rank> > {
115  EIGEN_DEVICE_FUNC static constexpr bool run(const DenseIndex i, const DenseIndex value) {
116  return i > value;
117  }
118 };
119 template <typename Index, std::size_t Rank>
120 struct index_statically_gt_impl<const DimensionList<Index, Rank> > {
121  EIGEN_DEVICE_FUNC static constexpr bool run(const DenseIndex i, const DenseIndex value) {
122  return i > value;
123  }
124 };
125 
126 template <typename Index, std::size_t Rank>
127 struct index_statically_lt_impl<DimensionList<Index, Rank> > {
128  EIGEN_DEVICE_FUNC static constexpr bool run(const DenseIndex i, const DenseIndex value) {
129  return i < value;
130  }
131 };
132 template <typename Index, std::size_t Rank>
133 struct index_statically_lt_impl<const DimensionList<Index, Rank> > {
134  EIGEN_DEVICE_FUNC static constexpr bool run(const DenseIndex i, const DenseIndex value) {
135  return i < value;
136  }
137 };
138 
139 } // end namespace internal
140 } // end namespace Eigen
141 
142 
143 #endif // EIGEN_CXX11_TENSOR_TENSOR_DIMENSION_LIST_H
int n
int i
#define EIGEN_ALWAYS_INLINE
#define EIGEN_DEVICE_FUNC
constexpr T array_get(const numeric_list< T, a, as... > &)
: TensorContractionSycl.h, provides various tensor contraction kernel for SYCL backend
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
EIGEN_DEFAULT_DENSE_INDEX_TYPE DenseIndex
EIGEN_ALWAYS_INLINE const Index operator[](const Index i) const