|
| template<int R = RowsAtCompileTime, int C = ColsAtCompileTime> |
| | Matrix (const Matrix< double, R, C > &lb, const Matrix< double, R, C > &ub) |
| | Constructs an interval matrix from lower and upper bound matrices.
|
| template<int R = RowsAtCompileTime, int C = ColsAtCompileTime> |
| | Matrix (int r, int c, const double bounds[][2]) |
| | Constructs an interval matrix from a 2D array of bounds.
|
| auto & | init () |
| | Initializes all elements of the matrix with default intervals.
|
| template<int R = RowsAtCompileTime, int C = ColsAtCompileTime, typename OtherDerived> |
| bool | operator== (const MatrixBase< OtherDerived > &x) const |
| | Compares this interval matrix with another matrix for equality.
|
| void | set_empty () |
| | Marks the interval matrix as empty.
|
| auto & | inflate (double r) |
| | Inflates all intervals in the matrix by a fixed radius.
|
| template<typename OtherDerived> |
| auto & | inflate (const MatrixBase< OtherDerived > &r) |
| | Inflates each interval in the matrix by corresponding values from another matrix.
|
| template<typename OtherDerived> |
| auto & | operator&= (const MatrixBase< OtherDerived > &x) |
| | Performs element-wise intersection assignment with another matrix.
|
| template<typename OtherDerived> |
| auto & | operator|= (const MatrixBase< OtherDerived > &x) |
| | Performs element-wise union assignment with another matrix.
|
| template<typename OtherDerived> |
| auto | operator& (const MatrixBase< OtherDerived > &x) const |
| | Returns the element-wise intersection of this matrix with another.
|
| template<typename OtherDerived> |
| auto | operator| (const MatrixBase< OtherDerived > &x) const |
| | Returns the element-wise union of this matrix with another.
|
| template<int R = RowsAtCompileTime, int C = ColsAtCompileTime> |
| auto | bisect (Index i, float ratio=0.49) const |
| | Bisects the interval at the given index into two sub-interval matrices.
|
| template<int R = RowsAtCompileTime, int C = ColsAtCompileTime> |
| auto | bisect_largest (float ratio=0.49) const |
| | Bisects the interval with the largest diameter in the matrix.
|
This class reuses some of the functions developed for ibex::IntervalMatrixBase. 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::IntervalMatrixBase (IBEX lib, author: Gilles Chabert)
This file is included in the declaration of Eigen::MatrixBase, thanks to the preprocessor token EIGEN_MATRIX_PLUGIN. See: https://eigen.tuxfamily.org/dox/TopicCustomizing_Plugins.html and the file codac2_matrices.h
- Date
- 2024
- Author
- Simon Rohou, Gilles Chabert
- Copyright
- Copyright 2023 Codac Team
- License: GNU Lesser General Public License (LGPL)
template<int R = RowsAtCompileTime, int C = ColsAtCompileTime>
| Matrix |
( |
const Matrix< double, R, C > & | lb, |
|
|
const Matrix< double, R, C > & | ub ) |
Constructs an interval matrix from lower and upper bound matrices.
Initializes the interval matrix with the given lower bound matrix lb and upper bound matrix ub.
Each element of the resulting interval matrix is constructed from corresponding elements in lb and ub. If any lower bound element is greater than its corresponding upper bound element, the matrix is set to empty.
- Parameters
-
| lb | Matrix of lower bounds. |
| ub | Matrix of upper bounds. |
- Precondition
lb and ub must have the same size.
52{
53 assert_release(
lb.size() ==
ub.size());
54
55 for(Index i = 0 ; i < this->size() ; i++)
56 {
57 auto& lbi = *(this->data()+i);
58 const auto& ubi = *(
ub.data()+i);
59
60 if(lbi.lb() > ubi)
61 {
63 break;
64 }
65
66 else
67 lbi |= ubi;
68 }
69}
void set_empty()
Marks the interval matrix as empty.
Definition codac2_Matrix_addons_IntervalMatrixBase.h:141
Matrix()=delete
Deleted default constructor to prevent default instantiation when either the number of rows or column...
auto ub() const
Returns a matrix containing the upper bounds of each interval element.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:103
auto lb() const
Returns a matrix containing the lower bounds of each interval element.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:91
template<int R = RowsAtCompileTime, int C = ColsAtCompileTime, typename OtherDerived>
| bool operator== |
( |
const MatrixBase< OtherDerived > & | x | ) |
const |
|
inline |
Compares this interval matrix with another matrix for equality.
Evaluates and casts the other matrix to an interval matrix, then performs an element-wise equality comparison.
- Parameters
-
| x | The other matrix (of arbitrary derived type) to compare. |
- Returns
- true if the matrices are equal after casting; false otherwise.
132{
133 return operator==(x.eval().template cast<codac2::Interval>());
134}
bool operator==(const MatrixBase< OtherDerived > &x) const
Compares this interval matrix with another matrix for equality.
Definition codac2_Matrix_addons_IntervalMatrixBase.h:131
template<typename OtherDerived>
| auto & operator&= |
( |
const MatrixBase< OtherDerived > & | x | ) |
|
|
inline |
Performs element-wise intersection assignment with another matrix.
Updates each element of this matrix by intersecting it with the corresponding element of matrix x.
If x is empty, this matrix is set empty.
- Parameters
-
| x | The matrix to intersect with. |
- Returns
- Reference to this matrix after intersection.
- Precondition
- The size of this matrix and
x must be the same.
206{
207 assert_release(this->size() == x.size());
208
209 if constexpr(std::is_same_v<typename MatrixBase<OtherDerived>::Scalar,
codac2::Interval>)
210 {
211 if(x.is_empty())
212 {
214 return *this;
215 }
216 }
217
218 for(Index i = 0 ; i < this->rows() ; i++)
219 for(Index j = 0 ; j < this->cols() ; j++)
220 (*this)(i,j) &= x(i,j);
221 return *this;
222}
template<typename OtherDerived>
| auto & operator|= |
( |
const MatrixBase< OtherDerived > & | x | ) |
|
|
inline |
Performs element-wise union assignment with another matrix.
Updates each element of this matrix by taking the union with the corresponding element of matrix x.
If x is empty, this matrix remains unchanged.
- Parameters
-
| x | The matrix to union with. |
- Returns
- Reference to this matrix after union.
- Precondition
- The size of this matrix and
x must be the same.
239{
240 assert_release(this->size() == x.size());
241
242 if constexpr(std::is_same_v<typename MatrixBase<OtherDerived>::Scalar,
codac2::Interval>)
243 {
244 if(x.is_empty())
245 return *this;
246 }
247
248 for(Index i = 0 ; i < this->rows() ; i++)
249 for(Index j = 0 ; j < this->cols() ; j++)
250 (*this)(i,j) |= x(i,j);
251 return *this;
252}