matrix equality operator

This commit is contained in:
Charles Schlosser 2024-12-10 12:40:39 +00:00
parent 00776d1ba4
commit 4a9e32ae0b

View File

@ -280,7 +280,7 @@ class MatrixBase : public DenseBase<Derived> {
* \sa isApprox(), operator!= */ * \sa isApprox(), operator!= */
template <typename OtherDerived> template <typename OtherDerived>
EIGEN_DEVICE_FUNC inline bool operator==(const MatrixBase<OtherDerived>& other) const { EIGEN_DEVICE_FUNC inline bool operator==(const MatrixBase<OtherDerived>& 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. /** \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<Derived> {
* \sa isApprox(), operator== */ * \sa isApprox(), operator== */
template <typename OtherDerived> template <typename OtherDerived>
EIGEN_DEVICE_FUNC inline bool operator!=(const MatrixBase<OtherDerived>& other) const { EIGEN_DEVICE_FUNC inline bool operator!=(const MatrixBase<OtherDerived>& other) const {
return cwiseNotEqual(other).any(); return !(*this == other);
} }
NoAlias<Derived, Eigen::MatrixBase> EIGEN_DEVICE_FUNC noalias(); NoAlias<Derived, Eigen::MatrixBase> EIGEN_DEVICE_FUNC noalias();