Introduce a NumTraits<T>::Literal type to be used for literals, and

improve mixing type support in operations between arrays and scalars:
 - 2 * ArrayXcf is now optimized in the sense that the integer 2 is properly promoted to a float instead of a complex<float> (fix a regression)
 - 2.1 * ArrayXi is now forbiden (previously, 2.1 was converted to 2)
 - This mechanism should be applicable to any custom scalar type, assuming NumTraits<T>::Literal is properly defined (it defaults to T)
This commit is contained in:
Gael Guennebaud
2016-06-23 14:27:20 +02:00
parent 67c12531e5
commit 76faf4a965
5 changed files with 51 additions and 27 deletions

View File

@@ -79,6 +79,11 @@ template<int SizeAtCompileType> void mixingtypes(int size = SizeAtCompileType)
VERIFY_MIX_SCALAR(vf * scf , vf.template cast<complex<float> >() * scf);
VERIFY_MIX_SCALAR(scd * vd , scd * vd.template cast<complex<double> >());
VERIFY_MIX_SCALAR(vcf * 2 , vcf * complex<float>(2));
VERIFY_MIX_SCALAR(vcf * 2.1 , vcf * complex<float>(2.1));
VERIFY_MIX_SCALAR(2 * vcf, vcf * complex<float>(2));
VERIFY_MIX_SCALAR(2.1 * vcf , vcf * complex<float>(2.1));
// check scalar quotients
VERIFY_MIX_SCALAR(vcf / sf , vcf / complex<float>(sf));
VERIFY_MIX_SCALAR(vf / scf , vf.template cast<complex<float> >() / scf);