codac 2.0.0
Loading...
Searching...
No Matches
codac2_cart_prod.h
Go to the documentation of this file.
1
9
10#pragma once
11
13#include "codac2_Matrix.h"
14#include "codac2_matrices.h"
15
16namespace codac2
17{
18 inline IntervalVector to_IntervalVector(const Interval& x)
19 {
20 return { x };
21 }
22
23 template<typename OtherDerived>
24 requires (std::is_same_v<typename OtherDerived::Scalar,Interval> && OtherDerived::ColsAtCompileTime==1)
25 inline IntervalVector to_IntervalVector(const Eigen::MatrixBase<OtherDerived>& x)
26 {
27 return x;
28 }
29
30 template<typename OtherDerived>
31 requires (std::is_same_v<typename OtherDerived::Scalar,double> && OtherDerived::ColsAtCompileTime==1)
32 inline IntervalVector to_IntervalVector(const Eigen::MatrixBase<OtherDerived>& x)
33 {
34 return x.template cast<Interval>();
35 }
36
37 // Flatten some matrix into an interval vector
38 template<typename T,int R,int C>
39 requires (!Eigen::IsVectorOrRow<R,C>)
40 inline IntervalVector to_IntervalVector(const Eigen::Matrix<T,R,C>& x)
41 {
42 return x.reshaped();
43 }
44
45 inline IntervalVector cart_prod()
46 {
47 return IntervalVector(0);
48 }
49
50 template<typename... X>
51 requires ((is_interval_based_v<X>) || ...)
52 && ((!is_ctc_v<X>) && ...) && ((!is_sep_v<X>) && ...)
53 inline IntervalVector cart_prod(const X&... x)
54 {
55 std::vector<IntervalVector> v_x;
56 ((v_x.push_back(to_IntervalVector(x))), ...);
57
58 Index n = 0;
59 for(const auto& xi : v_x)
60 n += xi.size();
61 IntervalVector x_(n);
62
63 Index i = 0;
64 for(const auto& xi : v_x)
65 {
66 x_.put(i, xi);
67 i += xi.size();
68 }
69 return x_;
70 }
71
72 template<typename... X>
73 requires ((!is_interval_based_v<X>) && ...)
74 && ((!is_ctc_v<X>) && ...) && ((!is_sep_v<X>) && ...)
75 inline Vector cart_prod(const X&... x)
76 {
77 return cart_prod(to_IntervalVector(x)...).mid();
78 }
79}
Interval class, for representing closed and connected subsets of .
Definition codac2_Interval.h:62