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