31template<
typename U=Scalar>
32 requires IsIntervalDomain<U>
39 for(Index i = 0 ; i < this->rows() ; i++)
40 for(Index j = 0 ; j < this->cols() ; j++)
44 v += std::log((*
this)(i,j).
diam());
58 for(Index i = 0 ; i < rows() ; i++)
59 for(Index j = 0 ; j < cols() ; j++)
69#define degenerate_mat(op) \
70 Matrix<double,RowsAtCompileTime,ColsAtCompileTime> m(this->rows(),this->cols()); \
72 if(this->is_empty()) \
73 m.init(std::numeric_limits<double>::quiet_NaN()); \
77 for(Index i = 0 ; i < this->rows() ; i++) \
78 for(Index j = 0 ; j < this->cols() ; j++) \
79 m(i,j) = (*this)(i,j).op(); \
89template<
typename U=Scalar>
90 requires IsIntervalDomain<U>
101template<
typename U=Scalar>
102 requires IsIntervalDomain<U>
103inline auto ub()
const
115template<
typename U=Scalar>
116 requires IsIntervalDomain<U>
129template<
typename U=Scalar>
130 requires IsIntervalDomain<U>
141template<
typename U=Scalar>
142 requires IsIntervalDomain<U>
155template<
typename U=Scalar>
156 requires IsIntervalDomain<U>
167template<
typename U=Scalar>
168 requires IsIntervalDomain<U>
181template<
typename U=Scalar>
182 requires IsIntervalDomain<U>
195template<
typename U=Scalar>
196 requires IsIntervalDomain<U>
209template<
typename U=Scalar>
210 requires IsIntervalDomain<U>
222inline double min_rad(
const std::vector<Index>& among_indices = {})
const
223 requires IsIntervalDomain<Scalar>
234inline double max_rad(
const std::vector<Index>& among_indices = {})
const
235 requires IsIntervalDomain<Scalar>
246inline double min_diam(
const std::vector<Index>& among_indices = {})
const
247 requires IsIntervalDomain<Scalar>
258inline double max_diam(
const std::vector<Index>& among_indices = {})
const
259 requires IsIntervalDomain<Scalar>
271 requires IsIntervalDomain<Scalar>
283 requires IsIntervalDomain<Scalar>
305inline Index
extr_diam_index(
bool min,
const std::vector<Index>& among_indices = {})
const
306 requires IsIntervalDomain<Scalar>
309 among_indices.empty() ||
310 std::ranges::all_of(among_indices, [&](Index k){ return 0 <= k && k < this->size(); })
317 double d =
min ? codac2::oo : -1;
318 int selected_index = -1;
319 bool unbounded =
false;
320 assert_release(!this->
is_empty() &&
"Diameter of an empty IntervalVector is undefined");
324 for(i = 0 ; i < this->size() ; i++)
326 if(!among_indices.empty()
327 && std::find(among_indices.begin(),among_indices.end(),i) == among_indices.end())
337 double w = coeff(i).diam();
346 if(min && selected_index == -1)
350 if(among_indices.empty())
356 i = among_indices[0];
361 if(unbounded && (!min || selected_index == -1))
363 double pt =
min ? -codac2::oo : codac2::oo;
366 for(; i < this->size() ; i++)
368 if(!among_indices.empty()
369 && std::find(among_indices.begin(),among_indices.end(),i) == among_indices.end())
372 if(coeff(i).
lb() == -codac2::oo)
374 if(coeff(i).
ub() == codac2::oo)
381 if((min && (-coeff(i).
ub() > pt)) || (!min && (-coeff(i).
ub() < pt)))
388 else if(coeff(i).
ub() == codac2::oo)
389 if((min && (coeff(i).
lb() > pt)) || (!min && (coeff(i).
lb() < pt)))
397 return selected_index;
419template<
typename OtherDerived>
420inline bool contains(
const MatrixBase<OtherDerived>& x)
const
431 assert_release(x.size() == this->size());
436 for(Index i = 0 ; i < this->rows() ; i++)
437 for(Index j = 0 ; j < this->cols() ; j++)
463template<
typename OtherDerived>
475 assert_release(x.size() == this->size());
480 for(Index i = 0 ; i < this->rows() ; i++)
481 for(Index j = 0 ; j < this->cols() ; j++)
496 for(Index i = 0 ; i < this->rows() ; i++)
497 for(Index j = 0 ; j < this->cols() ; j++)
512 for(Index i = 0 ; i < this->rows() ; i++)
513 for(Index j = 0 ; j < this->cols() ; j++)
530 for(Index i = 0 ; i < this->rows() ; i++)
531 for(Index j = 0 ; j < this->cols() ; j++)
556template<
typename OtherDerived>
557inline bool intersects(
const MatrixBase<OtherDerived>& x)
const
565template<
typename OtherDerived>
568 assert_release(this->size() == x.size());
573 for(Index i = 0 ; i < this->rows() ; i++)
574 for(Index j = 0 ; j < this->cols() ; j++)
600template<
typename OtherDerived>
609template<
typename OtherDerived>
612 assert_release(this->size() == x.size());
617 for(Index i = 0 ; i < this->rows() ; i++)
618 for(Index j = 0 ; j < this->cols() ; j++)
644template<
typename OtherDerived>
645inline bool overlaps(
const MatrixBase<OtherDerived>& x)
const
653template<
typename OtherDerived>
654inline bool _overlaps(
const MatrixBase<OtherDerived>& x)
const
656 assert_release(this->size() == x.size());
661 for(Index i = 0 ; i < this->rows() ; i++)
662 for(Index j = 0 ; j < this->cols() ; j++)
689template<
typename OtherDerived>
690inline bool is_subset(
const MatrixBase<OtherDerived>& x)
const
701 assert_release(this->size() == x.size());
706 for(Index i = 0 ; i < this->rows() ; i++)
707 for(Index j = 0 ; j < this->cols() ; j++)
733template<
typename OtherDerived>
745 assert_release(this->size() == x.size());
753 for(Index i = 0 ; i < this->rows() ; i++)
754 for(Index j = 0 ; j < this->cols() ; j++)
780template<
typename OtherDerived>
789template<
typename OtherDerived>
792 assert_release(this->size() == x.size());
797 for(Index i = 0 ; i < this->rows() ; i++)
798 for(Index j = 0 ; j < this->cols() ; j++)
825template<
typename OtherDerived>
834template<
typename OtherDerived>
837 assert_release(this->size() == x.size());
842 for(Index i = 0 ; i < this->rows() ; i++)
843 for(Index j = 0 ; j < this->cols() ; j++)
869template<
typename OtherDerived>
878template<
typename OtherDerived>
881 assert_release(this->size() == x.size());
886 for(Index i = 0 ; i < this->rows() ; i++)
887 for(Index j = 0 ; j < this->cols() ; j++)
914template<
typename OtherDerived>
923template<
typename OtherDerived>
926 assert_release(this->size() == x.size());
934 for(Index i = 0 ; i < this->rows() ; i++)
935 for(Index j = 0 ; j < this->cols() ; j++)
951 for(Index i = 0 ; i < this->rows() ; i++)
952 for(Index j = 0 ; j < this->cols() ; j++)
965 for(Index i = 0 ; i < this->rows() ; i++)
966 for(Index j = 0 ; j < this->cols() ; j++)
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 overlaps(const Matrix< codac2::Interval, RowsAtCompileTime, ColsAtCompileTime > &x) const
Checks whether this matrix overlaps with another.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:633
double volume() const
Computes the volume of the interval matrix.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:33
double min_diam(const std::vector< Index > &among_indices={}) const
Returns the minimum diameter among the interval elements.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:246
bool is_strict_superset(const Matrix< codac2::Interval, RowsAtCompileTime, ColsAtCompileTime > &x) const
Checks whether this matrix is a strict superset of another matrix.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:903
bool is_degenerated() const
Checks if the interval matrix is degenerated.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:510
auto diam() const
Returns a matrix containing the diameters of each interval element.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:211
double max_rad(const std::vector< Index > &among_indices={}) const
Returns the maximum radius among the interval elements.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:234
bool is_superset(const Matrix< codac2::Interval, RowsAtCompileTime, ColsAtCompileTime > &x) const
Checks whether this matrix is a superset of another interval matrix.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:858
Index extr_diam_index(bool min, const std::vector< Index > &among_indices={}) const
Returns the index of the element with the minimum or maximum diameter.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:305
bool is_unbounded() const
Checks if the interval matrix contains any unbounded intervals.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:493
bool _is_subset(const T &x) const
Internal helper for subset check.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:699
bool is_interior_subset(const Matrix< codac2::Interval, RowsAtCompileTime, ColsAtCompileTime > &x) const
Checks whether this matrix is an interior subset of another.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:769
bool is_strict_subset(const Matrix< codac2::Interval, RowsAtCompileTime, ColsAtCompileTime > &x) const
Checks whether this matrix is a strict subset of another matrix.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:722
double max_diam(const std::vector< Index > &among_indices={}) const
Returns the maximum diameter among the interval elements.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:258
bool is_empty() const
Checks whether the interval matrix is empty.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:56
bool _is_strict_subset(const T &x) const
Internal helper for strict subset check.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:743
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:452
bool is_subset(const Matrix< codac2::Interval, RowsAtCompileTime, ColsAtCompileTime > &x) const
Checks whether this matrix is a subset of another interval matrix.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:678
bool _overlaps(const MatrixBase< OtherDerived > &x) const
Internal helper to check overlap.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:654
auto mig() const
Returns a matrix containing the mignitudes of each interval element.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:143
bool is_disjoint(const Matrix< codac2::Interval, RowsAtCompileTime, ColsAtCompileTime > &x) const
Checks if this matrix is disjoint with another matrix of intervals.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:589
auto mid() const
Returns a matrix containing the midpoints of each interval element.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:117
Index min_diam_index(const std::vector< Index > &among_indices={}) const
Returns the index of the element with the minimum diameter.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:270
bool _is_interior_subset(const MatrixBase< OtherDerived > &x) const
Internal helper for interior subset checking.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:790
#define degenerate_mat(op)
Helper macro to create a matrix from a specific operation applied to each interval element.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:69
bool _interior_contains(const T &x) const
Internal helper function to check interior containment.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:473
bool is_strict_interior_subset(const Matrix< codac2::Interval, RowsAtCompileTime, ColsAtCompileTime > &x) const
Checks whether this matrix is a strict interior subset of another matrix.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:814
bool _is_strict_interior_subset(const MatrixBase< OtherDerived > &x) const
Internal helper for strict interior subset relation.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:835
bool is_flat() const
Checks if the interval matrix is flat.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:527
bool is_bisectable() const
Checks whether at least one interval in the matrix is bisectable.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:949
bool _is_superset(const MatrixBase< OtherDerived > &x) const
Internal helper for superset check.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:879
auto rand() const
Returns a matrix with random values chosen inside each interval element.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:183
auto mag() const
Returns a matrix containing the magnitudes of each interval element.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:131
bool _contains(const T &x) const
Internal helper function to check containment.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:429
Index max_diam_index(const std::vector< Index > &among_indices={}) const
Returns the index of the element with the maximum diameter.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:282
bool has_integer_bounds() const
Checks whether all intervals in the matrix have integer lower and upper bounds.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:963
bool contains(const Matrix< double, RowsAtCompileTime, ColsAtCompileTime > &x) const
Checks if this interval matrix contains the specified matrix x.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:408
auto ub() const
Returns a matrix containing the upper bounds of each interval element.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:103
bool _intersects(const MatrixBase< OtherDerived > &x) const
Internal helper that performs intersection checking.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:566
auto lb() const
Returns a matrix containing the lower bounds of each interval element.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:91
auto smag() const
Returns a matrix containing the signed magnitudes of each interval element.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:157
double min_rad(const std::vector< Index > &among_indices={}) const
Returns the minimum radius among the interval elements.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:222
bool _is_disjoint(const MatrixBase< OtherDerived > &x) const
Internal helper for disjointness checking.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:610
auto rad() const
Returns a matrix containing the radii of each interval element.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:197
bool intersects(const Matrix< codac2::Interval, RowsAtCompileTime, ColsAtCompileTime > &x) const
Checks whether this matrix intersects with another matrix of intervals.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:545
auto smig() const
Returns a matrix containing the signed mignitudes of each interval element.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:169
bool _is_strict_superset(const MatrixBase< OtherDerived > &x) const
Internal helper for strict superset check.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:924
Interval min(const Interval &x, const Interval &y)
Returns .
Definition codac2_Interval_operations_impl.h:269