11 #if defined(EIGEN_TEST_PART_7) 13 #ifndef EIGEN_NO_STATIC_ASSERT 14 #define EIGEN_NO_STATIC_ASSERT // turn static asserts into runtime asserts in order to check them 19 #if defined(__clang__) 20 # if (__clang_major__ * 100 + __clang_minor__) >= 308 21 # pragma clang diagnostic ignored "-Wdouble-promotion" 23 #elif defined(__GNUC__) 25 # pragma GCC diagnostic ignored "-Wdouble-promotion" 32 #if defined(EIGEN_TEST_PART_1) || defined(EIGEN_TEST_PART_2) || defined(EIGEN_TEST_PART_3) 34 #ifndef EIGEN_DONT_VECTORIZE 35 #define EIGEN_DONT_VECTORIZE 41 #define EIGEN_SCALAR_BINARY_OP_PLUGIN { g_called |= (!internal::is_same<LhsScalar,RhsScalar>::value); } 47 #define VERIFY_MIX_SCALAR(XPR,REF) \ 49 VERIFY_IS_APPROX(XPR,REF); \ 50 VERIFY( g_called && #XPR" not properly optimized"); 52 template<
int SizeAtCompileType>
68 #if 0 // we get other compilation errors here than just static asserts 76 typedef std::complex<float> CF;
77 typedef std::complex<double> CD;
84 typedef Matrix<std::complex<float>, SizeAtCompileType, 1> Vec_cf;
85 typedef Matrix<std::complex<double>, SizeAtCompileType, 1> Vec_cd;
88 Mat_d
md = mf.template cast<double>();
90 Mat_cf mcf = Mat_cf::Random(
size,
size);
91 Mat_cd mcd = mcf.template cast<complex<double> >();
93 Vec_f vf = Vec_f::Random(
size,1);
94 Vec_d vd = vf.template cast<double>();
95 Vec_cf vcf = Vec_cf::Random(
size,1);
96 Vec_cd vcd = vcf.template cast<complex<double> >();
97 float sf = internal::random<float>();
98 double sd = internal::random<double>();
107 while(
std::abs(sf )<epsf) sf = internal::random<float>();
108 while(
std::abs(sd )<epsd) sd = internal::random<double>();
109 while(
std::abs(scf)<epsf) scf = internal::random<CF>();
110 while(
std::abs(scd)<epsd) scd = internal::random<CD>();
154 VERIFY_IS_APPROX(vf.asDiagonal() * mcf, vf.template cast<complex<float> >().asDiagonal() * mcf);
155 VERIFY_IS_APPROX(vcd.asDiagonal() *
md, vcd.asDiagonal() * md.template cast<complex<double> >());
156 VERIFY_IS_APPROX(mcf * vf.asDiagonal(), mcf * vf.template cast<complex<float> >().asDiagonal());
157 VERIFY_IS_APPROX(md * vcd.asDiagonal(), md.template cast<complex<double> >() * vcd.asDiagonal());
170 VERIFY_IS_APPROX(mcd.array() *= md.array(), mcd2.array() *= md.array().template cast<std::complex<double> >());
183 VERIFY_IS_APPROX(sd*md.adjoint()*mcd, (sd*
md).
template cast<CD>().eval().adjoint()*mcd);
185 VERIFY_IS_APPROX(sd*md.adjoint()*mcd.adjoint(), (sd*
md).
template cast<CD>().eval().adjoint()*mcd.adjoint());
187 VERIFY_IS_APPROX(sd*md*mcd.adjoint(), (sd*
md).
template cast<CD>().eval()*mcd.adjoint());
190 VERIFY_IS_APPROX(sf*mf.adjoint()*mcf, (sf*
mf).
template cast<CF>().eval().adjoint()*mcf);
192 VERIFY_IS_APPROX(sf*mf.adjoint()*mcf.adjoint(), (sf*
mf).
template cast<CF>().eval().adjoint()*mcf.adjoint());
194 VERIFY_IS_APPROX(sf*mf*mcf.adjoint(), (sf*
mf).
template cast<CF>().eval()*mcf.adjoint());
217 VERIFY_IS_APPROX( sd*vcd.adjoint()*md.template triangularView<Upper>(), sd*vcd.adjoint()*md.template cast<CD>().
eval().template triangularView<Upper>());
219 VERIFY_IS_APPROX( sd*vcd.adjoint()*md.transpose().template triangularView<Upper>(), sd*vcd.adjoint()*md.transpose().template cast<CD>().
eval().template triangularView<Upper>());
222 VERIFY_IS_APPROX(scd*vd.adjoint()*mcd.template triangularView<Upper>(), scd*vd.adjoint().template cast<CD>().
eval()*mcd.template triangularView<Upper>());
224 VERIFY_IS_APPROX(scd*vd.adjoint()*mcd.transpose().template triangularView<Upper>(), scd*vd.adjoint().template cast<CD>().
eval()*mcd.transpose().template triangularView<Upper>());
245 VERIFY_IS_APPROX(Mat_cd(rcd.template triangularView<Upper>() = sd * mcd * md),
246 Mat_cd((sd * mcd * md.template cast<CD>().eval()).
template triangularView<Upper>()));
247 VERIFY_IS_APPROX(Mat_cd(rcd.template triangularView<Upper>() = sd * md * mcd),
248 Mat_cd((sd * md.template cast<CD>().eval() * mcd).
template triangularView<Upper>()));
249 VERIFY_IS_APPROX(Mat_cd(rcd.template triangularView<Upper>() = scd * mcd * md),
250 Mat_cd((scd * mcd * md.template cast<CD>().eval()).
template triangularView<Upper>()));
251 VERIFY_IS_APPROX(Mat_cd(rcd.template triangularView<Upper>() = scd * md * mcd),
252 Mat_cd((scd * md.template cast<CD>().eval() * mcd).
template triangularView<Upper>()));
255 VERIFY_IS_APPROX( md.array() * mcd.array(), md.template cast<CD>().
eval().array() * mcd.array() );
256 VERIFY_IS_APPROX( mcd.array() * md.array(), mcd.array() * md.template cast<CD>().
eval().array() );
258 VERIFY_IS_APPROX( md.array() + mcd.array(), md.template cast<CD>().
eval().array() + mcd.array() );
259 VERIFY_IS_APPROX( mcd.array() + md.array(), mcd.array() + md.template cast<CD>().
eval().array() );
261 VERIFY_IS_APPROX( md.array() - mcd.array(), md.template cast<CD>().
eval().array() - mcd.array() );
262 VERIFY_IS_APPROX( mcd.array() - md.array(), mcd.array() - md.template cast<CD>().
eval().array() );
264 if(mcd.array().abs().minCoeff()>epsd)
266 VERIFY_IS_APPROX( md.array() / mcd.array(), md.template cast<CD>().
eval().array() / mcd.array() );
268 if(md.array().abs().minCoeff()>epsd)
270 VERIFY_IS_APPROX( mcd.array() / md.array(), mcd.array() / md.template cast<CD>().
eval().array() );
273 if(md.array().abs().minCoeff()>epsd || mcd.array().abs().minCoeff()>epsd)
275 VERIFY_IS_APPROX( md.array().pow(mcd.array()), md.template cast<CD>().eval().array().pow(mcd.array()) );
276 VERIFY_IS_APPROX( mcd.array().pow(md.array()), mcd.array().pow(md.template cast<CD>().eval().array()) );
278 VERIFY_IS_APPROX(
pow(md.array(),mcd.array()), md.template cast<CD>().eval().array().pow(mcd.array()) );
279 VERIFY_IS_APPROX(
pow(mcd.array(),md.array()), mcd.array().pow(md.template cast<CD>().eval().array()) );
289 VERIFY_IS_APPROX( rcd.array() *= md.array(), mcd.array() * md.template cast<CD>().
eval().array() );
291 if(md.array().abs().minCoeff()>epsd)
293 VERIFY_IS_APPROX( rcd.array() /= md.array(), mcd.array() / md.template cast<CD>().
eval().array() );
297 VERIFY_IS_APPROX( rcd.noalias() += md + mcd*
md, mcd + (md.template cast<CD>().
eval()) + mcd*(md.template cast<CD>().eval()));
315 CALL_SUBTEST_1(mixingtypes<3>());
316 CALL_SUBTEST_2(mixingtypes<4>());
319 CALL_SUBTEST_4(mixingtypes<3>());
320 CALL_SUBTEST_5(mixingtypes<4>());
324 CALL_SUBTEST_7(raise_assertion<0>());
325 CALL_SUBTEST_7(raise_assertion<3>());
326 CALL_SUBTEST_7(raise_assertion<4>());
327 CALL_SUBTEST_7(raise_assertion<Dynamic>(0));
#define VERIFY_RAISES_ASSERT(a)
void adjoint(const MatrixType &m)
EIGEN_DEVICE_FUNC const SqrtReturnType sqrt() const
#define VERIFY_MIX_SCALAR(XPR, REF)
#define VERIFY_IS_APPROX(a, b)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
EIGEN_DEVICE_FUNC NewType cast(const OldType &x)
#define EIGEN_TEST_MAX_SIZE
A triangularView< Lower >().adjoint().solveInPlace(B)
internal::nested_eval< T, 1 >::type eval(const T &xpr)
Jet< T, N > pow(const Jet< T, N > &f, double g)
The matrix class, also used for vectors and row-vectors.
Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > & setRandom(Index size)
void raise_assertion(Index size=SizeAtCompileType)
void mixingtypes(int size=SizeAtCompileType)