| 143 | } |
| 144 | |
| 145 | template<typename MatrixType> void basicStuffComplex(const MatrixType& m) |
| 146 | { |
| 147 | typedef typename MatrixType::Index Index; |
| 148 | typedef typename MatrixType::Scalar Scalar; |
| 149 | typedef typename NumTraits<Scalar>::Real RealScalar; |
| 150 | typedef Matrix<RealScalar, MatrixType::RowsAtCompileTime, MatrixType::ColsAtCompileTime> RealMatrixType; |
| 151 | |
| 152 | Index rows = m.rows(); |
| 153 | Index cols = m.cols(); |
| 154 | |
| 155 | Scalar s1 = internal::random<Scalar>(), |
| 156 | s2 = internal::random<Scalar>(); |
| 157 | |
| 158 | VERIFY(numext::real(s1)==numext::real_ref(s1)); |
| 159 | VERIFY(numext::imag(s1)==numext::imag_ref(s1)); |
| 160 | numext::real_ref(s1) = numext::real(s2); |
| 161 | numext::imag_ref(s1) = numext::imag(s2); |
| 162 | VERIFY(internal::isApprox(s1, s2, NumTraits<RealScalar>::epsilon())); |
| 163 | // extended precision in Intel FPUs means that s1 == s2 in the line above is not guaranteed. |
| 164 | |
| 165 | RealMatrixType rm1 = RealMatrixType::Random(rows,cols), |
| 166 | rm2 = RealMatrixType::Random(rows,cols); |
| 167 | MatrixType cm(rows,cols); |
| 168 | cm.real() = rm1; |
| 169 | cm.imag() = rm2; |
| 170 | VERIFY_IS_APPROX(static_cast<const MatrixType&>(cm).real(), rm1); |
| 171 | VERIFY_IS_APPROX(static_cast<const MatrixType&>(cm).imag(), rm2); |
| 172 | rm1.setZero(); |
| 173 | rm2.setZero(); |
| 174 | rm1 = cm.real(); |
| 175 | rm2 = cm.imag(); |
| 176 | VERIFY_IS_APPROX(static_cast<const MatrixType&>(cm).real(), rm1); |
| 177 | VERIFY_IS_APPROX(static_cast<const MatrixType&>(cm).imag(), rm2); |
| 178 | cm.real().setZero(); |
| 179 | VERIFY(static_cast<const MatrixType&>(cm).real().isZero()); |
| 180 | VERIFY(!static_cast<const MatrixType&>(cm).imag().isZero()); |
| 181 | } |
| 182 | |
| 183 | #ifdef EIGEN_TEST_PART_2 |
| 184 | void casting() |