From 61e58cf602849d4d71361fb7eaa25cb8b5a1196d Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Sat, 5 Apr 2008 14:15:02 +0000 Subject: fixes as discussed with Gael on IRC. Mainly, in Fuzzy.h, and Dot.h, use ei_xpr_copy to evaluate args when needed. Had to introduce an ugly trick with ei_unref as when the XprCopy type is a reference one can't directly access member typedefs such as Scalar. --- Eigen/src/Core/Fuzzy.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'Eigen/src/Core/Fuzzy.h') diff --git a/Eigen/src/Core/Fuzzy.h b/Eigen/src/Core/Fuzzy.h index 4ebe9d2a7..5dd0265ba 100644 --- a/Eigen/src/Core/Fuzzy.h +++ b/Eigen/src/Core/Fuzzy.h @@ -44,7 +44,7 @@ template template bool MatrixBase::isApprox( - const OtherDerived& other, + const MatrixBase& other, typename NumTraits::Real prec ) const { @@ -55,9 +55,11 @@ bool MatrixBase::isApprox( } else { + typename Derived::XprCopy xprCopy(derived()); + typename OtherDerived::XprCopy otherXprCopy(other.derived()); for(int i = 0; i < cols(); i++) - if((col(i) - other.col(i)).norm2() - > std::min(col(i).norm2(), other.col(i).norm2()) * prec * prec) + if((xprCopy.col(i) - otherXprCopy.col(i)).norm2() + > std::min(xprCopy.col(i).norm2(), otherXprCopy.col(i).norm2()) * prec * prec) return false; return true; } @@ -85,8 +87,9 @@ bool MatrixBase::isMuchSmallerThan( } else { + typename Derived::XprCopy xprCopy(*this); for(int i = 0; i < cols(); i++) - if(col(i).norm2() > ei_abs2(other * prec)) + if(xprCopy.col(i).norm2() > ei_abs2(other * prec)) return false; return true; } @@ -116,8 +119,10 @@ bool MatrixBase::isMuchSmallerThan( } else { + typename Derived::XprCopy xprCopy(*this); + typename OtherDerived::XprCopy otherXprCopy(other); for(int i = 0; i < cols(); i++) - if(col(i).norm2() > other.col(i).norm2() * prec * prec) + if(xprCopy.col(i).norm2() > otherXprCopy.col(i).norm2() * prec * prec) return false; return true; } -- cgit v1.2.3