ZonoOpt 2.2.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
111 IntervalMatrix intersect(const IntervalMatrix& other) const;
112
119 IntervalMatrix interval_hull(const IntervalMatrix& other) const;
120
127 bool contains(const Eigen::SparseMatrix<zono_float>& mat) const;
128
135 bool contains_set(const IntervalMatrix& other) const;
136
142 Box operator*(const Eigen::Vector<zono_float, -1>& v) const;
143
149 Box operator*(const Box& box) const;
150
157
162 void operator*=(zono_float alpha);
163
170 friend IntervalMatrix operator*(zono_float alpha, const IntervalMatrix& A);
171
177 IntervalMatrix operator*(const Interval& interval) const;
178
185 friend IntervalMatrix operator*(const Interval& interval, const IntervalMatrix& A);
186
191 void operator*=(const Interval& interval);
192
199
206 friend IntervalMatrix operator/(zono_float alpha, const IntervalMatrix& A);
207
212 void operator/=(zono_float alpha);
213
219 IntervalMatrix operator/(const Interval& interval) const;
220
227 friend IntervalMatrix operator/(const Interval& interval, const IntervalMatrix& A);
228
233 void operator/=(const Interval& interval);
234
240 IntervalMatrix operator*(const Eigen::SparseMatrix<zono_float, Eigen::RowMajor>& A) const;
241
248 friend IntervalMatrix operator*(const Eigen::SparseMatrix<zono_float, Eigen::RowMajor>& A, const IntervalMatrix& B);
249
255 IntervalMatrix operator*(const Eigen::Matrix<zono_float, -1, -1>& A) const;
256
263 friend IntervalMatrix operator*(const Eigen::Matrix<zono_float, -1, -1>& A, const IntervalMatrix& B);
264
270 IntervalMatrix operator*(const IntervalMatrix& other) const;
271
276 void operator*=(const IntervalMatrix& other);
277
283 IntervalMatrix operator+(const IntervalMatrix& other) const;
284
289 void operator+=(const IntervalMatrix& other);
290
296 IntervalMatrix operator+(const Interval& interval) const;
297
304 friend IntervalMatrix operator+(const Interval& interval, const IntervalMatrix& mat);
305
310 void operator+=(const Interval& interval);
311
318
325 friend IntervalMatrix operator+(zono_float alpha, const IntervalMatrix& A);
326
331 void operator+=(zono_float alpha);
332
333
339 IntervalMatrix operator-(const IntervalMatrix& other) const;
340
345 void operator-=(const IntervalMatrix& other);
346
347
353 IntervalMatrix operator-(const Interval& interval) const;
354
361 friend IntervalMatrix operator-(const Interval& interval, const IntervalMatrix& mat);
362
367 void operator-=(const Interval& interval);
368
375
382 friend IntervalMatrix operator-(zono_float alpha, const IntervalMatrix& A);
383
388 void operator-=(zono_float alpha);
389
395
402 IntervalMatrix operator&(const IntervalMatrix& other) const;
403
410 IntervalMatrix operator|(const IntervalMatrix& other) const;
411
418 bool operator<=(const IntervalMatrix& other) const;
419
426 bool operator>=(const IntervalMatrix& other) const;
427
434 bool operator==(const IntervalMatrix& other) const;
435
440 size_t rows() const { return rows_; }
441
446 size_t cols() const { return cols_; }
447
452 std::string print() const;
453
460 friend std::ostream& operator<<(std::ostream& os, const IntervalMatrix& interval_matrix);
461
462 private:
463 size_t rows_, cols_;
464 std::vector<std::vector<std::pair<size_t, Interval>>> mat_; // rows->cols->vals
465 };
466
467}
468
469
470#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:638
size_t rows() const
Get number of rows.
Definition IntervalMatrix.hpp:440
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:715
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:671
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:605
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:732
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
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
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:693
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:446
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