17 using Eigen::internal::numeric_list;
18 using Eigen::internal::gen_numeric_list;
19 using Eigen::internal::gen_numeric_list_reversed;
20 using Eigen::internal::gen_numeric_list_swapped_pair;
22 using Eigen::internal::concat;
23 using Eigen::internal::mconcat;
24 using Eigen::internal::take;
25 using Eigen::internal::skip;
26 using Eigen::internal::slice;
28 using Eigen::internal::id_numeric;
29 using Eigen::internal::id_type;
30 using Eigen::internal::is_same_gf;
31 using Eigen::internal::apply_op_from_left;
32 using Eigen::internal::apply_op_from_right;
33 using Eigen::internal::contained_in_list;
34 using Eigen::internal::contained_in_list_gf;
36 using Eigen::internal::arg_sum;
39 using Eigen::internal::array_reverse;
40 using Eigen::internal::array_sum;
42 using Eigen::internal::array_reduce;
43 using Eigen::internal::array_zip;
45 using Eigen::internal::array_apply;
48 using Eigen::internal::instantiate_by_c_array;
57 template<
typename A,
typename B>
struct dummy_op;
68 template<
typename A,
typename B>
struct dummy_test { constexpr
static bool value =
false; constexpr
static int global_flags = 0; };
73 struct times2_op {
template<
typename A>
static A run(
A v) {
return v * 2; } };
89 VERIFY((
is_same<
typename gen_numeric_list<int, 0>::type, numeric_list<int>>::value));
90 VERIFY((
is_same<
typename gen_numeric_list<int, 1>::type, numeric_list<int, 0>>::value));
91 VERIFY((
is_same<
typename gen_numeric_list<int, 2>::type, numeric_list<int, 0, 1>>::value));
92 VERIFY((
is_same<
typename gen_numeric_list<int, 5>::type, numeric_list<int, 0, 1, 2, 3, 4>>::value));
93 VERIFY((
is_same<
typename gen_numeric_list<int, 10>::type, numeric_list<int, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9>>::value));
95 VERIFY((
is_same<
typename gen_numeric_list<int, 0, 42>::type, numeric_list<int>>::value));
96 VERIFY((
is_same<
typename gen_numeric_list<int, 1, 42>::type, numeric_list<int, 42>>::value));
97 VERIFY((
is_same<
typename gen_numeric_list<int, 2, 42>::type, numeric_list<int, 42, 43>>::value));
98 VERIFY((
is_same<
typename gen_numeric_list<int, 5, 42>::type, numeric_list<int, 42, 43, 44, 45, 46>>::value));
99 VERIFY((
is_same<
typename gen_numeric_list<int, 10, 42>::type, numeric_list<int, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51>>::value));
101 VERIFY((
is_same<
typename gen_numeric_list_reversed<int, 0>::type, numeric_list<int>>::value));
102 VERIFY((
is_same<
typename gen_numeric_list_reversed<int, 1>::type, numeric_list<int, 0>>::value));
103 VERIFY((
is_same<
typename gen_numeric_list_reversed<int, 2>::type, numeric_list<int, 1, 0>>::value));
104 VERIFY((
is_same<
typename gen_numeric_list_reversed<int, 5>::type, numeric_list<int, 4, 3, 2, 1, 0>>::value));
105 VERIFY((
is_same<
typename gen_numeric_list_reversed<int, 10>::type, numeric_list<int, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0>>::value));
107 VERIFY((
is_same<
typename gen_numeric_list_reversed<int, 0, 42>::type, numeric_list<int>>::value));
108 VERIFY((
is_same<
typename gen_numeric_list_reversed<int, 1, 42>::type, numeric_list<int, 42>>::value));
109 VERIFY((
is_same<
typename gen_numeric_list_reversed<int, 2, 42>::type, numeric_list<int, 43, 42>>::value));
110 VERIFY((
is_same<
typename gen_numeric_list_reversed<int, 5, 42>::type, numeric_list<int, 46, 45, 44, 43, 42>>::value));
111 VERIFY((
is_same<
typename gen_numeric_list_reversed<int, 10, 42>::type, numeric_list<int, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42>>::value));
113 VERIFY((
is_same<
typename gen_numeric_list_swapped_pair<int, 0, 2, 3>::type, numeric_list<int>>::value));
114 VERIFY((
is_same<
typename gen_numeric_list_swapped_pair<int, 1, 2, 3>::type, numeric_list<int, 0>>::value));
115 VERIFY((
is_same<
typename gen_numeric_list_swapped_pair<int, 2, 2, 3>::type, numeric_list<int, 0, 1>>::value));
116 VERIFY((
is_same<
typename gen_numeric_list_swapped_pair<int, 5, 2, 3>::type, numeric_list<int, 0, 1, 3, 2, 4>>::value));
117 VERIFY((
is_same<
typename gen_numeric_list_swapped_pair<int, 10, 2, 3>::type, numeric_list<int, 0, 1, 3, 2, 4, 5, 6, 7, 8, 9>>::value));
119 VERIFY((
is_same<
typename gen_numeric_list_swapped_pair<int, 0, 44, 45, 42>::type, numeric_list<int>>::value));
120 VERIFY((
is_same<
typename gen_numeric_list_swapped_pair<int, 1, 44, 45, 42>::type, numeric_list<int, 42>>::value));
121 VERIFY((
is_same<
typename gen_numeric_list_swapped_pair<int, 2, 44, 45, 42>::type, numeric_list<int, 42, 43>>::value));
122 VERIFY((
is_same<
typename gen_numeric_list_swapped_pair<int, 5, 44, 45, 42>::type, numeric_list<int, 42, 43, 45, 44, 46>>::value));
123 VERIFY((
is_same<
typename gen_numeric_list_swapped_pair<int, 10, 44, 45, 42>::type, numeric_list<int, 42, 43, 45, 44, 46, 47, 48, 49, 50, 51>>::value));
129 VERIFY((
is_same<
typename gen_numeric_list_repeated<int, 10, 0>::type, numeric_list<int, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0>>::value));
140 VERIFY((
is_same<
typename concat<numeric_list<int, 0, 0>, numeric_list<int>>::type, numeric_list<int, 0, 0>>::value));
141 VERIFY((
is_same<
typename concat<numeric_list<int>, numeric_list<int, 0, 0>>::type, numeric_list<int, 0, 0>>::value));
142 VERIFY((
is_same<
typename concat<numeric_list<int, 0, 0>, numeric_list<int, 0, 0>>::type, numeric_list<int, 0, 0, 0, 0>>::value));
143 VERIFY((
is_same<
typename concat<numeric_list<int, 0, 0>, numeric_list<int, 1, 2>>::type, numeric_list<int, 0, 0, 1, 2>>::value));
144 VERIFY((
is_same<
typename concat<numeric_list<int, 0>, numeric_list<int, 1, 2>>::type, numeric_list<int, 0, 1, 2>>::value));
152 VERIFY((
is_same<
typename mconcat<numeric_list<int, 0>>::type, numeric_list<int, 0>>::value));
153 VERIFY((
is_same<
typename mconcat<numeric_list<int, 0>, numeric_list<int, 1>>::type, numeric_list<int, 0, 1>>::value));
154 VERIFY((
is_same<
typename mconcat<numeric_list<int, 0>, numeric_list<int, 1>, numeric_list<int, 2>>::type, numeric_list<int, 0, 1, 2>>::value));
155 VERIFY((
is_same<
typename mconcat<numeric_list<int, 0>, numeric_list<int, 1, 2>>::type, numeric_list<int, 0, 1, 2>>::value));
156 VERIFY((
is_same<
typename mconcat<numeric_list<int, 0, 1>, numeric_list<int, 2>>::type, numeric_list<int, 0, 1, 2>>::value));
162 typedef numeric_list<int, 0, 1, 2, 3, 4, 5> il;
172 VERIFY((
is_same<
typename take<0, il>::type, numeric_list<int>>::value));
173 VERIFY((
is_same<
typename take<1, il>::type, numeric_list<int, 0>>::value));
174 VERIFY((
is_same<
typename take<2, il>::type, numeric_list<int, 0, 1>>::value));
175 VERIFY((
is_same<
typename take<3, il>::type, numeric_list<int, 0, 1, 2>>::value));
176 VERIFY((
is_same<
typename take<4, il>::type, numeric_list<int, 0, 1, 2, 3>>::value));
177 VERIFY((
is_same<
typename take<5, il>::type, numeric_list<int, 0, 1, 2, 3, 4>>::value));
178 VERIFY((
is_same<
typename take<6, il>::type, numeric_list<int, 0, 1, 2, 3, 4, 5>>::value));
188 VERIFY((
is_same<
typename skip<0, il>::type, numeric_list<int, 0, 1, 2, 3, 4, 5>>::value));
189 VERIFY((
is_same<
typename skip<1, il>::type, numeric_list<int, 1, 2, 3, 4, 5>>::value));
190 VERIFY((
is_same<
typename skip<2, il>::type, numeric_list<int, 2, 3, 4, 5>>::value));
191 VERIFY((
is_same<
typename skip<3, il>::type, numeric_list<int, 3, 4, 5>>::value));
192 VERIFY((
is_same<
typename skip<4, il>::type, numeric_list<int, 4, 5>>::value));
193 VERIFY((
is_same<
typename skip<5, il>::type, numeric_list<int, 5>>::value));
194 VERIFY((
is_same<
typename skip<6, il>::type, numeric_list<int>>::value));
196 VERIFY((
is_same<
typename slice<0, 3, tl>::type,
typename take<3, tl>::type>::value));
197 VERIFY((
is_same<
typename slice<0, 3, il>::type,
typename take<3, il>::type>::value));
199 VERIFY((
is_same<
typename slice<1, 3, il>::type, numeric_list<int, 1, 2, 3>>::value));
205 typedef numeric_list<int, 4, 8, 15, 16, 23, 42> il;
235 template<
typename... tt>
245 test_id_numeric<1, 4, 6>();
246 test_id_type<dummy_a, dummy_b, dummy_c>();
251 VERIFY((!is_same_gf<dummy_a, dummy_b>::value));
252 VERIFY((!!is_same_gf<dummy_a, dummy_a>::value));
253 VERIFY_IS_EQUAL((!!is_same_gf<dummy_a, dummy_b>::global_flags),
false);
254 VERIFY_IS_EQUAL((!!is_same_gf<dummy_a, dummy_a>::global_flags),
false);
268 VERIFY((!!contained_in_list<is_same, dummy_a, tl>::value));
269 VERIFY((!!contained_in_list<is_same, dummy_b, tl>::value));
270 VERIFY((!!contained_in_list<is_same, dummy_c, tl>::value));
271 VERIFY((!contained_in_list<is_same, dummy_d, tl>::value));
272 VERIFY((!contained_in_list<is_same, dummy_e, tl>::value));
274 VERIFY((!!contained_in_list_gf<dummy_test, dummy_a, tl>::value));
275 VERIFY((!!contained_in_list_gf<dummy_test, dummy_b, tl>::value));
276 VERIFY((!!contained_in_list_gf<dummy_test, dummy_c, tl>::value));
277 VERIFY((!contained_in_list_gf<dummy_test, dummy_d, tl>::value));
278 VERIFY((!contained_in_list_gf<dummy_test, dummy_e, tl>::value));
280 VERIFY_IS_EQUAL(((
int)contained_in_list_gf<dummy_test, dummy_a, tl>::global_flags), 1);
281 VERIFY_IS_EQUAL(((
int)contained_in_list_gf<dummy_test, dummy_b, tl>::global_flags), 2);
282 VERIFY_IS_EQUAL(((
int)contained_in_list_gf<dummy_test, dummy_c, tl>::global_flags), 4);
283 VERIFY_IS_EQUAL(((
int)contained_in_list_gf<dummy_test, dummy_d, tl>::global_flags), 0);
284 VERIFY_IS_EQUAL(((
int)contained_in_list_gf<dummy_test, dummy_e, tl>::global_flags), 0);
289 VERIFY_IS_EQUAL(arg_sum(1,2,3,4), 10);
290 VERIFY_IS_EQUAL(
arg_prod(1,2,3,4), 24);
291 VERIFY_IS_APPROX(arg_sum(0.5, 2, 5), 7.5);
292 VERIFY_IS_APPROX(
arg_prod(0.5, 2, 5), 5.0);
297 array<int, 6> a{{4, 8, 15, 16, 23, 42}};
298 array<int, 6>
b{{42, 23, 16, 15, 8, 4}};
302 VERIFY((array_reverse(a) ==
b));
303 VERIFY((array_reverse(
b) == a));
304 VERIFY_IS_EQUAL((array_sum(a)), 108);
305 VERIFY_IS_EQUAL((array_sum(
b)), 108);
312 array<int, 6> a{{4, 8, 15, 16, 23, 42}};
313 array<int, 6>
b{{0, 1, 2, 3, 4, 5}};
314 array<int, 6> c{{4, 9, 17, 19, 27, 47}};
315 array<int, 6>
d{{0, 8, 30, 48, 92, 210}};
316 array<int, 6> e{{0, 2, 4, 6, 8, 10}};
318 VERIFY((array_zip<sum_op>(a,
b) == c));
319 VERIFY((array_zip<product_op>(a,
b) ==
d));
320 VERIFY((array_apply<times2_op>(
b) == e));
321 VERIFY_IS_EQUAL((array_apply_and_reduce<sum_op, times2_op>(a)), 216);
322 VERIFY_IS_EQUAL((array_apply_and_reduce<sum_op, times2_op>(
b)), 30);
323 VERIFY_IS_EQUAL((array_zip_and_reduce<product_op, sum_op>(a,
b)), 14755932);
324 VERIFY_IS_EQUAL((array_zip_and_reduce<sum_op, product_op>(a,
b)), 388);
329 array<int, 3> a3{{1, 1, 1}};
330 array<int, 6> a6{{2, 2, 2, 2, 2, 2}};
331 VERIFY((repeat<3, int>(1) == a3));
332 VERIFY((repeat<6, int>(2) == a6));
334 int data[5] = { 0, 1, 2, 3, 4 };
335 VERIFY_IS_EQUAL((instantiate_by_c_array<dummy_inst, int, 0>(data).c), 0);
336 VERIFY_IS_EQUAL((instantiate_by_c_array<dummy_inst, int, 1>(data).c), 1);
337 VERIFY_IS_EQUAL((instantiate_by_c_array<dummy_inst, int, 2>(data).c), 2);
338 VERIFY_IS_EQUAL((instantiate_by_c_array<dummy_inst, int, 3>(data).c), 3);
339 VERIFY_IS_EQUAL((instantiate_by_c_array<dummy_inst, int, 4>(data).c), 4);
340 VERIFY_IS_EQUAL((instantiate_by_c_array<dummy_inst, int, 5>(data).c), 5);
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::ptrdiff_t array_prod(const Sizes< Indices... > &)
array< t, n > repeat(t v)
dummy_inst(int, int, int, int, int)
bool array_apply_and_reduce(const array< A, N > &a)
bool array_zip_and_reduce(const array< A, N > &a, const array< B, N > &b)
dummy_inst(int, int, int)
dummy_inst(int, int, int, int)
EIGEN_DEVICE_FUNC const Scalar & b