MCPcopy Create free account
hub / github.com/avaxman/Directional / basicStuffComplex

Function basicStuffComplex

external/eigen/test/basicstuff.cpp:169–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

167}
168
169template<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
206template<typename SrcScalar, typename TgtScalar>
207struct casting_test {

Callers 1

EIGEN_DECLARE_TESTFunction · 0.85

Calls 11

real_refFunction · 0.85
imag_refFunction · 0.85
realMethod · 0.80
imagMethod · 0.80
isZeroMethod · 0.80
realClass · 0.70
imagClass · 0.70
isApproxFunction · 0.50
rowsMethod · 0.45
colsMethod · 0.45
setZeroMethod · 0.45

Tested by

no test coverage detected