48template<
int R=RowsAtCompileTime,
int C=ColsAtCompileTime>
49 requires IsIntervalDomain<Scalar>
53 assert_release(
lb.size() ==
ub.size());
55 for(Index i = 0 ; i < this->size() ; i++)
57 auto& lbi = *(this->data()+i);
58 const auto& ubi = *(
ub.data()+i);
89template<
int R=RowsAtCompileTime,
int C=ColsAtCompileTime>
90 requires IsIntervalDomain<Scalar>
91Matrix(
int r,
int c,
const double bounds[][2])
94 assert_release(r > 0 && c > 0);
97 for(Index i = 0 ; i < this->rows() ; i++)
98 for(Index j = 0 ; j < this->cols() ; j++)
103 assert_release(k == this->size() &&
"incorrect array size");
115 for(Index i = 0 ; i < this->size() ; i++)
116 (this->data()+i)->init();
129template<
int R=RowsAtCompileTime,
int C=ColsAtCompileTime,
typename OtherDerived>
130 requires IsIntervalDomain<Scalar>
131inline bool operator==(
const MatrixBase<OtherDerived>& x)
const
133 return operator==(x.eval().template cast<codac2::Interval>());
142 requires IsIntervalDomain<Scalar>
153 requires IsIntervalDomain<Scalar>
164 requires IsIntervalDomain<Scalar>
175 requires IsIntervalDomain<Scalar>
186 requires IsIntervalDomain<Scalar>
197 requires IsIntervalDomain<Scalar>
219 requires IsIntervalDomain<Scalar>
225 double d = min ? codac2::oo : -1;
226 int selected_index = -1;
227 bool unbounded =
false;
228 assert_release(!this->
is_empty() &&
"Diameter of an empty IntervalVector is undefined");
232 for(i = 0 ; i < this->size() ; i++)
241 double w = (this->data()+i)->
diam();
250 if(min && selected_index == -1)
259 if(unbounded && (!min || selected_index == -1))
261 double pt = min ? -codac2::oo : codac2::oo;
264 for(; i < this->size() ; i++)
266 if((this->data()+i)->
lb() == -codac2::oo)
268 if((this->data()+i)->
ub() == codac2::oo)
275 if((min && (-(this->data()+i)->
ub() > pt)) || (!min && (-(this->data()+i)->
ub() < pt)))
278 pt = -(this->data()+i)->
ub();
282 else if((this->data()+i)->
ub() == codac2::oo)
283 if((min && ((this->data()+i)->
lb() > pt)) || (!min && ((this->data()+i)->
lb() < pt)))
286 pt = (this->data()+i)->
lb();
291 return selected_index;
300 requires IsIntervalDomain<Scalar>
316 requires IsIntervalDomain<Scalar>
318 assert_release(r >= 0.);
320 for(Index i = 0 ; i < this->size() ; i++)
321 (this->data()+i)->inflate(r);
336template<
typename OtherDerived>
337 requires IsIntervalDomain<Scalar>
338inline auto&
inflate(
const MatrixBase<OtherDerived>& r)
340 assert_release(this->size() == r.size());
341 assert_release(r.min_coeff() >= 0.);
343 for(Index i = 0 ; i < this->rows() ; i++)
344 for(Index j = 0 ; j < this->cols() ; j++)
362template<
typename OtherDerived>
365 assert_release(this->size() == x.size());
367 if constexpr(std::is_same_v<typename MatrixBase<OtherDerived>::Scalar,
codac2::Interval>)
376 for(Index i = 0 ; i < this->rows() ; i++)
377 for(Index j = 0 ; j < this->cols() ; j++)
378 (*
this)(i,j) &= x(i,j);
395template<
typename OtherDerived>
398 assert_release(this->size() == x.size());
400 if constexpr(std::is_same_v<typename MatrixBase<OtherDerived>::Scalar,
codac2::Interval>)
406 for(Index i = 0 ; i < this->rows() ; i++)
407 for(Index j = 0 ; j < this->cols() ; j++)
408 (*
this)(i,j) |= x(i,j);
421template<
typename OtherDerived>
422inline auto operator&(
const MatrixBase<OtherDerived>& x)
const
437template<
typename OtherDerived>
438inline auto operator|(
const MatrixBase<OtherDerived>& x)
const
441 return y |= x.template cast<codac2::Interval>();
451template<
int R=RowsAtCompileTime,
int C=ColsAtCompileTime>
452 requires IsIntervalDomain<Scalar>
453inline static auto empty(Index r, Index c)
455 assert_release(r >= 0 && c >= 0);
471template<
int R=RowsAtCompileTime,
int C=ColsAtCompileTime>
472 requires IsIntervalDomain<Scalar>
473inline auto bisect(Index i,
float ratio = 0.49)
const
475 assert_release(i >= 0 && i < this->size());
479 auto p = std::make_pair(*
this,*
this);
480 auto pi = (this->data()+i)->
bisect(ratio);
481 *(p.first.data()+i) = pi.first;
482 *(p.second.data()+i) = pi.second;
495template<
int R=RowsAtCompileTime,
int C=ColsAtCompileTime>
496 requires IsIntervalDomain<Scalar>
Interval class, for representing closed and connected subsets of .
Definition codac2_Interval.h:49
static Interval empty()
Provides an empty interval.
Definition codac2_Interval_impl.h:551
auto & operator&=(const MatrixBase< OtherDerived > &x)
Performs element-wise intersection assignment with another matrix.
Definition codac2_Matrix_addons_IntervalMatrixBase.h:363
auto & inflate(double r)
Inflates all intervals in the matrix by a fixed radius.
Definition codac2_Matrix_addons_IntervalMatrixBase.h:315
bool operator==(const MatrixBase< OtherDerived > &x) const
Compares this interval matrix with another matrix for equality.
Definition codac2_Matrix_addons_IntervalMatrixBase.h:131
Index max_diam_index() const
Returns the index of the element with the maximum diameter.
Definition codac2_Matrix_addons_IntervalMatrixBase.h:196
double min_diam() const
Returns the minimum diameter among the interval elements.
Definition codac2_Matrix_addons_IntervalMatrixBase.h:163
double min_rad() const
Returns the minimum radius among the interval elements.
Definition codac2_Matrix_addons_IntervalMatrixBase.h:141
Index extr_diam_index(bool min) const
Returns the index of the element with the minimum or maximum diameter.
Definition codac2_Matrix_addons_IntervalMatrixBase.h:218
Index min_diam_index() const
Returns the index of the element with the minimum diameter.
Definition codac2_Matrix_addons_IntervalMatrixBase.h:185
double max_diam() const
Returns the maximum diameter among the interval elements.
Definition codac2_Matrix_addons_IntervalMatrixBase.h:174
auto bisect(Index i, float ratio=0.49) const
Bisects the interval at the given index into two sub-interval matrices.
Definition codac2_Matrix_addons_IntervalMatrixBase.h:473
void set_empty()
Marks the interval matrix as empty.
Definition codac2_Matrix_addons_IntervalMatrixBase.h:299
auto bisect_largest(float ratio=0.49) const
Bisects the interval with the largest diameter in the matrix.
Definition codac2_Matrix_addons_IntervalMatrixBase.h:497
double max_rad() const
Returns the maximum radius among the interval elements.
Definition codac2_Matrix_addons_IntervalMatrixBase.h:152
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
auto & init()
Initializes all elements of the matrix with default intervals.
Definition codac2_Matrix_addons_IntervalMatrixBase.h:113
auto & operator|=(const MatrixBase< OtherDerived > &x)
Performs element-wise union assignment with another matrix.
Definition codac2_Matrix_addons_IntervalMatrixBase.h:396
auto operator&(const MatrixBase< OtherDerived > &x) const
Returns the element-wise intersection of this matrix with another.
Definition codac2_Matrix_addons_IntervalMatrixBase.h:422
auto operator|(const MatrixBase< OtherDerived > &x) const
Returns the element-wise union of this matrix with another.
Definition codac2_Matrix_addons_IntervalMatrixBase.h:438
Matrix()=delete
Deleted default constructor to prevent default instantiation when either the number of rows or column...
auto lb() const
Returns a matrix containing the lower bounds of each interval element.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:91
bool is_unbounded() const
Checks if the interval matrix contains any unbounded intervals.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:283
auto diam() const
Returns a matrix containing the diameters of each interval element.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:185
bool is_empty() const
Checks whether the interval matrix is empty.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:56
bool interior_contains(const Matrix< double, RowsAtCompileTime, ColsAtCompileTime > &x) const
Checks if the interior of this interval matrix contains the specified matrix x.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:242
bool is_bisectable() const
Checks whether at least one interval in the matrix is bisectable.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:739
auto ub() const
Returns a matrix containing the upper bounds of each interval element.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:103