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;
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>();
192 VERIFY_IS_APPROX(sf*
mf.adjoint()*mcf.adjoint(), (sf*
mf).template cast<CF>().eval().adjoint()*mcf.adjoint());
193 VERIFY_IS_APPROX(sf*mcf.adjoint()*
mf.adjoint(), sf*mcf.adjoint()*
mf.template cast<CF>().adjoint());
204 VERIFY_IS_APPROX(sf*vf.adjoint()*mcf, sf*vf.adjoint().template cast<CF>().eval()*mcf);
205 VERIFY_IS_APPROX(scf*vf.adjoint()*mcf, scf*vf.adjoint().template cast<CF>().eval()*mcf);
215 VERIFY_IS_APPROX(scd*vd.adjoint()*mcd, scd*vd.adjoint().template cast<CD>().eval()*mcd);
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>());
246 Mat_cd((
sd * mcd *
md.template cast<CD>().eval()).template triangularView<Upper>()));
248 Mat_cd((
sd *
md.template cast<CD>().eval() * mcd).template triangularView<Upper>()));
250 Mat_cd((scd * mcd *
md.template cast<CD>().eval()).template triangularView<Upper>()));
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()) );
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()));