Please, help us to better know about our user community by answering the following short survey: https://forms.gle/wpyrxWi18ox9Z5ae9
 
Loading...
Searching...
No Matches
TensorDimensionList.h
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
13namespace Eigen {
14
25template <typename Index, std::size_t Rank> struct DimensionList {
26 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
27 const Index operator[] (const Index i) const { return i; }
28};
29
30namespace internal {
31
32template<typename Index, std::size_t Rank> struct array_size<DimensionList<Index, Rank> > {
33 static const size_t value = Rank;
34};
35template<typename Index, std::size_t Rank> struct array_size<const DimensionList<Index, Rank> > {
36 static const size_t value = Rank;
37};
38
39template<DenseIndex n, typename Index, std::size_t Rank> const Index array_get(DimensionList<Index, Rank>&) {
40 return n;
41}
42template<DenseIndex n, typename Index, std::size_t Rank> const Index array_get(const DimensionList<Index, Rank>&) {
43 return n;
44}
45
46
47#if EIGEN_HAS_CONSTEXPR
48template <typename Index, std::size_t Rank>
49struct index_known_statically_impl<DimensionList<Index, Rank> > {
50 EIGEN_DEVICE_FUNC static constexpr bool run(const DenseIndex) {
51 return true;
52 }
53};
54template <typename Index, std::size_t Rank>
55struct index_known_statically_impl<const DimensionList<Index, Rank> > {
56 EIGEN_DEVICE_FUNC static constexpr bool run(const DenseIndex) {
57 return true;
58 }
59};
60
61template <typename Index, std::size_t Rank>
62struct all_indices_known_statically_impl<DimensionList<Index, Rank> > {
63 EIGEN_DEVICE_FUNC static constexpr bool run() {
64 return true;
65 }
66};
67template <typename Index, std::size_t Rank>
68struct all_indices_known_statically_impl<const DimensionList<Index, Rank> > {
69 EIGEN_DEVICE_FUNC static constexpr bool run() {
70 return true;
71 }
72};
73
74template <typename Index, std::size_t Rank>
75struct indices_statically_known_to_increase_impl<DimensionList<Index, Rank> > {
76 EIGEN_DEVICE_FUNC static constexpr bool run() {
77 return true;
78 }
79};
80template <typename Index, std::size_t Rank>
81struct indices_statically_known_to_increase_impl<const DimensionList<Index, Rank> > {
82 EIGEN_DEVICE_FUNC static constexpr bool run() {
83 return true;
84 }
85};
86
87template <typename Index, std::size_t Rank>
88struct index_statically_eq_impl<DimensionList<Index, Rank> > {
89 static constexpr bool run(const DenseIndex i, const DenseIndex value) {
90 return i == value;
91 }
92};
93template <typename Index, std::size_t Rank>
94struct 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
100template <typename Index, std::size_t Rank>
101struct 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};
106template <typename Index, std::size_t Rank>
107struct 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
113template <typename Index, std::size_t Rank>
114struct 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};
119template <typename Index, std::size_t Rank>
120struct 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
126template <typename Index, std::size_t Rank>
127struct 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};
132template <typename Index, std::size_t Rank>
133struct 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#else
140template <typename Index, std::size_t Rank>
141struct index_known_statically_impl<DimensionList<Index, Rank> > {
142 EIGEN_DEVICE_FUNC static EIGEN_ALWAYS_INLINE bool run(const DenseIndex) {
143 return true;
144 }
145};
146template <typename Index, std::size_t Rank>
147struct index_known_statically_impl<const DimensionList<Index, Rank> > {
148 EIGEN_DEVICE_FUNC static EIGEN_ALWAYS_INLINE bool run(const DenseIndex) {
149 return true;
150 }
151};
152
153template <typename Index, std::size_t Rank>
154struct all_indices_known_statically_impl<DimensionList<Index, Rank> > {
155 EIGEN_DEVICE_FUNC static EIGEN_ALWAYS_INLINE bool run() {
156 return true;
157 }
158};
159template <typename Index, std::size_t Rank>
160struct all_indices_known_statically_impl<const DimensionList<Index, Rank> > {
161 EIGEN_DEVICE_FUNC static EIGEN_ALWAYS_INLINE bool run() {
162 return true;
163 }
164};
165
166template <typename Index, std::size_t Rank>
167struct indices_statically_known_to_increase_impl<DimensionList<Index, Rank> > {
168 static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run() {
169 return true;
170 }
171};
172template <typename Index, std::size_t Rank>
173struct indices_statically_known_to_increase_impl<const DimensionList<Index, Rank> > {
174 static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run() {
175 return true;
176 }
177};
178
179template <typename Index, std::size_t Rank>
180struct index_statically_eq_impl<DimensionList<Index, Rank> > {
181 static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(const DenseIndex, const DenseIndex) {
182 return false;
183 }
184};
185template <typename Index, std::size_t Rank>
186struct index_statically_eq_impl<const DimensionList<Index, Rank> > {
187 static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(const DenseIndex, const DenseIndex) {
188 return false;
189 }
190};
191
192template <typename Index, std::size_t Rank>
193struct index_statically_ne_impl<DimensionList<Index, Rank> > {
194 static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(const DenseIndex, const DenseIndex){
195 return false;
196 }
197};
198template <typename Index, std::size_t Rank>
199struct index_statically_ne_impl<const DimensionList<Index, Rank> > {
200 static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(const DenseIndex, const DenseIndex) {
201 return false;
202 }
203};
204
205template <typename Index, std::size_t Rank>
206struct index_statically_gt_impl<DimensionList<Index, Rank> > {
207 static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(const DenseIndex, const DenseIndex) {
208 return false;
209 }
210};
211template <typename Index, std::size_t Rank>
212struct index_statically_gt_impl<const DimensionList<Index, Rank> > {
213 static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(const DenseIndex, const DenseIndex) {
214 return false;
215 }
216};
217
218template <typename Index, std::size_t Rank>
219struct index_statically_lt_impl<DimensionList<Index, Rank> > {
220 static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(const DenseIndex, const DenseIndex) {
221 return false;
222 }
223};
224template <typename Index, std::size_t Rank>
225struct index_statically_lt_impl<const DimensionList<Index, Rank> > {
226 static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(const DenseIndex, const DenseIndex) {
227 return false;
228 }
229};
230#endif
231
232} // end namespace internal
233} // end namespace Eigen
234
235
236#endif // EIGEN_CXX11_TENSOR_TENSOR_DIMENSION_LIST_H
Namespace containing all symbols from the Eigen library.
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index