10#ifndef EIGEN_EMULATE_CXX11_META_H
11#define EIGEN_EMULATE_CXX11_META_H
25struct empty_list {
static const std::size_t count = 0; };
27template<
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;
37template<
typename T1 = null_type,
typename T2 = null_type,
typename T3 = null_type,
38 typename T4 = null_type,
typename T5 = null_type,
typename T6 = null_type,
39 typename T7 = null_type,
typename T8 = null_type>
40struct make_type_list {
41 typedef typename make_type_list<T2, T3, T4, T5, T6, T7, T8>::type tailresult;
43 typedef type_list<T1, tailresult> type;
46template<>
struct make_type_list<> {
47 typedef empty_list type;
51template <std::
size_t index,
class TList>
struct get_type;
53template <
class Head,
class Tail>
54struct get_type<0, type_list<Head, Tail> >
59template <std::
size_t i,
class Head,
class Tail>
60struct get_type<i, type_list<Head, Tail> >
62 typedef typename get_type<i-1, Tail>::type type;
67template <
typename T, T n>
70 static const T value = n;
74template<
typename T,
size_t n, T V>
struct gen_numeric_list_repeated;
76template<
typename T, T V>
struct gen_numeric_list_repeated<T, 1, V> {
77 typedef typename make_type_list<type2val<T, V> >::type type;
80template<
typename T, T V>
struct gen_numeric_list_repeated<T, 2, V> {
81 typedef typename make_type_list<type2val<T, V>, type2val<T, V> >::type type;
84template<
typename T, T V>
struct gen_numeric_list_repeated<T, 3, V> {
85 typedef typename make_type_list<type2val<T, V>, type2val<T, V>, type2val<T, V> >::type type;
88template<
typename T, T V>
struct gen_numeric_list_repeated<T, 4, V> {
89 typedef typename make_type_list<type2val<T, V>, type2val<T, V>, type2val<T, V>, type2val<T, V> >::type type;
92template<
typename T, T V>
struct gen_numeric_list_repeated<T, 5, V> {
93 typedef typename make_type_list<type2val<T, V>, type2val<T, V>, type2val<T, V>, type2val<T, V>, type2val<T, V> >::type type;
96template<
typename T, T V>
struct gen_numeric_list_repeated<T, 6, V> {
97 typedef typename make_type_list<type2val<T, V>, type2val<T, V>, type2val<T, V>,
98 type2val<T, V>, type2val<T, V>, type2val<T, V> >::type type;
101template<
typename T, T V>
struct gen_numeric_list_repeated<T, 7, V> {
102 typedef typename make_type_list<type2val<T, V>, type2val<T, V>, type2val<T, V>,
103 type2val<T, V>, type2val<T, V>, type2val<T, V>,
104 type2val<T, V> >::type type;
107template<
typename T, T V>
struct gen_numeric_list_repeated<T, 8, V> {
108 typedef typename make_type_list<type2val<T, V>, type2val<T, V>, type2val<T, V>,
109 type2val<T, V>, type2val<T, V>, type2val<T, V>,
110 type2val<T, V>, type2val<T, V> >::type type;
114template <std::
size_t index,
class NList>
struct get;
116template <std::
size_t i>
117struct get<i, empty_list>
119 get() { eigen_assert(
false &&
"index overflow"); }
121 static const char value =
'\0';
124template <std::
size_t i,
class Head>
125struct get<i, type_list<Head, empty_list> >
127 get() { eigen_assert(
false &&
"index overflow"); }
129 static const char value =
'\0';
133struct get<0, type_list<Head, empty_list> >
135 typedef typename Head::type type;
136 static const type value = Head::value;
139template <
class Head,
class Tail>
140struct get<0, type_list<Head, Tail> >
142 typedef typename Head::type type;
143 static const type value = Head::value;
146template <std::
size_t i,
class Head,
class Tail>
147struct get<i, type_list<Head, Tail> >
149 typedef typename Tail::HeadType::type type;
150 static const type value = get<i-1, Tail>::value;
154template <
class NList>
struct arg_prod {
155 static const typename NList::HeadType::type value = get<0, NList>::value * arg_prod<typename NList::TailType>::value;
157template <>
struct arg_prod<empty_list> {
158 static const int value = 1;
162template<
int n,
typename t>
163array<t, n> repeat(t v) {
169template<std::
size_t I,
class Head,
class Tail>
170EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
typename Head::type array_get(type_list<Head, Tail>&) {
171 return get<I, type_list<Head, Tail> >::value;
173template<std::
size_t I,
class Head,
class Tail>
174EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
typename Head::type array_get(
const type_list<Head, Tail>&) {
175 return get<I, type_list<Head, Tail> >::value;
178template <
class NList>
179EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
typename NList::HeadType::type array_prod(
const NList&) {
180 return arg_prod<NList>::value;
183template<
typename t, std::
size_t n>
184EIGEN_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]; }
190EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE t array_prod(
const array<t, 0>& ) {
195EIGEN_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]; }
203template<std::
size_t I,
class T>
204EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T& array_get(std::vector<T>& a) {
207template<std::
size_t I,
class T>
208EIGEN_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; }
219struct logical_and_op {
220 template<
typename A,
typename B>
static inline bool run(A a, B b) {
return a && b; }
222struct logical_or_op {
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; }
235struct lesser_equal_op {
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; }
242struct greater_equal_op {
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; }
252struct greater_equal_zero_op {
253 template<
typename A>
static inline bool run(A a) {
return a >= 0; }
257template<
typename Reducer,
typename Op,
typename A, std::
size_t N>
258struct ArrayApplyAndReduce {
259 static inline bool run(
const array<A, N>& a) {
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]));
269template<
typename Reducer,
typename Op,
typename A>
270struct ArrayApplyAndReduce<Reducer, Op, A, 1> {
271 static inline bool run(
const array<A, 1>& a) {
272 return Op::run(a[0]);
276template<
typename Reducer,
typename Op,
typename A, std::
size_t N>
277inline bool array_apply_and_reduce(
const array<A, N>& a) {
278 return ArrayApplyAndReduce<Reducer, Op, A, N>::run(a);
281template<
typename Reducer,
typename Op,
typename A,
typename B, std::
size_t N>
282struct ArrayZipAndReduce {
283 static inline bool run(
const array<A, N>& a,
const array<B, N>& b) {
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]));
293template<
typename Reducer,
typename Op,
typename A,
typename B>
294struct ArrayZipAndReduce<Reducer, Op, A, B, 1> {
295 static inline bool run(
const array<A, 1>& a,
const array<B, 1>& b) {
296 return Op::run(a[0], b[0]);
300template<
typename Reducer,
typename Op,
typename A,
typename B, std::
size_t N>
301inline bool array_zip_and_reduce(
const array<A, N>& a,
const array<B, N>& b) {
302 return ArrayZipAndReduce<Reducer, Op, A, B, N>::run(a, b);
Namespace containing all symbols from the Eigen library.
Definition: AdolcForward:45