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