10 #ifndef EIGEN_EMULATE_CXX11_META_H 11 #define EIGEN_EMULATE_CXX11_META_H 25 struct empty_list {
static const std::size_t count = 0; };
27 template<
typename T,
typename Tail=empty_list>
struct type_list {
29 typedef Tail TailType;
31 static const Tail tail;
32 static const std::size_t count = 1 + Tail::count;
51 template <std::
size_t index,
class TList>
struct get_type;
53 template <
class Head,
class Tail>
59 template <std::
size_t i,
class Head,
class Tail>
62 typedef typename get_type<i-1, Tail>::type type;
67 template <
typename T, T n>
70 static const T value = n;
98 type2val<T, V>, type2val<T, V>, type2val<T, V> >
::type type;
103 type2val<T, V>, type2val<T, V>, type2val<T, V>,
109 type2val<T, V>, type2val<T, V>, type2val<T, V>,
114 template <std::
size_t index,
class NList>
struct get;
116 template <std::
size_t i>
119 get() { eigen_assert(
false &&
"index overflow"); }
121 static const char value =
'\0';
124 template <std::
size_t i,
class Head>
127 get() { eigen_assert(
false &&
"index overflow"); }
129 static const char value =
'\0';
132 template <
class Head>
135 typedef typename Head::type type;
136 static const type value = Head::value;
139 template <
class Head,
class Tail>
142 typedef typename Head::type type;
143 static const type value = Head::value;
146 template <std::
size_t i,
class Head,
class Tail>
149 typedef typename Tail::HeadType::type type;
150 static const type value =
get<i-1, Tail>::value;
158 static const int value = 1;
162 template<
int n,
typename t>
169 template<std::
size_t I,
class Head,
class Tail>
173 template<std::
size_t I,
class Head,
class Tail>
178 template <
class NList>
179 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
typename NList::HeadType::type array_prod(
const NList&) {
183 template<
typename t, std::
size_t n>
184 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE t array_prod(
const array<t, n>& a) {
186 for (
size_t i = 0; i < n; ++i) { prod *= a[i]; }
190 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE t array_prod(
const array<t, 0>& ) {
195 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE t array_prod(
const std::vector<t>& a) {
196 eigen_assert(a.size() > 0);
198 for (
size_t i = 0; i < a.size(); ++i) { prod *= a[i]; }
203 template<std::
size_t I,
class T>
204 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
T& array_get(std::vector<T>& a) {
207 template<std::
size_t I,
class T>
208 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
const T& array_get(
const std::vector<T>& a) {
213 template<
typename A,
typename B>
static inline bool run(
A a,
B b) {
return a + b; }
216 template<
typename A,
typename B>
static inline bool run(
A a,
B b) {
return a * b; }
220 template<
typename A,
typename B>
static inline bool run(
A a,
B b) {
return a && b; }
223 template<
typename A,
typename B>
static inline bool run(
A a,
B b) {
return a || b; }
227 template<
typename A,
typename B>
static inline bool run(
A a,
B b) {
return a == b; }
230 template<
typename A,
typename B>
static inline bool run(
A a,
B b) {
return a != b; }
233 template<
typename A,
typename B>
static inline bool run(
A a,
B b) {
return a < b; }
236 template<
typename A,
typename B>
static inline bool run(
A a,
B b) {
return a <= b; }
240 template<
typename A,
typename B>
static inline bool run(
A a,
B b) {
return a > b; }
243 template<
typename A,
typename B>
static inline bool run(
A a,
B b) {
return a >= b; }
247 template<
typename A>
static inline bool run(
A a) {
return !a; }
250 template<
typename A>
static inline bool run(
A a) {
return -a; }
253 template<
typename A>
static inline bool run(
A a) {
return a >= 0; }
257 template<
typename Reducer,
typename Op,
typename A, std::
size_t N>
260 EIGEN_STATIC_ASSERT(N >= 2, YOU_MADE_A_PROGRAMMING_MISTAKE);
261 bool result = Reducer::run(Op::run(a[0]), Op::run(a[1]));
262 for (
size_t i = 2; i < N; ++i) {
263 result = Reducer::run(result, Op::run(a[i]));
269 template<
typename Reducer,
typename Op,
typename A>
272 return Op::run(a[0]);
276 template<
typename Reducer,
typename Op,
typename A, std::
size_t N>
277 inline bool array_apply_and_reduce(
const array<A, N>& a) {
281 template<
typename Reducer,
typename Op,
typename A,
typename B, std::
size_t N>
284 EIGEN_STATIC_ASSERT(N >= 2, YOU_MADE_A_PROGRAMMING_MISTAKE);
285 bool result = Reducer::run(Op::run(a[0], b[0]), Op::run(a[1], b[1]));
286 for (
size_t i = 2; i < N; ++i) {
287 result = Reducer::run(result, Op::run(a[i], b[i]));
293 template<
typename Reducer,
typename Op,
typename A,
typename B>
296 return Op::run(a[0], b[0]);
300 template<
typename Reducer,
typename Op,
typename A,
typename B, std::
size_t N>
311 #endif // EIGEN_EMULATE_CXX11_META_H Definition: EmulateCXX11Meta.h:35
Definition: EmulateCXX11Meta.h:74
Definition: EmulateCXX11Meta.h:40
Definition: EmulateCXX11Meta.h:226
Definition: EmulateCXX11Meta.h:27
Definition: EmulateCXX11Meta.h:229
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:85
Definition: EmulateCXX11Meta.h:114
Definition: EmulateCXX11Meta.h:235
Definition: EmulateCXX11Meta.h:25
Definition: EmulateCXX11Meta.h:212
Definition: EmulateCXX11Meta.h:154
Definition: EmulateCXX11Meta.h:282
Definition: EmulateCXX11Meta.h:258
Definition: EmulateCXX11Meta.h:252
Definition: EmulateCXX11Meta.h:222
Definition: EmulateCXX11Meta.h:239
Definition: EmulateArray.h:21
Definition: EmulateCXX11Meta.h:219
Definition: BandTriangularSolver.h:13
Definition: EmulateCXX11Meta.h:246
Definition: EmulateCXX11Meta.h:68
Definition: EmulateCXX11Meta.h:232
Definition: EmulateCXX11Meta.h:249
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:178
Definition: EmulateCXX11Meta.h:215
Definition: EmulateCXX11Meta.h:242
Definition: EmulateCXX11Meta.h:51