fix dot product, add norm/norm2/normalized

add fuzzy compares for matrices/vectors
add random matrix/vector generation
This commit is contained in:
Benoit Jacob
2007-10-10 06:09:56 +00:00
parent 7f0a546a81
commit 06e1e0d83b
9 changed files with 221 additions and 48 deletions

View File

@@ -47,7 +47,7 @@ class EigenTest : public QObject
void testMatrixManip();
};
template<typename T> inline typename EiTraits<T>::Real TestEpsilon();
template<typename T> inline typename EiNumTraits<T>::Real TestEpsilon();
template<> inline int TestEpsilon<int>() { return 0; }
template<> inline float TestEpsilon<float>() { return 1e-2f; }
template<> inline double TestEpsilon<double>() { return 1e-4; }
@@ -62,7 +62,7 @@ template<typename T> bool TestNegligible(const T& a, const T& b)
template<typename T> bool TestApprox(const T& a, const T& b)
{
if(EiTraits<T>::IsFloat)
if(EiNumTraits<T>::IsFloat)
return(EiAbs(a - b) <= std::min(EiAbs(a), EiAbs(b)) * TestEpsilon<T>());
else
return(a == b);
@@ -70,7 +70,7 @@ template<typename T> bool TestApprox(const T& a, const T& b)
template<typename T> bool TestLessThanOrApprox(const T& a, const T& b)
{
if(EiTraits<T>::IsFloat)
if(EiNumTraits<T>::IsFloat)
return(a < b || EiApprox(a, b));
else
return(a <= b);