Eigen  3.4.90 (git rev 5a9f66fb35d03a4da9ef8976e67a61b30aa16dcf)
 
Loading...
Searching...
No Matches
MoreMeta.h
1// This file is part of Eigen, a lightweight C++ template library
2// for linear algebra.
3//
4// Copyright (C) 2008-2015 Gael Guennebaud <[email protected]>
5// Copyright (C) 2006-2008 Benoit Jacob <[email protected]>
6//
7// This Source Code Form is subject to the terms of the Mozilla
8// Public License v. 2.0. If a copy of the MPL was not distributed
9// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10
11#ifndef EIGEN_MOREMETA_H
12#define EIGEN_MOREMETA_H
13
14// IWYU pragma: private
15#include "../InternalHeaderCheck.h"
16
17namespace Eigen {
18
19namespace internal {
20
21template <typename... tt>
22struct type_list {
23 constexpr static int count = sizeof...(tt);
24};
25
26template <typename t, typename... tt>
27struct type_list<t, tt...> {
28 constexpr static int count = sizeof...(tt) + 1;
29 typedef t first_type;
30};
31
32template <typename T, T... nn>
33struct numeric_list {
34 constexpr static std::size_t count = sizeof...(nn);
35};
36
37template <typename T, T n, T... nn>
38struct numeric_list<T, n, nn...> {
39 static constexpr std::size_t count = sizeof...(nn) + 1;
40 static constexpr T first_value = n;
41};
42
43#ifndef EIGEN_PARSED_BY_DOXYGEN
44/* numeric list constructors
45 *
46 * equivalencies:
47 * constructor result
48 * typename gen_numeric_list<int, 5>::type numeric_list<int, 0,1,2,3,4>
49 * typename gen_numeric_list_reversed<int, 5>::type numeric_list<int, 4,3,2,1,0>
50 * typename gen_numeric_list_swapped_pair<int, 5,1,2>::type numeric_list<int, 0,2,1,3,4>
51 * typename gen_numeric_list_repeated<int, 0, 5>::type numeric_list<int, 0,0,0,0,0>
52 */
53
54template <typename T, std::size_t n, T start = 0, T... ii>
55struct gen_numeric_list : gen_numeric_list<T, n - 1, start, start + n - 1, ii...> {};
56template <typename T, T start, T... ii>
57struct gen_numeric_list<T, 0, start, ii...> {
58 typedef numeric_list<T, ii...> type;
59};
60
61template <typename T, std::size_t n, T start = 0, T... ii>
62struct gen_numeric_list_reversed : gen_numeric_list_reversed<T, n - 1, start, ii..., start + n - 1> {};
63template <typename T, T start, T... ii>
64struct gen_numeric_list_reversed<T, 0, start, ii...> {
65 typedef numeric_list<T, ii...> type;
66};
67
68template <typename T, std::size_t n, T a, T b, T start = 0, T... ii>
69struct gen_numeric_list_swapped_pair
70 : gen_numeric_list_swapped_pair<T, n - 1, a, b, start,
71 (start + n - 1) == a ? b : ((start + n - 1) == b ? a : (start + n - 1)), ii...> {};
72template <typename T, T a, T b, T start, T... ii>
73struct gen_numeric_list_swapped_pair<T, 0, a, b, start, ii...> {
74 typedef numeric_list<T, ii...> type;
75};
76
77template <typename T, std::size_t n, T V, T... nn>
78struct gen_numeric_list_repeated : gen_numeric_list_repeated<T, n - 1, V, V, nn...> {};
79template <typename T, T V, T... nn>
80struct gen_numeric_list_repeated<T, 0, V, nn...> {
81 typedef numeric_list<T, nn...> type;
82};
83
84/* list manipulation: concatenate */
85
86template <class a, class b>
87struct concat;
88
89template <typename... as, typename... bs>
90struct concat<type_list<as...>, type_list<bs...>> {
91 typedef type_list<as..., bs...> type;
92};
93template <typename T, T... as, T... bs>
94struct concat<numeric_list<T, as...>, numeric_list<T, bs...>> {
95 typedef numeric_list<T, as..., bs...> type;
96};
97
98template <typename... p>
99struct mconcat;
100template <typename a>
101struct mconcat<a> {
102 typedef a type;
103};
104template <typename a, typename b>
105struct mconcat<a, b> : concat<a, b> {};
106template <typename a, typename b, typename... cs>
107struct mconcat<a, b, cs...> : concat<a, typename mconcat<b, cs...>::type> {};
108
109/* list manipulation: extract slices */
110
111template <int n, typename x>
112struct take;
113template <int n, typename a, typename... as>
114struct take<n, type_list<a, as...>> : concat<type_list<a>, typename take<n - 1, type_list<as...>>::type> {};
115template <int n>
116struct take<n, type_list<>> {
117 typedef type_list<> type;
118};
119template <typename a, typename... as>
120struct take<0, type_list<a, as...>> {
121 typedef type_list<> type;
122};
123template <>
124struct take<0, type_list<>> {
125 typedef type_list<> type;
126};
127
128template <typename T, int n, T a, T... as>
129struct take<n, numeric_list<T, a, as...>>
130 : concat<numeric_list<T, a>, typename take<n - 1, numeric_list<T, as...>>::type> {};
131// XXX The following breaks in gcc-11, and is invalid anyways.
132// template<typename T, int n> struct take<n, numeric_list<T>> { typedef numeric_list<T> type;
133// };
134template <typename T, T a, T... as>
135struct take<0, numeric_list<T, a, as...>> {
136 typedef numeric_list<T> type;
137};
138template <typename T>
139struct take<0, numeric_list<T>> {
140 typedef numeric_list<T> type;
141};
142
143template <typename T, int n, T... ii>
144struct h_skip_helper_numeric;
145template <typename T, int n, T i, T... ii>
146struct h_skip_helper_numeric<T, n, i, ii...> : h_skip_helper_numeric<T, n - 1, ii...> {};
147template <typename T, T i, T... ii>
148struct h_skip_helper_numeric<T, 0, i, ii...> {
149 typedef numeric_list<T, i, ii...> type;
150};
151template <typename T, int n>
152struct h_skip_helper_numeric<T, n> {
153 typedef numeric_list<T> type;
154};
155template <typename T>
156struct h_skip_helper_numeric<T, 0> {
157 typedef numeric_list<T> type;
158};
159
160template <int n, typename... tt>
161struct h_skip_helper_type;
162template <int n, typename t, typename... tt>
163struct h_skip_helper_type<n, t, tt...> : h_skip_helper_type<n - 1, tt...> {};
164template <typename t, typename... tt>
165struct h_skip_helper_type<0, t, tt...> {
166 typedef type_list<t, tt...> type;
167};
168template <int n>
169struct h_skip_helper_type<n> {
170 typedef type_list<> type;
171};
172template <>
173struct h_skip_helper_type<0> {
174 typedef type_list<> type;
175};
176#endif // not EIGEN_PARSED_BY_DOXYGEN
177
178template <int n>
179struct h_skip {
180 template <typename T, T... ii>
181 constexpr static EIGEN_STRONG_INLINE typename h_skip_helper_numeric<T, n, ii...>::type helper(
182 numeric_list<T, ii...>) {
183 return typename h_skip_helper_numeric<T, n, ii...>::type();
184 }
185 template <typename... tt>
186 constexpr static EIGEN_STRONG_INLINE typename h_skip_helper_type<n, tt...>::type helper(type_list<tt...>) {
187 return typename h_skip_helper_type<n, tt...>::type();
188 }
189};
190
191template <int n, typename a>
192struct skip {
193 typedef decltype(h_skip<n>::helper(a())) type;
194};
195
196template <int start, int count, typename a>
197struct slice : take<count, typename skip<start, a>::type> {};
198
199/* list manipulation: retrieve single element from list */
200
201template <int n, typename x>
202struct get;
203
204template <int n, typename a, typename... as>
205struct get<n, type_list<a, as...>> : get<n - 1, type_list<as...>> {};
206template <typename a, typename... as>
207struct get<0, type_list<a, as...>> {
208 typedef a type;
209};
210
211template <typename T, int n, T a, T... as>
212struct get<n, numeric_list<T, a, as...>> : get<n - 1, numeric_list<T, as...>> {};
213template <typename T, T a, T... as>
214struct get<0, numeric_list<T, a, as...>> {
215 constexpr static T value = a;
216};
217
218template <std::size_t n, typename T, T a, T... as>
219constexpr T array_get(const numeric_list<T, a, as...>&) {
220 return get<(int)n, numeric_list<T, a, as...>>::value;
221}
222
223/* always get type, regardless of dummy; good for parameter pack expansion */
224
225template <typename T, T dummy, typename t>
226struct id_numeric {
227 typedef t type;
228};
229template <typename dummy, typename t>
230struct id_type {
231 typedef t type;
232};
233
234/* equality checking, flagged version */
235
236template <typename a, typename b>
237struct is_same_gf : is_same<a, b> {
238 constexpr static int global_flags = 0;
239};
240
241/* apply_op to list */
242
243template <bool from_left, // false
244 template <typename, typename> class op, typename additional_param, typename... values>
245struct h_apply_op_helper {
246 typedef type_list<typename op<values, additional_param>::type...> type;
247};
248template <template <typename, typename> class op, typename additional_param, typename... values>
249struct h_apply_op_helper<true, op, additional_param, values...> {
250 typedef type_list<typename op<additional_param, values>::type...> type;
251};
252
253template <bool from_left, template <typename, typename> class op, typename additional_param>
254struct h_apply_op {
255 template <typename... values>
256 constexpr static typename h_apply_op_helper<from_left, op, additional_param, values...>::type helper(
257 type_list<values...>) {
258 return typename h_apply_op_helper<from_left, op, additional_param, values...>::type();
259 }
260};
261
262template <template <typename, typename> class op, typename additional_param, typename a>
263struct apply_op_from_left {
264 typedef decltype(h_apply_op<true, op, additional_param>::helper(a())) type;
265};
266
267template <template <typename, typename> class op, typename additional_param, typename a>
268struct apply_op_from_right {
269 typedef decltype(h_apply_op<false, op, additional_param>::helper(a())) type;
270};
271
272/* see if an element is in a list */
273
274template <template <typename, typename> class test, typename check_against, typename h_list,
275 bool last_check_positive = false>
276struct contained_in_list;
277
278template <template <typename, typename> class test, typename check_against, typename h_list>
279struct contained_in_list<test, check_against, h_list, true> {
280 constexpr static bool value = true;
281};
282
283template <template <typename, typename> class test, typename check_against, typename a, typename... as>
284struct contained_in_list<test, check_against, type_list<a, as...>, false>
285 : contained_in_list<test, check_against, type_list<as...>, test<check_against, a>::value> {};
286
287template <template <typename, typename> class test, typename check_against, typename... empty>
288struct contained_in_list<test, check_against, type_list<empty...>, false> {
289 constexpr static bool value = false;
290};
291
292/* see if an element is in a list and check for global flags */
293
294template <template <typename, typename> class test, typename check_against, typename h_list, int default_flags = 0,
295 bool last_check_positive = false, int last_check_flags = default_flags>
296struct contained_in_list_gf;
297
298template <template <typename, typename> class test, typename check_against, typename h_list, int default_flags,
299 int last_check_flags>
300struct contained_in_list_gf<test, check_against, h_list, default_flags, true, last_check_flags> {
301 constexpr static bool value = true;
302 constexpr static int global_flags = last_check_flags;
303};
304
305template <template <typename, typename> class test, typename check_against, typename a, typename... as,
306 int default_flags, int last_check_flags>
307struct contained_in_list_gf<test, check_against, type_list<a, as...>, default_flags, false, last_check_flags>
308 : contained_in_list_gf<test, check_against, type_list<as...>, default_flags, test<check_against, a>::value,
309 test<check_against, a>::global_flags> {};
310
311template <template <typename, typename> class test, typename check_against, typename... empty, int default_flags,
312 int last_check_flags>
313struct contained_in_list_gf<test, check_against, type_list<empty...>, default_flags, false, last_check_flags> {
314 constexpr static bool value = false;
315 constexpr static int global_flags = default_flags;
316};
317
318/* generic reductions */
319
320template <typename Reducer, typename... Ts>
321struct reduce;
322
323template <typename Reducer>
324struct reduce<Reducer> {
325 EIGEN_DEVICE_FUNC constexpr static EIGEN_STRONG_INLINE int run() { return Reducer::Identity; }
326};
327
328template <typename Reducer, typename A>
329struct reduce<Reducer, A> {
330 EIGEN_DEVICE_FUNC constexpr static EIGEN_STRONG_INLINE A run(A a) { return a; }
331};
332
333template <typename Reducer, typename A, typename... Ts>
334struct reduce<Reducer, A, Ts...> {
335 EIGEN_DEVICE_FUNC constexpr static EIGEN_STRONG_INLINE auto run(A a, Ts... ts)
336 -> decltype(Reducer::run(a, reduce<Reducer, Ts...>::run(ts...))) {
337 return Reducer::run(a, reduce<Reducer, Ts...>::run(ts...));
338 }
339};
340
341/* generic binary operations */
342
343struct sum_op {
344 template <typename A, typename B>
345 EIGEN_DEVICE_FUNC constexpr static EIGEN_STRONG_INLINE auto run(A a, B b) -> decltype(a + b) {
346 return a + b;
347 }
348 static constexpr int Identity = 0;
349};
350struct product_op {
351 template <typename A, typename B>
352 EIGEN_DEVICE_FUNC constexpr static EIGEN_STRONG_INLINE auto run(A a, B b) -> decltype(a * b) {
353 return a * b;
354 }
355 static constexpr int Identity = 1;
356};
357
358struct logical_and_op {
359 template <typename A, typename B>
360 constexpr static EIGEN_STRONG_INLINE auto run(A a, B b) -> decltype(a && b) {
361 return a && b;
362 }
363};
364struct logical_or_op {
365 template <typename A, typename B>
366 constexpr static EIGEN_STRONG_INLINE auto run(A a, B b) -> decltype(a || b) {
367 return a || b;
368 }
369};
370
371struct equal_op {
372 template <typename A, typename B>
373 constexpr static EIGEN_STRONG_INLINE auto run(A a, B b) -> decltype(a == b) {
374 return a == b;
375 }
376};
377struct not_equal_op {
378 template <typename A, typename B>
379 constexpr static EIGEN_STRONG_INLINE auto run(A a, B b) -> decltype(a != b) {
380 return a != b;
381 }
382};
383struct lesser_op {
384 template <typename A, typename B>
385 constexpr static EIGEN_STRONG_INLINE auto run(A a, B b) -> decltype(a < b) {
386 return a < b;
387 }
388};
389struct lesser_equal_op {
390 template <typename A, typename B>
391 constexpr static EIGEN_STRONG_INLINE auto run(A a, B b) -> decltype(a <= b) {
392 return a <= b;
393 }
394};
395struct greater_op {
396 template <typename A, typename B>
397 constexpr static EIGEN_STRONG_INLINE auto run(A a, B b) -> decltype(a > b) {
398 return a > b;
399 }
400};
401struct greater_equal_op {
402 template <typename A, typename B>
403 constexpr static EIGEN_STRONG_INLINE auto run(A a, B b) -> decltype(a >= b) {
404 return a >= b;
405 }
406};
407
408/* generic unary operations */
409
410struct not_op {
411 template <typename A>
412 constexpr static EIGEN_STRONG_INLINE auto run(A a) -> decltype(!a) {
413 return !a;
414 }
415};
416struct negation_op {
417 template <typename A>
418 constexpr static EIGEN_STRONG_INLINE auto run(A a) -> decltype(-a) {
419 return -a;
420 }
421};
422struct greater_equal_zero_op {
423 template <typename A>
424 constexpr static EIGEN_STRONG_INLINE auto run(A a) -> decltype(a >= 0) {
425 return a >= 0;
426 }
427};
428
429/* reductions for lists */
430
431// using auto -> return value spec makes ICC 13.0 and 13.1 crash here, so we have to hack it
432// together in front... (13.0 doesn't work with array_prod/array_reduce/... anyway, but 13.1
433// does...
434template <typename... Ts>
435EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE decltype(reduce<product_op, Ts...>::run((*((Ts*)0))...)) arg_prod(
436 Ts... ts) {
437 return reduce<product_op, Ts...>::run(ts...);
438}
439
440template <typename... Ts>
441constexpr EIGEN_STRONG_INLINE decltype(reduce<sum_op, Ts...>::run((*((Ts*)0))...)) arg_sum(Ts... ts) {
442 return reduce<sum_op, Ts...>::run(ts...);
443}
444
445/* reverse arrays */
446
447template <typename Array, int... n>
448constexpr EIGEN_STRONG_INLINE Array h_array_reverse(Array arr, numeric_list<int, n...>) {
449 return {{array_get<sizeof...(n) - n - 1>(arr)...}};
450}
451
452template <typename T, std::size_t N>
453constexpr EIGEN_STRONG_INLINE array<T, N> array_reverse(array<T, N> arr) {
454 return h_array_reverse(arr, typename gen_numeric_list<int, N>::type());
455}
456
457/* generic array reductions */
458
459// can't reuse standard reduce() interface above because Intel's Compiler
460// *really* doesn't like it, so we just reimplement the stuff
461// (start from N - 1 and work down to 0 because specialization for
462// n == N - 1 also doesn't work in Intel's compiler, so it goes into
463// an infinite loop)
464template <typename Reducer, typename T, std::size_t N, std::size_t n = N - 1>
465struct h_array_reduce {
466 EIGEN_DEVICE_FUNC constexpr static EIGEN_STRONG_INLINE auto run(array<T, N> arr, T identity)
467 -> decltype(Reducer::run(h_array_reduce<Reducer, T, N, n - 1>::run(arr, identity), array_get<n>(arr))) {
468 return Reducer::run(h_array_reduce<Reducer, T, N, n - 1>::run(arr, identity), array_get<n>(arr));
469 }
470};
471
472template <typename Reducer, typename T, std::size_t N>
473struct h_array_reduce<Reducer, T, N, 0> {
474 EIGEN_DEVICE_FUNC constexpr static EIGEN_STRONG_INLINE T run(const array<T, N>& arr, T) { return array_get<0>(arr); }
475};
476
477template <typename Reducer, typename T>
478struct h_array_reduce<Reducer, T, 0> {
479 EIGEN_DEVICE_FUNC constexpr static EIGEN_STRONG_INLINE T run(const array<T, 0>&, T identity) { return identity; }
480};
481
482template <typename Reducer, typename T, std::size_t N>
483EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE auto array_reduce(const array<T, N>& arr, T identity)
484 -> decltype(h_array_reduce<Reducer, T, N>::run(arr, identity)) {
485 return h_array_reduce<Reducer, T, N>::run(arr, identity);
486}
487
488/* standard array reductions */
489
490template <typename T, std::size_t N>
491EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE auto array_sum(const array<T, N>& arr)
492 -> decltype(array_reduce<sum_op, T, N>(arr, static_cast<T>(0))) {
493 return array_reduce<sum_op, T, N>(arr, static_cast<T>(0));
494}
495
496template <typename T, std::size_t N>
497EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE auto array_prod(const array<T, N>& arr)
498 -> decltype(array_reduce<product_op, T, N>(arr, static_cast<T>(1))) {
499 return array_reduce<product_op, T, N>(arr, static_cast<T>(1));
500}
501
502template <typename t>
503EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE t array_prod(const std::vector<t>& a) {
504 eigen_assert(a.size() > 0);
505 t prod = 1;
506 for (size_t i = 0; i < a.size(); ++i) {
507 prod *= a[i];
508 }
509 return prod;
510}
511
512/* zip an array */
513
514template <typename Op, typename A, typename B, std::size_t N, int... n>
515constexpr EIGEN_STRONG_INLINE array<decltype(Op::run(A(), B())), N> h_array_zip(array<A, N> a, array<B, N> b,
516 numeric_list<int, n...>) {
517 return array<decltype(Op::run(A(), B())), N>{{Op::run(array_get<n>(a), array_get<n>(b))...}};
518}
519
520template <typename Op, typename A, typename B, std::size_t N>
521constexpr EIGEN_STRONG_INLINE array<decltype(Op::run(A(), B())), N> array_zip(array<A, N> a, array<B, N> b) {
522 return h_array_zip<Op>(a, b, typename gen_numeric_list<int, N>::type());
523}
524
525/* zip an array and reduce the result */
526
527template <typename Reducer, typename Op, typename A, typename B, std::size_t N, int... n>
528constexpr EIGEN_STRONG_INLINE auto h_array_zip_and_reduce(array<A, N> a, array<B, N> b, numeric_list<int, n...>)
529 -> decltype(reduce<Reducer, typename id_numeric<int, n, decltype(Op::run(A(), B()))>::type...>::run(
530 Op::run(array_get<n>(a), array_get<n>(b))...)) {
531 return reduce<Reducer, typename id_numeric<int, n, decltype(Op::run(A(), B()))>::type...>::run(
532 Op::run(array_get<n>(a), array_get<n>(b))...);
533}
534
535template <typename Reducer, typename Op, typename A, typename B, std::size_t N>
536constexpr EIGEN_STRONG_INLINE auto array_zip_and_reduce(array<A, N> a, array<B, N> b)
537 -> decltype(h_array_zip_and_reduce<Reducer, Op, A, B, N>(a, b, typename gen_numeric_list<int, N>::type())) {
538 return h_array_zip_and_reduce<Reducer, Op, A, B, N>(a, b, typename gen_numeric_list<int, N>::type());
539}
540
541/* apply stuff to an array */
542
543template <typename Op, typename A, std::size_t N, int... n>
544constexpr EIGEN_STRONG_INLINE array<decltype(Op::run(A())), N> h_array_apply(array<A, N> a, numeric_list<int, n...>) {
545 return array<decltype(Op::run(A())), N>{{Op::run(array_get<n>(a))...}};
546}
547
548template <typename Op, typename A, std::size_t N>
549constexpr EIGEN_STRONG_INLINE array<decltype(Op::run(A())), N> array_apply(array<A, N> a) {
550 return h_array_apply<Op>(a, typename gen_numeric_list<int, N>::type());
551}
552
553/* apply stuff to an array and reduce */
554
555template <typename Reducer, typename Op, typename A, std::size_t N, int... n>
556constexpr EIGEN_STRONG_INLINE auto h_array_apply_and_reduce(array<A, N> arr, numeric_list<int, n...>)
557 -> decltype(reduce<Reducer, typename id_numeric<int, n, decltype(Op::run(A()))>::type...>::run(
558 Op::run(array_get<n>(arr))...)) {
559 return reduce<Reducer, typename id_numeric<int, n, decltype(Op::run(A()))>::type...>::run(
560 Op::run(array_get<n>(arr))...);
561}
562
563template <typename Reducer, typename Op, typename A, std::size_t N>
564constexpr EIGEN_STRONG_INLINE auto array_apply_and_reduce(array<A, N> a)
565 -> decltype(h_array_apply_and_reduce<Reducer, Op, A, N>(a, typename gen_numeric_list<int, N>::type())) {
566 return h_array_apply_and_reduce<Reducer, Op, A, N>(a, typename gen_numeric_list<int, N>::type());
567}
568
569/* repeat a value n times (and make an array out of it
570 * usage:
571 * array<int, 16> = repeat<16>(42);
572 */
573
574template <int n>
575struct h_repeat {
576 template <typename t, int... ii>
577 constexpr static EIGEN_STRONG_INLINE array<t, n> run(t v, numeric_list<int, ii...>) {
578 return {{typename id_numeric<int, ii, t>::type(v)...}};
579 }
580};
581
582template <int n, typename t>
583constexpr array<t, n> repeat(t v) {
584 return h_repeat<n>::run(v, typename gen_numeric_list<int, n>::type());
585}
586
587/* instantiate a class by a C-style array */
588template <class InstType, typename ArrType, std::size_t N, bool Reverse, typename... Ps>
589struct h_instantiate_by_c_array;
590
591template <class InstType, typename ArrType, std::size_t N, typename... Ps>
592struct h_instantiate_by_c_array<InstType, ArrType, N, false, Ps...> {
593 static InstType run(ArrType* arr, Ps... args) {
594 return h_instantiate_by_c_array<InstType, ArrType, N - 1, false, Ps..., ArrType>::run(arr + 1, args..., arr[0]);
595 }
596};
597
598template <class InstType, typename ArrType, std::size_t N, typename... Ps>
599struct h_instantiate_by_c_array<InstType, ArrType, N, true, Ps...> {
600 static InstType run(ArrType* arr, Ps... args) {
601 return h_instantiate_by_c_array<InstType, ArrType, N - 1, false, ArrType, Ps...>::run(arr + 1, arr[0], args...);
602 }
603};
604
605template <class InstType, typename ArrType, typename... Ps>
606struct h_instantiate_by_c_array<InstType, ArrType, 0, false, Ps...> {
607 static InstType run(ArrType* arr, Ps... args) {
608 (void)arr;
609 return InstType(args...);
610 }
611};
612
613template <class InstType, typename ArrType, typename... Ps>
614struct h_instantiate_by_c_array<InstType, ArrType, 0, true, Ps...> {
615 static InstType run(ArrType* arr, Ps... args) {
616 (void)arr;
617 return InstType(args...);
618 }
619};
620
621template <class InstType, typename ArrType, std::size_t N, bool Reverse = false>
622InstType instantiate_by_c_array(ArrType* arr) {
623 return h_instantiate_by_c_array<InstType, ArrType, N, Reverse>::run(arr);
624}
625
626} // end namespace internal
627
628} // end namespace Eigen
629
630#endif // EIGEN_MOREMETA_H
Namespace containing all symbols from the Eigen library.
Definition Core:137