Re: [eigen] Convert 1x1 matrix to internal type?

[ Thread Index | Date Index | More Archives ]

On Thu, Sep 23, 2010 at 6:40 PM, Gael Guennebaud
<gael.guennebaud@xxxxxxxxx> wrote:
> unfortunately, allowing automatic conversion for any 1x1 matrix leads
> to many ambiguities (I don't remember exactly but there is a old
> thread where I listed them).

for the record:

ok I've a working version of that:

Matrix<float,1,1> mat;

mat = 1;
float x = mat + 1

 but there is a quite big downside:

mat * 2

does not compile anymore because there is an ambiguity which has to be
resolved by doing either:

mat * Scalar(2);
mat * 2.f;
Scalar(mat) * 2;

Maybe the worst thing is that such an ambiguity will show up for 1x1
objects only... so think about general template code which compile
fine for all objects except 1x1. Since the later ones are likely not
be well tested....

also not that :

double x = 2. * vec1.transpose() * vec2;

won't work, so enabling such a conversion only for inner product is
not 100% ideal....


Mail converted by MHonArc 2.6.19+