ZonoOpt 2.3.0
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
49 IntervalMatrix(const Eigen::Matrix<zono_float, -1, -1>& mat_lb,
50 const Eigen::Matrix<zono_float, -1, -1>& mat_ub);
51
57 explicit IntervalMatrix(const Eigen::Matrix<Interval, -1, -1>& mat);
58
64 std::vector<std::vector<Interval>> to_array() const;
65
71 std::tuple<int, int, std::vector<Eigen::Triplet<Interval>>> to_triplets() const;
72
79 Eigen::SparseMatrix<zono_float> center() const;
80
87 Eigen::SparseMatrix<zono_float> diam() const;
88
95 IntervalMatrix radius() const;
96
103 zono_float width() const;
104
109 bool is_empty() const;
110
115 bool is_single_valued() const;
116
123 IntervalMatrix intersect(const IntervalMatrix& other) const;
124
131 IntervalMatrix interval_hull(const IntervalMatrix& other) const;
132
139 bool contains(const Eigen::SparseMatrix<zono_float>& mat) const;
140
147 bool contains_set(const IntervalMatrix& other) const;
148
154 Box operator*(const Eigen::Vector<zono_float, -1>& v) const;
155
161 Box operator*(const Box& box) const;
162
169
174 void operator*=(zono_float alpha);
175
182 friend IntervalMatrix operator*(zono_float alpha, const IntervalMatrix& A);
183
189 IntervalMatrix operator*(const Interval& interval) const;
190
197 friend IntervalMatrix operator*(const Interval& interval, const IntervalMatrix& A);
198
203 void operator*=(const Interval& interval);
204
211
218 friend IntervalMatrix operator/(zono_float alpha, const IntervalMatrix& A);
219
224 void operator/=(zono_float alpha);
225
231 IntervalMatrix operator/(const Interval& interval) const;
232
239 friend IntervalMatrix operator/(const Interval& interval, const IntervalMatrix& A);
240
245 void operator/=(const Interval& interval);
246
252 IntervalMatrix operator*(const Eigen::SparseMatrix<zono_float, Eigen::RowMajor>& A) const;
253
260 friend IntervalMatrix operator*(const Eigen::SparseMatrix<zono_float, Eigen::RowMajor>& A, const IntervalMatrix& B);
261
267 IntervalMatrix operator*(const Eigen::Matrix<zono_float, -1, -1>& A) const;
268
275 friend IntervalMatrix operator*(const Eigen::Matrix<zono_float, -1, -1>& A, const IntervalMatrix& B);
276
282 IntervalMatrix operator*(const IntervalMatrix& other) const;
283
288 void operator*=(const IntervalMatrix& other);
289
295 IntervalMatrix operator+(const IntervalMatrix& other) const;
296
301 void operator+=(const IntervalMatrix& other);
302
308 IntervalMatrix operator+(const Interval& interval) const;
309
316 friend IntervalMatrix operator+(const Interval& interval, const IntervalMatrix& mat);
317
322 void operator+=(const Interval& interval);
323
330
337 friend IntervalMatrix operator+(zono_float alpha, const IntervalMatrix& A);
338
343 void operator+=(zono_float alpha);
344
345
351 IntervalMatrix operator-(const IntervalMatrix& other) const;
352
357 void operator-=(const IntervalMatrix& other);
358
359
365 IntervalMatrix operator-(const Interval& interval) const;
366
373 friend IntervalMatrix operator-(const Interval& interval, const IntervalMatrix& mat);
374
379 void operator-=(const Interval& interval);
380
387
394 friend IntervalMatrix operator-(zono_float alpha, const IntervalMatrix& A);
395
400 void operator-=(zono_float alpha);
401
407
414 IntervalMatrix operator&(const IntervalMatrix& other) const;
415
422 IntervalMatrix operator|(const IntervalMatrix& other) const;
423
430 bool operator<=(const IntervalMatrix& other) const;
431
438 bool operator>=(const IntervalMatrix& other) const;
439
446 bool operator==(const IntervalMatrix& other) const;
447
452 size_t rows() const { return rows_; }
453
458 size_t cols() const { return cols_; }
459
464 std::string print() const;
465
472 friend std::ostream& operator<<(std::ostream& os, const IntervalMatrix& interval_matrix);
473
474 private:
475 size_t rows_, cols_;
476 std::vector<std::vector<std::pair<size_t, Interval>>> mat_; // rows->cols->vals
477 };
478
479}
480
481
482#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:452
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:458
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