Skip to content

Commit 94b79f7

Browse files
committed
make matrix equal comparable
1 parent 3b41555 commit 94b79f7

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

ql/math/matrix.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ namespace QuantLib {
6060

6161
Matrix& operator=(const Matrix&);
6262
Matrix& operator=(Matrix&&) noexcept;
63+
64+
bool operator==(const Matrix&) const;
65+
bool operator!=(const Matrix&) const;
6366
//@}
6467

6568
//! \name Algebraic operators
@@ -255,6 +258,15 @@ namespace QuantLib {
255258
return *this;
256259
}
257260

261+
inline bool Matrix::operator==(const Matrix& to) const {
262+
return rows_ == to.rows_ && columns_ == to.columns_ &&
263+
std::equal(begin(), end(), to.begin());
264+
}
265+
266+
inline bool Matrix::operator!=(const Matrix& to) const {
267+
return !(this->operator==(to));
268+
}
269+
258270
inline void Matrix::swap(Matrix& from) {
259271
using std::swap;
260272
data_.swap(from.data_);

0 commit comments

Comments
 (0)