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();