diff options
author | 2008-08-22 17:48:36 +0000 | |
---|---|---|
committer | 2008-08-22 17:48:36 +0000 | |
commit | f0394edfa7d063e37256e673cdecacd9f55f44ae (patch) | |
tree | a2e36374f3f51fc74f0d64c403f4368c8ae55d54 /test/main.h | |
parent | a95c1e190b6963543950f4b7831fcc0b844bd95f (diff) |
* bugfix in SolveTriangular found by Timothy Hunter (did not compiled for very small fixed size matrices)
* bugfix in Dot unroller
* added special random generator for the unit tests and reduced the tolerance threshold by an order of magnitude
this fixes issues with sum.cpp but other tests still failed sometimes, this have to be carefully checked...
Diffstat (limited to 'test/main.h')
-rw-r--r-- | test/main.h | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/test/main.h b/test/main.h index 19f453922..d4cdced60 100644 --- a/test/main.h +++ b/test/main.h @@ -164,8 +164,8 @@ namespace Eigen { template<typename T> inline typename NumTraits<T>::Real test_precision(); template<> inline int test_precision<int>() { return 0; } -template<> inline float test_precision<float>() { return 1e-3f; } -template<> inline double test_precision<double>() { return 1e-5; } +template<> inline float test_precision<float>() { return 1e-4f; } +template<> inline double test_precision<double>() { return 1e-6; } template<> inline float test_precision<std::complex<float> >() { return test_precision<float>(); } template<> inline double test_precision<std::complex<double> >() { return test_precision<double>(); } @@ -221,6 +221,26 @@ inline bool test_ei_isMuchSmallerThan(const MatrixBase<Derived>& m, return m.isMuchSmallerThan(s, test_precision<typename ei_traits<Derived>::Scalar>()); } +template<typename T> T test_random(); + +template<> int test_random() { return ei_random<int>(-100,100); } +template<> float test_random() { return float(ei_random<int>(-1000,1000)) / 256.f; } +template<> double test_random() { return double(ei_random<int>(-1000,1000)) / 256.; } +template<> std::complex<float> test_random() +{ return std::complex<float>(test_random<float>(),test_random<float>()); } +template<> std::complex<double> test_random() +{ return std::complex<double>(test_random<double>(),test_random<double>()); } + +template<typename MatrixType> +MatrixType test_random_matrix(int rows = MatrixType::RowsAtCompileTime, int cols = MatrixType::ColsAtCompileTime) +{ + MatrixType res(rows, cols); + for (int j=0; j<cols; ++j) + for (int i=0; i<rows; ++i) + res.coeffRef(i,j) = test_random<typename MatrixType::Scalar>(); + return res; +} + } // end namespace Eigen |