diff options
author | Gael Guennebaud <g.gael@free.fr> | 2009-09-04 10:17:28 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2009-09-04 10:17:28 +0200 |
commit | 6902ef0824221391d159d153285f3d2142fdcd5b (patch) | |
tree | 1862be6dda74aea522c89804c6640108369e9c1b /test/mixingtypes.cpp | |
parent | a7ed998d523287e790142f4d3ff3d7f8e37e4d17 (diff) |
extend mixingtype test to check diagonal products and fix the later for real*complex products
Diffstat (limited to 'test/mixingtypes.cpp')
-rw-r--r-- | test/mixingtypes.cpp | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/test/mixingtypes.cpp b/test/mixingtypes.cpp index 690442a02..6280c3b6e 100644 --- a/test/mixingtypes.cpp +++ b/test/mixingtypes.cpp @@ -33,6 +33,7 @@ #include "main.h" +using namespace std; template<int SizeAtCompileType> void mixingtypes(int size = SizeAtCompileType) { @@ -45,14 +46,14 @@ template<int SizeAtCompileType> void mixingtypes(int size = SizeAtCompileType) typedef Matrix<std::complex<float>, SizeAtCompileType, 1> Vec_cf; typedef Matrix<std::complex<double>, SizeAtCompileType, 1> Vec_cd; - Mat_f mf(size,size); - Mat_d md(size,size); - Mat_cf mcf(size,size); - Mat_cd mcd(size,size); - Vec_f vf(size,1); - Vec_d vd(size,1); - Vec_cf vcf(size,1); - Vec_cd vcd(size,1); + Mat_f mf = Mat_f::Random(size,size); + Mat_d md = mf.template cast<double>(); + Mat_cf mcf = Mat_cf::Random(size,size); + Mat_cd mcd = mcf.template cast<complex<double> >(); + Vec_f vf = Vec_f::Random(size,1); + Vec_d vd = vf.template cast<double>(); + Vec_cf vcf = Vec_cf::Random(size,1); + Vec_cd vcd = vcf.template cast<complex<double> >(); mf+mf; VERIFY_RAISES_ASSERT(mf+md); @@ -64,7 +65,16 @@ template<int SizeAtCompileType> void mixingtypes(int size = SizeAtCompileType) vf.dot(vf); VERIFY_RAISES_ASSERT(vd.dot(vf)); VERIFY_RAISES_ASSERT(vcf.dot(vf)); // yeah eventually we should allow this but i'm too lazy to make that change now in Dot.h -} // especially as that might be rewritten as cwise product .sum() which would make that automatic. + // especially as that might be rewritten as cwise product .sum() which would make that automatic. + + VERIFY_IS_APPROX(vf.asDiagonal() * mcf, vf.template cast<complex<float> >().asDiagonal() * mcf); + VERIFY_IS_APPROX(vcd.asDiagonal() * md, vcd.asDiagonal() * md.template cast<complex<double> >()); + VERIFY_IS_APPROX(mcf * vf.asDiagonal(), mcf * vf.template cast<complex<float> >().asDiagonal()); + VERIFY_IS_APPROX(md * vcd.asDiagonal(), md.template cast<complex<double> >() * vcd.asDiagonal()); + +// vd.asDiagonal() * mf; // does not even compile +// vcd.asDiagonal() * mf; // does not even compile +} void mixingtypes_large(int size) |