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:
Benoit Jacob
2007-10-13 16:56:24 +00:00
parent 31061557a5
commit e445f5085a
16 changed files with 132 additions and 281 deletions

View File

@@ -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