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
23template <typename Index, std::size_t Rank>
24struct DimensionList {
25 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE const Index operator[](const Index i) const { return i; }
26};
27
28namespace internal {
29
30template<typename Index, std::size_t Rank> struct array_size<DimensionList<Index, Rank> > {
31 static const size_t value = Rank;
32};
33template<typename Index, std::size_t Rank> struct array_size<const DimensionList<Index, Rank> > {
34 static const size_t value = Rank;
35};
36
37template<DenseIndex n, typename Index, std::size_t Rank> const Index array_get(DimensionList<Index, Rank>&) {
38 return n;
39}
40template<DenseIndex n, typename Index, std::size_t Rank> const Index array_get(const DimensionList<Index, Rank>&) {
41 return n;
42}
43
44
45#if EIGEN_HAS_CONSTEXPR
46template <typename Index, std::size_t Rank>
47struct index_known_statically_impl<DimensionList<Index, Rank> > {
48 EIGEN_DEVICE_FUNC static constexpr bool run(const DenseIndex) {
49 return true;
50 }
51};
52template <typename Index, std::size_t Rank>
53struct index_known_statically_impl<const DimensionList<Index, Rank> > {
54 EIGEN_DEVICE_FUNC static constexpr bool run(const DenseIndex) {
55 return true;
56 }
57};
58
59template <typename Index, std::size_t Rank>
60struct all_indices_known_statically_impl<DimensionList<Index, Rank> > {
61 EIGEN_DEVICE_FUNC static constexpr bool run() {
62 return true;
63 }
64};
65template <typename Index, std::size_t Rank>
66struct all_indices_known_statically_impl<const DimensionList<Index, Rank> > {
67 EIGEN_DEVICE_FUNC static constexpr bool run() {
68 return true;
69 }
70};
71
72template <typename Index, std::size_t Rank>
73struct indices_statically_known_to_increase_impl<DimensionList<Index, Rank> > {
74 EIGEN_DEVICE_FUNC static constexpr bool run() {
75 return true;
76 }
77};
78template <typename Index, std::size_t Rank>
79struct indices_statically_known_to_increase_impl<const DimensionList<Index, Rank> > {
80 EIGEN_DEVICE_FUNC static constexpr bool run() {
81 return true;
82 }
83};
84
85template <typename Index, std::size_t Rank>
86struct index_statically_eq_impl<DimensionList<Index, Rank> > {
87 static constexpr bool run(const DenseIndex i, const DenseIndex value) {
88 return i == value;
89 }
90};
91template <typename Index, std::size_t Rank>
92struct index_statically_eq_impl<const DimensionList<Index, Rank> > {
93 EIGEN_DEVICE_FUNC static constexpr bool run(const DenseIndex i, const DenseIndex value) {
94 return i == value;
95 }
96};
97
98template <typename Index, std::size_t Rank>
99struct index_statically_ne_impl<DimensionList<Index, Rank> > {
100 EIGEN_DEVICE_FUNC static constexpr bool run(const DenseIndex i, const DenseIndex value) {
101 return i != value;
102 }
103};
104template <typename Index, std::size_t Rank>
105struct index_statically_ne_impl<const DimensionList<Index, Rank> > {
106 static constexpr bool run(const DenseIndex i, const DenseIndex value) {
107 return i != value;
108 }
109};
110
111template <typename Index, std::size_t Rank>
112struct index_statically_gt_impl<DimensionList<Index, Rank> > {
113 EIGEN_DEVICE_FUNC static constexpr bool run(const DenseIndex i, const DenseIndex value) {
114 return i > value;
115 }
116};
117template <typename Index, std::size_t Rank>
118struct index_statically_gt_impl<const DimensionList<Index, Rank> > {
119 EIGEN_DEVICE_FUNC static constexpr bool run(const DenseIndex i, const DenseIndex value) {
120 return i > value;
121 }
122};
123
124template <typename Index, std::size_t Rank>
125struct index_statically_lt_impl<DimensionList<Index, Rank> > {
126 EIGEN_DEVICE_FUNC static constexpr bool run(const DenseIndex i, const DenseIndex value) {
127 return i < value;
128 }
129};
130template <typename Index, std::size_t Rank>
131struct index_statically_lt_impl<const DimensionList<Index, Rank> > {
132 EIGEN_DEVICE_FUNC static constexpr bool run(const DenseIndex i, const DenseIndex value) {
133 return i < value;
134 }
135};
136
137#else
138template <typename Index, std::size_t Rank>
139struct index_known_statically_impl<DimensionList<Index, Rank> > {
140 EIGEN_DEVICE_FUNC static EIGEN_ALWAYS_INLINE bool run(const DenseIndex) {
141 return true;
142 }
143};
144template <typename Index, std::size_t Rank>
145struct index_known_statically_impl<const DimensionList<Index, Rank> > {
146 EIGEN_DEVICE_FUNC static EIGEN_ALWAYS_INLINE bool run(const DenseIndex) {
147 return true;
148 }
149};
150
151template <typename Index, std::size_t Rank>
152struct all_indices_known_statically_impl<DimensionList<Index, Rank> > {
153 EIGEN_DEVICE_FUNC static EIGEN_ALWAYS_INLINE bool run() {
154 return true;
155 }
156};
157template <typename Index, std::size_t Rank>
158struct all_indices_known_statically_impl<const DimensionList<Index, Rank> > {
159 EIGEN_DEVICE_FUNC static EIGEN_ALWAYS_INLINE bool run() {
160 return true;
161 }
162};
163
164template <typename Index, std::size_t Rank>
165struct indices_statically_known_to_increase_impl<DimensionList<Index, Rank> > {
166 static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run() {
167 return true;
168 }
169};
170template <typename Index, std::size_t Rank>
171struct indices_statically_known_to_increase_impl<const DimensionList<Index, Rank> > {
172 static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run() {
173 return true;
174 }
175};
176
177template <typename Index, std::size_t Rank>
178struct index_statically_eq_impl<DimensionList<Index, Rank> > {
179 static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(const DenseIndex, const DenseIndex) {
180 return false;
181 }
182};
183template <typename Index, std::size_t Rank>
184struct index_statically_eq_impl<const DimensionList<Index, Rank> > {
185 static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(const DenseIndex, const DenseIndex) {
186 return false;
187 }
188};
189
190template <typename Index, std::size_t Rank>
191struct index_statically_ne_impl<DimensionList<Index, Rank> > {
192 static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(const DenseIndex, const DenseIndex){
193 return false;
194 }
195};
196template <typename Index, std::size_t Rank>
197struct index_statically_ne_impl<const DimensionList<Index, Rank> > {
198 static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(const DenseIndex, const DenseIndex) {
199 return false;
200 }
201};
202
203template <typename Index, std::size_t Rank>
204struct index_statically_gt_impl<DimensionList<Index, Rank> > {
205 static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(const DenseIndex, const DenseIndex) {
206 return false;
207 }
208};
209template <typename Index, std::size_t Rank>
210struct index_statically_gt_impl<const DimensionList<Index, Rank> > {
211 static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(const DenseIndex, const DenseIndex) {
212 return false;
213 }
214};
215
216template <typename Index, std::size_t Rank>
217struct index_statically_lt_impl<DimensionList<Index, Rank> > {
218 static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(const DenseIndex, const DenseIndex) {
219 return false;
220 }
221};
222template <typename Index, std::size_t Rank>
223struct index_statically_lt_impl<const DimensionList<Index, Rank> > {
224 static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(const DenseIndex, const DenseIndex) {
225 return false;
226 }
227};
228#endif
229
230} // end namespace internal
231} // end namespace Eigen
232
233
234#endif // EIGEN_CXX11_TENSOR_TENSOR_DIMENSION_LIST_H
Namespace containing all symbols from the Eigen library.
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index