ZonoOpt 2.4.1
Loading...
Searching...
No Matches
IntervalMatrix.hpp
Go to the documentation of this file.
1#ifndef ZONOOPT_INTERVALMATRIX_HPP_
2#define ZONOOPT_INTERVALMATRIX_HPP_
3
15#include "Interval.hpp"
16#include "Box.hpp"
17
18namespace ZonoOpt
19{
20 using namespace detail;
21
27 {
28 public:
32 IntervalMatrix() : rows_(0), cols_(0)
33 {
34 }
35
42 IntervalMatrix(size_t rows, size_t cols, const std::vector<Eigen::Triplet<Interval>>& triplets);
43
50 IntervalMatrix(const Eigen::Matrix<zono_float, -1, -1>& mat_lb,
51 const Eigen::Matrix<zono_float, -1, -1>& mat_ub);
52
58 explicit IntervalMatrix(const Eigen::Matrix<Interval, -1, -1>& mat);
59
65 std::vector<std::vector<Interval>> to_array() const;
66
72 std::tuple<int, int, std::vector<Eigen::Triplet<Interval>>> to_triplets() const;
73
80 Eigen::SparseMatrix<zono_float> center() const;
81
88 Eigen::SparseMatrix<zono_float> diam() const;
89
96 IntervalMatrix radius() const;
97
104 zono_float width() const;
105
110 bool is_empty() const;
111
116 bool is_single_valued() const;
117
125 IntervalMatrix intersect(const IntervalMatrix& other) const;
126
134 IntervalMatrix interval_hull(const IntervalMatrix& other) const;
135
143 bool contains(const Eigen::SparseMatrix<zono_float>& mat) const;
144
152 bool contains_set(const IntervalMatrix& other) const;
153
160 Box operator*(const Eigen::Vector<zono_float, -1>& v) const;
161
168 Box operator*(const Box& box) const;
169
176
181 void operator*=(zono_float alpha);
182
189 friend IntervalMatrix operator*(zono_float alpha, const IntervalMatrix& A);
190
196 IntervalMatrix operator*(const Interval& interval) const;
197
204 friend IntervalMatrix operator*(const Interval& interval, const IntervalMatrix& A);
205
210 void operator*=(const Interval& interval);
211
218
225 friend IntervalMatrix operator/(zono_float alpha, const IntervalMatrix& A);
226
231 void operator/=(zono_float alpha);
232
238 IntervalMatrix operator/(const Interval& interval) const;
239
246 friend IntervalMatrix operator/(const Interval& interval, const IntervalMatrix& A);
247
252 void operator/=(const Interval& interval);
253
260 IntervalMatrix operator*(const Eigen::SparseMatrix<zono_float, Eigen::RowMajor>& A) const;
261
269 friend IntervalMatrix operator*(const Eigen::SparseMatrix<zono_float, Eigen::RowMajor>& A, const IntervalMatrix& B);
270
277 IntervalMatrix operator*(const Eigen::Matrix<zono_float, -1, -1>& A) const;
278
286 friend IntervalMatrix operator*(const Eigen::Matrix<zono_float, -1, -1>& A, const IntervalMatrix& B);
287
294 IntervalMatrix operator*(const IntervalMatrix& other) const;
295
301 void operator*=(const IntervalMatrix& other);
302
309 IntervalMatrix operator+(const IntervalMatrix& other) const;
310
316 void operator+=(const IntervalMatrix& other);
317
323 IntervalMatrix operator+(const Interval& interval) const;
324
331 friend IntervalMatrix operator+(const Interval& interval, const IntervalMatrix& mat);
332
337 void operator+=(const Interval& interval);
338
345
352 friend IntervalMatrix operator+(zono_float alpha, const IntervalMatrix& A);
353
358 void operator+=(zono_float alpha);
359
360
367 IntervalMatrix operator-(const IntervalMatrix& other) const;
368
374 void operator-=(const IntervalMatrix& other);
375
376
382 IntervalMatrix operator-(const Interval& interval) const;
383
390 friend IntervalMatrix operator-(const Interval& interval, const IntervalMatrix& mat);
391
396 void operator-=(const Interval& interval);
397
404
411 friend IntervalMatrix operator-(zono_float alpha, const IntervalMatrix& A);
412
417 void operator-=(zono_float alpha);
418
424
432 IntervalMatrix operator&(const IntervalMatrix& other) const;
433
441 IntervalMatrix operator|(const IntervalMatrix& other) const;
442
449 bool operator<=(const IntervalMatrix& other) const;
450
457 bool operator>=(const IntervalMatrix& other) const;
458
465 bool operator==(const IntervalMatrix& other) const;
466
471 size_t rows() const { return rows_; }
472
477 size_t cols() const { return cols_; }
478
483 std::string print() const;
484
491 friend std::ostream& operator<<(std::ostream& os, const IntervalMatrix& interval_matrix);
492
493 private:
494 size_t rows_, cols_;
495 std::vector<std::vector<std::pair<size_t, Interval>>> mat_; // rows->cols->vals
496 };
497
498}
499
500
501#endif
Box and MI_Box classes.
Interval class.
Box (i.e., interval vector) class.
Definition Box.hpp:25
Class for interval matrices (i.e., every element of the matrix is an interval)
Definition IntervalMatrix.hpp:27
IntervalMatrix interval_hull(const IntervalMatrix &other) const
Interval matrix interval hull.
Definition IntervalMatrix.cpp:664
size_t rows() const
Get number of rows.
Definition IntervalMatrix.hpp:471
Eigen::SparseMatrix< zono_float > diam() const
Get diameter matrix.
Definition IntervalMatrix.cpp:563
IntervalMatrix operator&(const IntervalMatrix &other) const
Interval matrix intersection oeprator.
Definition IntervalMatrix.cpp:522
bool operator>=(const IntervalMatrix &other) const
Set containment operator.
Definition IntervalMatrix.cpp:537
std::string print() const
Print method.
Definition IntervalMatrix.cpp:741
zono_float width() const
Get width of interval matrix.
Definition IntervalMatrix.cpp:592
friend IntervalMatrix operator+(const Interval &interval, const IntervalMatrix &mat)
IntervalMatrix element-wise addition with interval.
Definition IntervalMatrix.cpp:167
bool contains(const Eigen::SparseMatrix< zono_float > &mat) const
Check whether the interval matrix contains a given sparse matrix.
Definition IntervalMatrix.cpp:697
void operator/=(zono_float alpha)
IntervalMatrix elementwise division by scalar.
Definition IntervalMatrix.cpp:231
IntervalMatrix intersect(const IntervalMatrix &other) const
Interval matrix intersection.
Definition IntervalMatrix.cpp:631
bool operator<=(const IntervalMatrix &other) const
Set containment operator.
Definition IntervalMatrix.cpp:532
Eigen::SparseMatrix< zono_float > center() const
Get center matrix.
Definition IntervalMatrix.cpp:547
friend std::ostream & operator<<(std::ostream &os, const IntervalMatrix &interval_matrix)
print to ostream
Definition IntervalMatrix.cpp:758
std::vector< std::vector< Interval > > to_array() const
Convert to a vector of vectors of Intervals (row-major)
Definition IntervalMatrix.cpp:85
friend IntervalMatrix operator-(const Interval &interval, const IntervalMatrix &mat)
IntervalMatrix elementwise interval subtraction.
Definition IntervalMatrix.cpp:432
bool operator==(const IntervalMatrix &other) const
Set equality operator.
Definition IntervalMatrix.cpp:542
friend IntervalMatrix operator*(zono_float alpha, const IntervalMatrix &A)
IntervalMatrix scalar multiplication.
Definition IntervalMatrix.cpp:213
bool is_empty() const
Determine whether interval matrix is empty (any contained interval is empty)
Definition IntervalMatrix.cpp:605
void operator-=(const IntervalMatrix &other)
IntervalMatrix subtraction in-place.
Definition IntervalMatrix.cpp:437
void operator*=(zono_float alpha)
IntervalMatrix scalar multiplication in-place.
Definition IntervalMatrix.cpp:185
bool is_single_valued() const
Determine whether interval matrix is single-valued (i.e., all intervals have width 0 within numerical...
Definition IntervalMatrix.cpp:618
friend IntervalMatrix operator/(zono_float alpha, const IntervalMatrix &A)
IntervalMatrix elementwise scalar division.
Definition IntervalMatrix.cpp:483
bool contains_set(const IntervalMatrix &other) const
Check whether the interval matrix contains another interval matrix.
Definition IntervalMatrix.cpp:719
IntervalMatrix operator|(const IntervalMatrix &other) const
Interval matrix interval hull operator.
Definition IntervalMatrix.cpp:527
std::tuple< int, int, std::vector< Eigen::Triplet< Interval > > > to_triplets() const
Convert to triplets.
Definition IntervalMatrix.cpp:111
size_t cols() const
Get number of columns.
Definition IntervalMatrix.hpp:477
IntervalMatrix radius() const
Get radius matrix.
Definition IntervalMatrix.cpp:579
void operator+=(const IntervalMatrix &other)
IntervalMatrix addition in-place.
Definition IntervalMatrix.cpp:365
IntervalMatrix()
IntervalMatrix default constructor.
Definition IntervalMatrix.hpp:32
Interval class.
Definition Interval.hpp:48
#define zono_float
Defines the floating-point type used in ZonoOpt.
Definition ZonoOpt.hpp:45
Definition ZonoOpt.hpp:58