MCPcopy Create free account
hub / github.com/Derious/cuMPC / basicStuffComplex

Function basicStuffComplex

dependence/eigen-3.4.0/test/basicstuff.cpp:161–196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

159}
160
161template<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
198template<typename SrcScalar, typename TgtScalar>
199struct 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