codac 2.0.0
Loading...
Searching...
No Matches
codac2_MatrixBase_addons_IntervalVector.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<typename U = Scalar, int R = RowsAtCompileTime, int C = ColsAtCompileTime>
requires IsIntervalDomain<U> && IsVectorOrRow<R,C>
auto complementary () const
 Computes the complementary set of this interval vector (or interval row).
 
template<typename OtherDerived, typename U = Scalar, int R = RowsAtCompileTime, int C = ColsAtCompileTime>
requires IsIntervalDomain<U> && IsVectorOrRow<R,C>
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.
 

Detailed Description

This class reuses some of the functions developed for ibex::IntervalVector. The original IBEX code is revised in modern C++ and adapted to the template structure proposed in Codac, based on the Eigen library. See ibex::IntervalVector (IBEX lib, author: Gilles Chabert)

This file is included in the declaration of Eigen::MatrixBase, thanks to the preprocessor token EIGEN_MATRIXBASE_PLUGIN. See: https://eigen.tuxfamily.org/dox/TopicCustomizing_Plugins.html and the file codac2_matrices.h


Date
2024
Author
Simon Rohou, Gilles Chabert
License: GNU Lesser General Public License (LGPL)

Function Documentation

◆ complementary()

template<typename U = Scalar, int R = RowsAtCompileTime, int C = ColsAtCompileTime>
requires IsIntervalDomain<U> && IsVectorOrRow<R,C>
auto complementary ( ) const
inline

Computes the complementary set of this interval vector (or interval row).

This function returns the set of intervals that are not part of this vector, interpreted as the complement with respect to the whole interval domain.

Returns
A list of intervals representing the complement of this interval vector.
32{
33 return Matrix<codac2::Interval,R,C>((int)this->size()).diff(*this);
34}
Matrix()=delete
Deleted default constructor to prevent default instantiation when either the number of rows or column...

◆ diff()

template<typename OtherDerived, typename U = Scalar, int R = RowsAtCompileTime, int C = ColsAtCompileTime>
requires IsIntervalDomain<U> && IsVectorOrRow<R,C>
std::list< Matrix< codac2::Interval, R, C > > diff ( const MatrixBase< OtherDerived > & y,
bool compactness = true ) const
inline

Computes the difference between this interval vector (or interval row) and another.

This method returns the set-theoretic difference between this vector x and another vector y, i.e., all values contained in x but not in y. The result is expressed as a list of disjoint interval vectors.

Parameters
yThe interval vector to subtract.
compactnessoptional boolean to obtain or not disjoint intervals.
Returns
A list of interval vectors forming the difference this \ y. The list is empty if the difference is empty.
Note
Note the following special cases:
  • If the two vectors are equal, the result is empty.
  • If they are disjoint, the result is simply this vector.
  • If y is a flat interval (degenerate) in some dimensions and x is not, this may return x directly to avoid unnecessary fragmentation (depending on the compactness flag).
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
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