diff options
-rw-r--r-- | Eigen/src/Core/arch/SSE/Complex.h | 9 | ||||
-rw-r--r-- | Eigen/src/Core/products/CoeffBasedProduct.h | 3 | ||||
-rw-r--r-- | Eigen/src/Core/products/GeneralMatrixVector.h | 23 | ||||
-rw-r--r-- | bench/bench_gemm.cpp | 103 | ||||
-rw-r--r-- | test/mixingtypes.cpp | 173 |
5 files changed, 147 insertions, 164 deletions
diff --git a/Eigen/src/Core/arch/SSE/Complex.h b/Eigen/src/Core/arch/SSE/Complex.h index 036b72d3e..585630563 100644 --- a/Eigen/src/Core/arch/SSE/Complex.h +++ b/Eigen/src/Core/arch/SSE/Complex.h @@ -109,12 +109,9 @@ template<> EIGEN_STRONG_INLINE Packet2cf ei_pset1<Packet2cf>(const std::complex< template<> EIGEN_STRONG_INLINE std::complex<float> ei_pfirst<Packet2cf>(const Packet2cf& a) { - union { - float res[2]; - double asDouble; - }; - _mm_store_sd(&asDouble,_mm_castps_pd(a.v)); - return *(std::complex<float>*)res; + std::complex<float> res; + _mm_storel_pi((__m64*)&res, a.v); + return res; } template<> EIGEN_STRONG_INLINE Packet2cf ei_preverse(const Packet2cf& a) { return Packet2cf(_mm_castpd_ps(ei_preverse(_mm_castps_pd(a.v)))); } diff --git a/Eigen/src/Core/products/CoeffBasedProduct.h b/Eigen/src/Core/products/CoeffBasedProduct.h index 66976d8e2..c79a34de0 100644 --- a/Eigen/src/Core/products/CoeffBasedProduct.h +++ b/Eigen/src/Core/products/CoeffBasedProduct.h @@ -108,7 +108,8 @@ struct ei_traits<CoeffBasedProduct<LhsNested,RhsNested,NestingFlags> > * loop of the product might be vectorized. This is the meaning of CanVectorizeInner. Since it doesn't affect * the Flags, it is safe to make this value depend on ActualPacketAccessBit, that doesn't affect the ABI. */ - CanVectorizeInner = LhsRowMajor + CanVectorizeInner = SameType + && LhsRowMajor && (!RhsRowMajor) && (LhsFlags & RhsFlags & ActualPacketAccessBit) && (LhsFlags & RhsFlags & AlignedBit) diff --git a/Eigen/src/Core/products/GeneralMatrixVector.h b/Eigen/src/Core/products/GeneralMatrixVector.h index 4d2f82680..a5062bedb 100644 --- a/Eigen/src/Core/products/GeneralMatrixVector.h +++ b/Eigen/src/Core/products/GeneralMatrixVector.h @@ -91,7 +91,7 @@ EIGEN_DONT_INLINE static void run( const Index ResPacketAlignedMask = ResPacketSize-1; const Index PeelAlignedMask = ResPacketSize*peels-1; const Index size = rows; - + // How many coeffs of the result do we have to skip to be aligned. // Here we assume data are at least aligned on the base scalar type. Index alignedStart = ei_first_aligned(res,size); @@ -244,30 +244,29 @@ EIGEN_DONT_INLINE static void run( Index start = columnBound; do { - for (Index i=start; i<end; ++i) + for (Index k=start; k<end; ++k) { - RhsPacket ptmp0 = ei_pset1<RhsPacket>(alpha*rhs[i*rhsIncr]); - const LhsScalar* lhs0 = lhs + i*lhsStride; + RhsPacket ptmp0 = ei_pset1<RhsPacket>(alpha*rhs[k*rhsIncr]); + const LhsScalar* lhs0 = lhs + k*lhsStride; if (Vectorizable) { /* explicit vectorization */ // process first unaligned result's coeffs for (Index j=0; j<alignedStart; ++j) - res[j] += cj.pmul(lhs0[j], ei_pfirst(ptmp0)); - + res[j] += cj.pmul(lhs0[j], rhs[k*rhsIncr]/*ei_pfirst(ptmp0)*/); // process aligned result's coeffs if ((size_t(lhs0+alignedStart)%sizeof(LhsPacket))==0) - for (Index j = alignedStart;j<alignedSize;j+=ResPacketSize) - ei_pstore(&res[j], pcj.pmadd(ei_pload<LhsPacket>(&lhs0[j]), ptmp0, ei_pload<ResPacket>(&res[j]))); + for (Index i = alignedStart;i<alignedSize;i+=ResPacketSize) + ei_pstore(&res[i], pcj.pmadd(ei_ploadu<LhsPacket>(&lhs0[i]), ptmp0, ei_pload<ResPacket>(&res[i]))); else - for (Index j = alignedStart;j<alignedSize;j+=ResPacketSize) - ei_pstore(&res[j], pcj.pmadd(ei_ploadu<LhsPacket>(&lhs0[j]), ptmp0, ei_pload<ResPacket>(&res[j]))); + for (Index i = alignedStart;i<alignedSize;i+=ResPacketSize) + ei_pstore(&res[i], pcj.pmadd(ei_ploadu<LhsPacket>(&lhs0[i]), ptmp0, ei_pload<ResPacket>(&res[i]))); } // process remaining scalars (or all if no explicit vectorization) - for (Index j=alignedSize; j<size; ++j) - res[j] += cj.pmul(lhs0[j], ei_pfirst(ptmp0)); + for (Index i=alignedSize; i<size; ++i) + res[i] += cj.pmul(lhs0[i], ei_pfirst(ptmp0)); } if (skipColumns) { diff --git a/bench/bench_gemm.cpp b/bench/bench_gemm.cpp index 5e2cf087c..922c3cd64 100644 --- a/bench/bench_gemm.cpp +++ b/bench/bench_gemm.cpp @@ -10,15 +10,16 @@ using namespace std; using namespace Eigen; #ifndef SCALAR -#define SCALAR std::complex<double> -// #define SCALAR double +#define SCALAR std::complex<float> +// #define SCALAR float #endif typedef SCALAR Scalar; typedef NumTraits<Scalar>::Real RealScalar; typedef Matrix<RealScalar,Dynamic,Dynamic> A; -typedef Matrix<Scalar,Dynamic,Dynamic> B; +typedef Matrix</*Real*/Scalar,Dynamic,Dynamic> B; typedef Matrix<Scalar,Dynamic,Dynamic> C; +typedef Matrix<RealScalar,Dynamic,Dynamic> M; #ifdef HAVE_BLAS @@ -35,7 +36,7 @@ static std::complex<float> cfzero = 0; static std::complex<double> cdone = 1; static std::complex<double> cdzero = 0; static char notrans = 'N'; -static char trans = 'T'; +static char trans = 'T'; static char nonunit = 'N'; static char lower = 'L'; static char right = 'R'; @@ -87,10 +88,30 @@ void blas_gemm(const MatrixXd& a, const MatrixXd& b, MatrixXd& c) #endif +void matlab_cplx_cplx(const M& ar, const M& ai, const M& br, const M& bi, M& cr, M& ci) +{ + cr.noalias() += ar * br; + cr.noalias() -= ai * bi; + ci.noalias() += ar * bi; + ci.noalias() += ai * br; +} + +void matlab_real_cplx(const M& a, const M& br, const M& bi, M& cr, M& ci) +{ + cr.noalias() += a * br; + ci.noalias() += a * bi; +} + +void matlab_cplx_real(const M& ar, const M& ai, const M& b, M& cr, M& ci) +{ + cr.noalias() += ar * b; + ci.noalias() += ai * b; +} + template<typename A, typename B, typename C> EIGEN_DONT_INLINE void gemm(const A& a, const B& b, C& c) { - c.noalias() += a * b; + c.noalias() += a * b; } int main(int argc, char ** argv) @@ -99,8 +120,8 @@ int main(int argc, char ** argv) std::ptrdiff_t l2 = ei_queryTopLevelCacheSize(); std::cout << "L1 cache size = " << (l1>0 ? l1/1024 : -1) << " KB\n"; std::cout << "L2/L3 cache size = " << (l2>0 ? l2/1024 : -1) << " KB\n"; - typedef ei_product_blocking_traits<Scalar,Scalar> Blocking; - std::cout << "Register blocking = " << Blocking::mr << " x " << Blocking::nr << "\n"; + typedef ei_gebp_traits<Scalar,Scalar> Traits; + std::cout << "Register blocking = " << Traits::mr << " x " << Traits::nr << "\n"; int rep = 1; // number of repetitions per try int tries = 2; // number of tries, we keep the best @@ -135,19 +156,19 @@ int main(int argc, char ** argv) int m = s; int n = s; int p = s; - A a(m,n); a.setRandom(); - B b(n,p); b.setRandom(); - C c(m,p); c.setOnes(); + A a(m,p); a.setRandom(); + B b(p,n); b.setRandom(); + C c(m,n); c.setOnes(); std::cout << "Matrix sizes = " << m << "x" << p << " * " << p << "x" << n << "\n"; - std::ptrdiff_t cm(m), cn(n), ck(p); - computeProductBlockingSizes<Scalar,Scalar>(ck, cm, cn); - std::cout << "blocking size = " << cm << " x " << ck << "\n"; + std::ptrdiff_t mc(m), nc(n), kc(p); + computeProductBlockingSizes<Scalar,Scalar>(kc, mc, nc); + std::cout << "blocking size (mc x kc) = " << mc << " x " << kc << "\n"; C r = c; // check the parallel product is correct - #ifdef EIGEN_HAS_OPENMP + #if defined EIGEN_HAS_OPENMP int procs = omp_get_max_threads(); if(procs>1) { @@ -161,6 +182,17 @@ int main(int argc, char ** argv) c.noalias() += a * b; if(!r.isApprox(c)) std::cerr << "Warning, your parallel product is crap!\n\n"; } + #elif defined HAVE_BLAS + blas_gemm(a,b,r); + c.noalias() += a * b; + if(!r.isApprox(c)) std::cerr << "Warning, your product is crap!\n\n"; +// std::cerr << r << "\n\n" << c << "\n\n"; + #else + gemm(a,b,c); + r.noalias() += a.cast<Scalar>() * b.cast<Scalar>(); + if(!r.isApprox(c)) std::cerr << "Warning, your product is crap!\n\n"; +// std::cerr << c << "\n\n"; +// std::cerr << r << "\n\n"; #endif #ifdef HAVE_BLAS @@ -187,6 +219,49 @@ int main(int argc, char ** argv) std::cout << "mt speed up x" << tmono.best(CPU_TIMER) / tmt.best(REAL_TIMER) << " => " << (100.0*tmono.best(CPU_TIMER) / tmt.best(REAL_TIMER))/procs << "%\n"; } #endif + + #ifdef DECOUPLED + if((NumTraits<A::Scalar>::IsComplex) && (NumTraits<B::Scalar>::IsComplex)) + { + M ar(m,p); ar.setRandom(); + M ai(m,p); ai.setRandom(); + M br(p,n); br.setRandom(); + M bi(p,n); bi.setRandom(); + M cr(m,n); cr.setRandom(); + M ci(m,n); ci.setRandom(); + + BenchTimer t; + BENCH(t, tries, rep, matlab_cplx_cplx(ar,ai,br,bi,cr,ci)); + std::cout << "\"matlab\" cpu " << t.best(CPU_TIMER)/rep << "s \t" << (double(m)*n*p*rep*2/t.best(CPU_TIMER))*1e-9 << " GFLOPS \t(" << t.total(CPU_TIMER) << "s)\n"; + std::cout << "\"matlab\" real " << t.best(REAL_TIMER)/rep << "s \t" << (double(m)*n*p*rep*2/t.best(REAL_TIMER))*1e-9 << " GFLOPS \t(" << t.total(REAL_TIMER) << "s)\n"; + } + if((!NumTraits<A::Scalar>::IsComplex) && (NumTraits<B::Scalar>::IsComplex)) + { + M a(m,p); a.setRandom(); + M br(p,n); br.setRandom(); + M bi(p,n); bi.setRandom(); + M cr(m,n); cr.setRandom(); + M ci(m,n); ci.setRandom(); + + BenchTimer t; + BENCH(t, tries, rep, matlab_real_cplx(a,br,bi,cr,ci)); + std::cout << "\"matlab\" cpu " << t.best(CPU_TIMER)/rep << "s \t" << (double(m)*n*p*rep*2/t.best(CPU_TIMER))*1e-9 << " GFLOPS \t(" << t.total(CPU_TIMER) << "s)\n"; + std::cout << "\"matlab\" real " << t.best(REAL_TIMER)/rep << "s \t" << (double(m)*n*p*rep*2/t.best(REAL_TIMER))*1e-9 << " GFLOPS \t(" << t.total(REAL_TIMER) << "s)\n"; + } + if((NumTraits<A::Scalar>::IsComplex) && (!NumTraits<B::Scalar>::IsComplex)) + { + M ar(m,p); ar.setRandom(); + M ai(m,p); ai.setRandom(); + M b(p,n); b.setRandom(); + M cr(m,n); cr.setRandom(); + M ci(m,n); ci.setRandom(); + + BenchTimer t; + BENCH(t, tries, rep, matlab_cplx_real(ar,ai,b,cr,ci)); + std::cout << "\"matlab\" cpu " << t.best(CPU_TIMER)/rep << "s \t" << (double(m)*n*p*rep*2/t.best(CPU_TIMER))*1e-9 << " GFLOPS \t(" << t.total(CPU_TIMER) << "s)\n"; + std::cout << "\"matlab\" real " << t.best(REAL_TIMER)/rep << "s \t" << (double(m)*n*p*rep*2/t.best(REAL_TIMER))*1e-9 << " GFLOPS \t(" << t.total(REAL_TIMER) << "s)\n"; + } + #endif return 0; } diff --git a/test/mixingtypes.cpp b/test/mixingtypes.cpp index cc6c4481a..7673348b4 100644 --- a/test/mixingtypes.cpp +++ b/test/mixingtypes.cpp @@ -40,6 +40,8 @@ using namespace std; template<int SizeAtCompileType> void mixingtypes(int size = SizeAtCompileType) { + typedef std::complex<float> CF; + typedef std::complex<double> CD; typedef Matrix<float, SizeAtCompileType, SizeAtCompileType> Mat_f; typedef Matrix<double, SizeAtCompileType, SizeAtCompileType> Mat_d; typedef Matrix<std::complex<float>, SizeAtCompileType, SizeAtCompileType> Mat_cf; @@ -49,14 +51,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 = 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> >(); + 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> >(); float sf = ei_random<float>(); double sd = ei_random<double>(); complex<float> scf = ei_random<complex<float> >(); @@ -104,134 +106,43 @@ template<int SizeAtCompileType> void mixingtypes(int size = SizeAtCompileType) Mat_cd mcd2 = mcd; VERIFY_IS_APPROX(mcd.array() *= md.array(), mcd2.array() *= md.array().template cast<std::complex<double> >()); -} - - -void mixingtypes_large(int size) -{ - typedef std::complex<float> CF; - typedef std::complex<double> CD; - static const int SizeAtCompileType = Dynamic; - typedef Matrix<float, SizeAtCompileType, SizeAtCompileType> Mat_f; - typedef Matrix<double, SizeAtCompileType, SizeAtCompileType> Mat_d; - typedef Matrix<std::complex<float>, SizeAtCompileType, SizeAtCompileType> Mat_cf; - typedef Matrix<std::complex<double>, SizeAtCompileType, SizeAtCompileType> Mat_cd; - typedef Matrix<float, SizeAtCompileType, 1> Vec_f; - typedef Matrix<double, SizeAtCompileType, 1> Vec_d; - typedef Matrix<std::complex<float>, SizeAtCompileType, 1> Vec_cf; - typedef Matrix<std::complex<double>, SizeAtCompileType, 1> Vec_cd; - - Mat_f mf(size,size); mf.setRandom(); - Mat_d md(size,size); md.setRandom(); - Mat_cf mcf(size,size); mcf.setRandom(); - Mat_cd mcd(size,size); mcd.setRandom(); - Vec_f vf(size,1); vf.setRandom(); - Vec_d vd(size,1); vd.setRandom(); - Vec_cf vcf(size,1); vcf.setRandom(); - Vec_cd vcd(size,1); vcd.setRandom(); - - float sf = ei_random<float>(); - double sd = ei_random<double>(); - CF scf = ei_random<CF>(); - CD scd = ei_random<CD>(); - -// mf*mf; - // FIXME large products does not allow mixing types - VERIFY_IS_APPROX(sd*md*mcd, (sd*md).cast<CD>().eval()*mcd); - VERIFY_IS_APPROX(sd*mcd*md, sd*mcd*md.cast<CD>()); - VERIFY_IS_APPROX(scd*md*mcd, scd*md.cast<CD>().eval()*mcd); - VERIFY_IS_APPROX(scd*mcd*md, scd*mcd*md.cast<CD>()); -// std::cerr << (mf*mf).cast<CF>() << "\n\n" << mf.cast<CF>().eval()*mf.cast<CF>().eval() << "\n\n"; -// VERIFY_IS_APPROX((mf*mf).cast<CF>(), mf.cast<CF>().eval()*mf.cast<CF>().eval()); - VERIFY_IS_APPROX(sf*mf*mcf, sf*mf.cast<CF>()*mcf); - VERIFY_IS_APPROX(sf*mcf*mf, sf*mcf*mf.cast<CF>()); - VERIFY_IS_APPROX(scf*mf*mcf, scf*mf.cast<CF>()*mcf); - VERIFY_IS_APPROX(scf*mcf*mf, scf*mcf*mf.cast<CF>()); - - VERIFY_IS_APPROX(sf*mf*vcf, (sf*mf).cast<CF>().eval()*vcf); - VERIFY_IS_APPROX(scf*mf*vcf,(scf*mf.cast<CF>()).eval()*vcf); - VERIFY_IS_APPROX(sf*mcf*vf, sf*mcf*vf.cast<CF>()); - VERIFY_IS_APPROX(scf*mcf*vf,scf*mcf*vf.cast<CF>()); - - VERIFY_IS_APPROX(sf*vcf.adjoint()*mf, sf*vcf.adjoint()*mf.cast<CF>().eval()); - VERIFY_IS_APPROX(scf*vcf.adjoint()*mf, scf*vcf.adjoint()*mf.cast<CF>().eval()); - VERIFY_IS_APPROX(sf*vf.adjoint()*mcf, sf*vf.adjoint().cast<CF>().eval()*mcf); - VERIFY_IS_APPROX(scf*vf.adjoint()*mcf, scf*vf.adjoint().cast<CF>().eval()*mcf); - - VERIFY_IS_APPROX(sd*md*vcd, (sd*md).cast<CD>().eval()*vcd); - VERIFY_IS_APPROX(scd*md*vcd,(scd*md.cast<CD>()).eval()*vcd); - VERIFY_IS_APPROX(sd*mcd*vd, sd*mcd*vd.cast<CD>().eval()); - VERIFY_IS_APPROX(scd*mcd*vd,scd*mcd*vd.cast<CD>().eval()); - - VERIFY_IS_APPROX(sd*vcd.adjoint()*md, sd*vcd.adjoint()*md.cast<CD>().eval()); - VERIFY_IS_APPROX(scd*vcd.adjoint()*md, scd*vcd.adjoint()*md.cast<CD>().eval()); - VERIFY_IS_APPROX(sd*vd.adjoint()*mcd, sd*vd.adjoint().cast<CD>().eval()*mcd); - VERIFY_IS_APPROX(scd*vd.adjoint()*mcd, scd*vd.adjoint().cast<CD>().eval()*mcd); - - -// VERIFY_IS_APPROX(vcf.adjoint() * mf, vcf.adjoint() * mf.cast<CF>()); -// VERIFY_IS_APPROX(vf.adjoint() * mcf, vf.adjoint().cast<CF>() * mcf); -// VERIFY_IS_APPROX(md*vcd, md.cast<CD>()*vcd); -// VERIFY_IS_APPROX(mcd*vd, mcd*vd.cast<CD>()); -// VERIFY_IS_APPROX(vcd.adjoint() * md, vcd.adjoint() * md.cast<CD>()); -// VERIFY_IS_APPROX(vd.adjoint() * mcd, vd.adjoint().cast<CD>() * mcd); -// VERIFY_RAISES_ASSERT(mcf *= mf); // does not even compile -// VERIFY_RAISES_ASSERT(vcd = md*vcd); // does not even compile (cannot convert complex to double) -// VERIFY_RAISES_ASSERT(vcf = mcf*vf); - -// VERIFY_RAISES_ASSERT(mf*md); // does not even compile -// VERIFY_RAISES_ASSERT(mcf*mcd); // does not even compile -// VERIFY_RAISES_ASSERT(mcf*vcd); // does not even compile -// VERIFY_RAISES_ASSERT(vcf = mf*vf); -} - -template<int SizeAtCompileType> void mixingtypes_small() -{ - int size = SizeAtCompileType; - typedef Matrix<float, SizeAtCompileType, SizeAtCompileType> Mat_f; - typedef Matrix<double, SizeAtCompileType, SizeAtCompileType> Mat_d; - typedef Matrix<std::complex<float>, SizeAtCompileType, SizeAtCompileType> Mat_cf; - typedef Matrix<std::complex<double>, SizeAtCompileType, SizeAtCompileType> Mat_cd; - typedef Matrix<float, SizeAtCompileType, 1> Vec_f; - typedef Matrix<double, SizeAtCompileType, 1> Vec_d; - 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); - - - mf*mf; - // FIXME shall we discard those products ? - // 1) currently they work only if SizeAtCompileType is small enough - // 2) in case we vectorize complexes this might be difficult to still allow that - md*mcd; - mcd*md; - mf*vcf; - mcf*vf; - mcf *= mf; - vcd = md*vcd; - vcf = mcf*vf; -// VERIFY_RAISES_ASSERT(mf*md); // does not even compile -// VERIFY_RAISES_ASSERT(mcf*mcd); // does not even compile -// VERIFY_RAISES_ASSERT(mcf*vcd); // does not even compile - VERIFY_RAISES_ASSERT(vcf = mf*vf); + // check matrix-matrix products + + VERIFY_IS_APPROX(sd*md*mcd, (sd*md).template cast<CD>().eval()*mcd); + VERIFY_IS_APPROX(sd*mcd*md, sd*mcd*md.template cast<CD>()); + VERIFY_IS_APPROX(scd*md*mcd, scd*md.template cast<CD>().eval()*mcd); + VERIFY_IS_APPROX(scd*mcd*md, scd*mcd*md.template cast<CD>()); + + VERIFY_IS_APPROX(sf*mf*mcf, sf*mf.template cast<CF>()*mcf); + VERIFY_IS_APPROX(sf*mcf*mf, sf*mcf*mf.template cast<CF>()); + VERIFY_IS_APPROX(scf*mf*mcf, scf*mf.template cast<CF>()*mcf); + VERIFY_IS_APPROX(scf*mcf*mf, scf*mcf*mf.template cast<CF>()); + + VERIFY_IS_APPROX(sf*mf*vcf, (sf*mf).template cast<CF>().eval()*vcf); + VERIFY_IS_APPROX(scf*mf*vcf,(scf*mf.template cast<CF>()).eval()*vcf); + VERIFY_IS_APPROX(sf*mcf*vf, sf*mcf*vf.template cast<CF>()); + VERIFY_IS_APPROX(scf*mcf*vf,scf*mcf*vf.template cast<CF>()); + + VERIFY_IS_APPROX(sf*vcf.adjoint()*mf, sf*vcf.adjoint()*mf.template cast<CF>().eval()); + VERIFY_IS_APPROX(scf*vcf.adjoint()*mf, scf*vcf.adjoint()*mf.template cast<CF>().eval()); + VERIFY_IS_APPROX(sf*vf.adjoint()*mcf, sf*vf.adjoint().template cast<CF>().eval()*mcf); + VERIFY_IS_APPROX(scf*vf.adjoint()*mcf, scf*vf.adjoint().template cast<CF>().eval()*mcf); + + VERIFY_IS_APPROX(sd*md*vcd, (sd*md).template cast<CD>().eval()*vcd); + VERIFY_IS_APPROX(scd*md*vcd,(scd*md.template cast<CD>()).eval()*vcd); + VERIFY_IS_APPROX(sd*mcd*vd, sd*mcd*vd.template cast<CD>().eval()); + VERIFY_IS_APPROX(scd*mcd*vd,scd*mcd*vd.template cast<CD>().eval()); + + VERIFY_IS_APPROX(sd*vcd.adjoint()*md, sd*vcd.adjoint()*md.template cast<CD>().eval()); + VERIFY_IS_APPROX(scd*vcd.adjoint()*md, scd*vcd.adjoint()*md.template cast<CD>().eval()); + VERIFY_IS_APPROX(sd*vd.adjoint()*mcd, sd*vd.adjoint().template cast<CD>().eval()*mcd); + VERIFY_IS_APPROX(scd*vd.adjoint()*mcd, scd*vd.adjoint().template cast<CD>().eval()*mcd); } void test_mixingtypes() { - // check that our operator new is indeed called: CALL_SUBTEST_1(mixingtypes<3>()); CALL_SUBTEST_2(mixingtypes<4>()); - CALL_SUBTEST_3(mixingtypes<Dynamic>(20)); - - CALL_SUBTEST_4(mixingtypes_small<4>()); - CALL_SUBTEST_5(mixingtypes_large(11)); + CALL_SUBTEST_3(mixingtypes<Dynamic>(ei_random<int>(1,310))); } |