| 135 | |
| 136 | template<typename MatrixType> |
| 137 | void testGonioFunctions(const MatrixType& A) |
| 138 | { |
| 139 | typedef typename MatrixType::Scalar Scalar; |
| 140 | typedef typename NumTraits<Scalar>::Real RealScalar; |
| 141 | typedef std::complex<RealScalar> ComplexScalar; |
| 142 | typedef Matrix<ComplexScalar, MatrixType::RowsAtCompileTime, |
| 143 | MatrixType::ColsAtCompileTime, MatrixType::Options> ComplexMatrix; |
| 144 | |
| 145 | ComplexScalar imagUnit(0,1); |
| 146 | ComplexScalar two(2,0); |
| 147 | |
| 148 | ComplexMatrix Ac = A.template cast<ComplexScalar>(); |
| 149 | |
| 150 | ComplexMatrix exp_iA = (imagUnit * Ac).exp(); |
| 151 | ComplexMatrix exp_miA = (-imagUnit * Ac).exp(); |
| 152 | |
| 153 | ComplexMatrix sinAc = A.sin().template cast<ComplexScalar>(); |
| 154 | VERIFY_IS_APPROX_ABS(sinAc, (exp_iA - exp_miA) / (two*imagUnit)); |
| 155 | |
| 156 | ComplexMatrix cosAc = A.cos().template cast<ComplexScalar>(); |
| 157 | VERIFY_IS_APPROX_ABS(cosAc, (exp_iA + exp_miA) / 2); |
| 158 | } |
| 159 | |
| 160 | template<typename MatrixType> |
| 161 | void testMatrix(const MatrixType& A) |
no test coverage detected