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>
158 requires IsIntervalDomain<Scalar>
160 assert_release(r >= 0.);
162 for(Index i = 0 ; i < this->size() ; i++)
163 (this->data()+i)->inflate(r);
178template<
typename OtherDerived>
179 requires IsIntervalDomain<Scalar>
180inline auto&
inflate(
const MatrixBase<OtherDerived>& r)
182 assert_release(this->size() == r.size());
183 assert_release(r.min_coeff() >= 0.);
185 for(Index i = 0 ; i < this->rows() ; i++)
186 for(Index j = 0 ; j < this->cols() ; j++)
204template<
typename OtherDerived>
207 assert_release(this->size() == x.size());
209 if constexpr(std::is_same_v<typename MatrixBase<OtherDerived>::Scalar,
codac2::Interval>)
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);
237template<
typename OtherDerived>
240 assert_release(this->size() == x.size());
242 if constexpr(std::is_same_v<typename MatrixBase<OtherDerived>::Scalar,
codac2::Interval>)
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);
263template<
typename OtherDerived>
264inline auto operator&(
const MatrixBase<OtherDerived>& x)
const
279template<
typename OtherDerived>
280inline auto operator|(
const MatrixBase<OtherDerived>& x)
const
283 return y |= x.template cast<codac2::Interval>();
293template<
int R=RowsAtCompileTime,
int C=ColsAtCompileTime>
294 requires IsIntervalDomain<Scalar>
295inline static auto empty(Index r, Index c)
297 assert_release(r >= 0 && c >= 0);
313template<
int R=RowsAtCompileTime,
int C=ColsAtCompileTime>
314 requires IsIntervalDomain<Scalar>
315inline auto bisect(Index i,
float ratio = 0.49)
const
317 assert_release(i >= 0 && i < this->size());
321 auto p = std::make_pair(*
this,*
this);
322 auto pi = (this->data()+i)->
bisect(ratio);
323 *(p.first.data()+i) = pi.first;
324 *(p.second.data()+i) = pi.second;
337template<
int R=RowsAtCompileTime,
int C=ColsAtCompileTime>
338 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:568
auto & operator&=(const MatrixBase< OtherDerived > &x)
Performs element-wise intersection assignment with another matrix.
Definition codac2_Matrix_addons_IntervalMatrixBase.h:205
auto & inflate(double r)
Inflates all intervals in the matrix by a fixed radius.
Definition codac2_Matrix_addons_IntervalMatrixBase.h:157
bool operator==(const MatrixBase< OtherDerived > &x) const
Compares this interval matrix with another matrix for equality.
Definition codac2_Matrix_addons_IntervalMatrixBase.h:131
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:315
void set_empty()
Marks the interval matrix as empty.
Definition codac2_Matrix_addons_IntervalMatrixBase.h:141
auto bisect_largest(float ratio=0.49) const
Bisects the interval with the largest diameter in the matrix.
Definition codac2_Matrix_addons_IntervalMatrixBase.h:339
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:238
auto operator&(const MatrixBase< OtherDerived > &x) const
Returns the element-wise intersection of this matrix with another.
Definition codac2_Matrix_addons_IntervalMatrixBase.h:264
auto operator|(const MatrixBase< OtherDerived > &x) const
Returns the element-wise union of this matrix with another.
Definition codac2_Matrix_addons_IntervalMatrixBase.h:280
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
Index max_diam_index() const
Returns the index of the element with the maximum diameter.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:276
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:426
bool is_bisectable() const
Checks whether at least one interval in the matrix is bisectable.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:923
auto ub() const
Returns a matrix containing the upper bounds of each interval element.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:103