| 167 | } |
| 168 | |
| 169 | template<typename MatrixType> void basicStuffComplex(const MatrixType& m) |
| 170 | { |
| 171 | typedef typename MatrixType::Scalar Scalar; |
| 172 | typedef typename NumTraits<Scalar>::Real RealScalar; |
| 173 | typedef Matrix<RealScalar, MatrixType::RowsAtCompileTime, MatrixType::ColsAtCompileTime> RealMatrixType; |
| 174 | |
| 175 | Index rows = m.rows(); |
| 176 | Index cols = m.cols(); |
| 177 | |
| 178 | Scalar s1 = internal::random<Scalar>(), |
| 179 | s2 = internal::random<Scalar>(); |
| 180 | |
| 181 | VERIFY(numext::real(s1)==numext::real_ref(s1)); |
| 182 | VERIFY(numext::imag(s1)==numext::imag_ref(s1)); |
| 183 | numext::real_ref(s1) = numext::real(s2); |
| 184 | numext::imag_ref(s1) = numext::imag(s2); |
| 185 | VERIFY(internal::isApprox(s1, s2, NumTraits<RealScalar>::epsilon())); |
| 186 | // extended precision in Intel FPUs means that s1 == s2 in the line above is not guaranteed. |
| 187 | |
| 188 | RealMatrixType rm1 = RealMatrixType::Random(rows,cols), |
| 189 | rm2 = RealMatrixType::Random(rows,cols); |
| 190 | MatrixType cm(rows,cols); |
| 191 | cm.real() = rm1; |
| 192 | cm.imag() = rm2; |
| 193 | VERIFY_IS_APPROX(static_cast<const MatrixType&>(cm).real(), rm1); |
| 194 | VERIFY_IS_APPROX(static_cast<const MatrixType&>(cm).imag(), rm2); |
| 195 | rm1.setZero(); |
| 196 | rm2.setZero(); |
| 197 | rm1 = cm.real(); |
| 198 | rm2 = cm.imag(); |
| 199 | VERIFY_IS_APPROX(static_cast<const MatrixType&>(cm).real(), rm1); |
| 200 | VERIFY_IS_APPROX(static_cast<const MatrixType&>(cm).imag(), rm2); |
| 201 | cm.real().setZero(); |
| 202 | VERIFY(static_cast<const MatrixType&>(cm).real().isZero()); |
| 203 | VERIFY(!static_cast<const MatrixType&>(cm).imag().isZero()); |
| 204 | } |
| 205 | |
| 206 | template<typename SrcScalar, typename TgtScalar> |
| 207 | struct casting_test { |