| 68 | |
| 69 | template<typename MatrixType> |
| 70 | void testGeneral(const MatrixType& m, const typename MatrixType::RealScalar& tol) |
| 71 | { |
| 72 | typedef typename MatrixType::RealScalar RealScalar; |
| 73 | MatrixType m1, m2, m3, m4, m5; |
| 74 | RealScalar x, y; |
| 75 | |
| 76 | for (int i=0; i < g_repeat; ++i) { |
| 77 | generateTestMatrix<MatrixType>::run(m1, m.rows()); |
| 78 | MatrixPower<MatrixType> mpow(m1); |
| 79 | |
| 80 | x = internal::random<RealScalar>(); |
| 81 | y = internal::random<RealScalar>(); |
| 82 | m2 = mpow(x); |
| 83 | m3 = mpow(y); |
| 84 | |
| 85 | m4 = mpow(x+y); |
| 86 | m5.noalias() = m2 * m3; |
| 87 | VERIFY(m4.isApprox(m5, tol)); |
| 88 | |
| 89 | m4 = mpow(x*y); |
| 90 | m5 = m2.pow(y); |
| 91 | VERIFY(m4.isApprox(m5, tol)); |
| 92 | |
| 93 | m4 = (std::abs(x) * m1).pow(y); |
| 94 | m5 = std::pow(std::abs(x), y) * m3; |
| 95 | VERIFY(m4.isApprox(m5, tol)); |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | template<typename MatrixType> |
| 100 | void testSingular(const MatrixType& m_const, const typename MatrixType::RealScalar& tol) |