MCPcopy Create free account
hub / github.com/PX4/eigen / basicStuffComplex

Function basicStuffComplex

test/basicstuff.cpp:145–181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

143}
144
145template<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
184void casting()

Callers 1

test_basicstuffFunction · 0.85

Calls 11

real_refFunction · 0.85
imag_refFunction · 0.85
realMethod · 0.80
imagMethod · 0.80
isZeroMethod · 0.80
realFunction · 0.70
imagFunction · 0.70
isApproxFunction · 0.50
rowsMethod · 0.45
colsMethod · 0.45
setZeroMethod · 0.45

Tested by 1

test_basicstuffFunction · 0.68