codac 2.0.0
Loading...
Searching...
No Matches
codac2_MatrixBase_addons_IntervalVector.h
Go to the documentation of this file.
1
20
29template<typename U=Scalar,int R=RowsAtCompileTime,int C=ColsAtCompileTime>
30 requires IsIntervalDomain<U> && IsVectorOrRow<R,C>
31inline auto complementary() const
32{
33 return Matrix<codac2::Interval,R,C>((int)this->size()).diff(*this);
34}
35
54template<typename OtherDerived,typename U=Scalar,int R=RowsAtCompileTime,int C=ColsAtCompileTime>
55 requires IsIntervalDomain<U> && IsVectorOrRow<R,C>
56inline std::list<Matrix<codac2::Interval,R,C>> diff(const MatrixBase<OtherDerived>& y, bool compactness = true) const
57{
58 // This code originates from the ibex-lib
59 // See: ibex_TemplateVector.h
60 // Author: Gilles Chabert
61 // It has been revised with modern C++ and templated types
62
63 const Index n = this->size();
64 assert_release(y.size() == n);
65
66 if(y == *this)
67 return { };
68
71
72 if(z.is_empty())
73 {
74 if(x.is_empty()) return { };
75 else return { x };
76 }
77
78 else
79 {
80 // Check if in one dimension y is flat and x not,
81 // in which case the diff returns also x directly
82 if(compactness)
83 for(Index i = 0 ; i < n ; i++)
84 if(z[i].is_degenerated() && !x[i].is_degenerated())
85 {
86 if(x.is_empty()) return { };
87 else return { x };
88 }
89 }
90
91 std::list<Matrix<codac2::Interval,R,C>> l;
92
93 for(Index var = 0 ; var < n ; var++)
94 {
95 codac2::Interval c1, c2;
96
97 for(const auto& ci : x[var].diff(y[var], compactness))
98 {
99 assert(!ci.is_empty());
100
102 for(Index i = 0 ; i < var ; i++)
103 v[i] = x[i];
104 v[var] = ci;
105 for(Index i = var+1 ; i < n ; i++)
106 v[i] = x[i];
107 if(!v.is_empty())
108 l.push_back(v);
109 }
110
111 x[var] = z[var];
112 }
113
114 return l;
115}
Interval class, for representing closed and connected subsets of .
Definition codac2_Interval.h:49
Matrix(const Matrix< double, R, C > &lb, const Matrix< double, R, C > &ub)
Constructs an interval matrix from lower and upper bound matrices.
Definition codac2_Matrix_addons_IntervalMatrixBase.h:50
Matrix()=delete
Deleted default constructor to prevent default instantiation when either the number of rows or column...
bool is_degenerated() const
Checks if the interval matrix is degenerated.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:300
std::list< Matrix< codac2::Interval, R, C > > diff(const MatrixBase< OtherDerived > &y, bool compactness=true) const
Computes the difference between this interval vector (or interval row) and another.
Definition codac2_MatrixBase_addons_IntervalVector.h:56
auto complementary() const
Computes the complementary set of this interval vector (or interval row).
Definition codac2_MatrixBase_addons_IntervalVector.h:31