| 96 | |
| 97 | template<typename MatrixType> |
| 98 | void randomTest(const MatrixType& m, double tol) |
| 99 | { |
| 100 | /* this test covers the following files: |
| 101 | Inverse.h |
| 102 | */ |
| 103 | typename MatrixType::Index rows = m.rows(); |
| 104 | typename MatrixType::Index cols = m.cols(); |
| 105 | MatrixType m1(rows, cols), m2(rows, cols), identity = MatrixType::Identity(rows, cols); |
| 106 | |
| 107 | typedef typename NumTraits<typename internal::traits<MatrixType>::Scalar>::Real RealScalar; |
| 108 | |
| 109 | for(int i = 0; i < g_repeat; i++) { |
| 110 | m1 = MatrixType::Random(rows, cols); |
| 111 | |
| 112 | m2 = m1.matrixFunction(expfn) * (-m1).matrixFunction(expfn); |
| 113 | std::cout << "randomTest: error funm = " << relerr(identity, m2); |
| 114 | VERIFY(identity.isApprox(m2, static_cast<RealScalar>(tol))); |
| 115 | |
| 116 | m2 = m1.exp() * (-m1).exp(); |
| 117 | std::cout << " error expm = " << relerr(identity, m2) << "\n"; |
| 118 | VERIFY(identity.isApprox(m2, static_cast<RealScalar>(tol))); |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | void test_matrix_exponential() |
| 123 | { |
no test coverage detected