codac 1.5.6
Loading...
Searching...
No Matches
codac2_cart_prod.h
Go to the documentation of this file.
1
12#ifndef __CODAC2_CARTPROD_H__
13#define __CODAC2_CARTPROD_H__
14
15#include "codac2_Interval.h"
17
18namespace codac2
19{
20 IntervalVector cart_prod_dyn(const Interval& x1, const Interval& x2);
21 IntervalVector_<2> cart_prod_static(const Interval& x1, const Interval& x2);
22 IntervalVector cart_prod_dyn(const IntervalVector& x1, const Interval& x2);
23
24 template<int N>
25 IntervalVector_<N+1> cart_prod_static(const IntervalVector_<N>& x1, const Interval& x2)
26 {
27 IntervalVector_<N+1> x;
28 x << x1,x2;
29 return x;
30 }
31
32 IntervalVector cart_prod_dyn(const Interval& x1, const IntervalVector& x2);
33
34 template<int N>
35 IntervalVector_<N+1> cart_prod_static(const Interval& x1, const IntervalVector_<N>& x2)
36 {
37 IntervalVector_<N+1> x;
38 x << x1,x2;
39 return x;
40 }
41
42 IntervalVector cart_prod_dyn(const IntervalVector& x1, const IntervalVector& x2);
43
44 template<int N,int M>
45 IntervalVector_<N+M> cart_prod_static(const IntervalVector_<N>& x1, const IntervalVector_<M>& x2)
46 {
47 IntervalVector_<N+M> x;
48 x << x1,x2;
49 return x;
50 }
51
52 template<int N, typename T1, typename T2, typename... Args>
53 IntervalVector_<N> cart_prod(const T1& x1, const T2& x2, const Args&... xi) // recursive variadic function
54 {
55 auto x_ = cart_prod_static(x1, x2);
56 if constexpr(sizeof...(xi) > 0)
57 return cart_prod<N>(x_, xi...);
58 else
59 return x_;
60 }
61
62 template<typename T1, typename T2, typename... Args>
63 IntervalVector cart_prod(const T1& x1, const T2& x2, const Args&... xi) // recursive variadic function
64 {
65 IntervalVector x_ = cart_prod_dyn(IntervalVector(x1), IntervalVector(x2));
66 if constexpr(sizeof...(xi) > 0)
67 return cart_prod(x_, xi...);
68 else
69 return x_;
70 }
71
72} // namespace codac
73
74#endif