aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Core/Fuzzy.h
diff options
context:
space:
mode:
authorGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2008-04-05 14:15:02 +0000
committerGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2008-04-05 14:15:02 +0000
commit61e58cf602849d4d71361fb7eaa25cb8b5a1196d (patch)
treeb688c607e0f92e31dc2b81d222e03ea569243f91 /Eigen/src/Core/Fuzzy.h
parentb4a156671fbe4e08c5f9cf7d939e2ee845e98283 (diff)
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.
Diffstat (limited to 'Eigen/src/Core/Fuzzy.h')
-rw-r--r--Eigen/src/Core/Fuzzy.h15
1 files changed, 10 insertions, 5 deletions
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<typename Derived>
template<typename OtherDerived>
bool MatrixBase<Derived>::isApprox(
- const OtherDerived& other,
+ const MatrixBase<OtherDerived>& other,
typename NumTraits<Scalar>::Real prec
) const
{
@@ -55,9 +55,11 @@ bool MatrixBase<Derived>::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<Derived>::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<Derived>::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;
}