From 4a9e32ae0b4d4adf74d339969746c0f9c724e432 Mon Sep 17 00:00:00 2001 From: Charles Schlosser Date: Tue, 10 Dec 2024 12:40:39 +0000 Subject: [PATCH] matrix equality operator --- Eigen/src/Core/MatrixBase.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h index 81d5a97ea..5466a57c4 100644 --- a/Eigen/src/Core/MatrixBase.h +++ b/Eigen/src/Core/MatrixBase.h @@ -280,7 +280,7 @@ class MatrixBase : public DenseBase { * \sa isApprox(), operator!= */ template EIGEN_DEVICE_FUNC inline bool operator==(const MatrixBase& other) const { - return cwiseEqual(other).all(); + return (this->rows() == other.rows()) && (this->cols() == other.cols()) && cwiseEqual(other).all(); } /** \returns true if at least one pair of coefficients of \c *this and \a other are not exactly equal to each other. @@ -289,7 +289,7 @@ class MatrixBase : public DenseBase { * \sa isApprox(), operator== */ template EIGEN_DEVICE_FUNC inline bool operator!=(const MatrixBase& other) const { - return cwiseNotEqual(other).any(); + return !(*this == other); } NoAlias EIGEN_DEVICE_FUNC noalias();