mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
implement the first _real_ unit-tests, testing the results for correctness instead
of just checking compilation. Fix the many issues discovered by these unit-tests, by the way fixing a performance bug.
This commit is contained in:
@@ -40,7 +40,8 @@ bool Object<Scalar, Derived>::isApprox(
|
||||
else
|
||||
{
|
||||
for(int i = 0; i < cols(); i++)
|
||||
if(!col(i).isApprox(other.col(i), prec))
|
||||
if((col(i) - other.col(i)).norm2()
|
||||
> std::min(col(i).norm2(), other.col(i).norm2()) * prec * prec)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
@@ -59,7 +60,7 @@ bool Object<Scalar, Derived>::isMuchSmallerThan(
|
||||
else
|
||||
{
|
||||
for(int i = 0; i < cols(); i++)
|
||||
if(!col(i).isMuchSmallerThan(other, prec))
|
||||
if(col(i).norm2() > NumTraits<Scalar>::abs2(other) * prec * prec)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
@@ -79,10 +80,10 @@ bool Object<Scalar, Derived>::isMuchSmallerThan(
|
||||
else
|
||||
{
|
||||
for(int i = 0; i < cols(); i++)
|
||||
if(!col(i).isMuchSmallerThan(other.col(i), prec))
|
||||
if(col(i).norm2() > other.col(i).norm2() * prec * prec)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // EI_FUZZY_H
|
||||
#endif // EI_FUZZY_H
|
||||
|
||||
Reference in New Issue
Block a user