Re: [eigen] Bug in traspose

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


On Friday 18 January 2008 01:48:52 Schleimer, Ben wrote:
> --- Benoît Jacob <jacob@xxxxxxxxxxxxxxx> wrote:
> > There is a problem with this:
> > > Matrix2d m;
> > > m <<= (1, 2),
> > >       (3, 4);
> >
> > Here the first operator, refers to the object 1 and the compiler will
> > treat it as an "int". Since we can't overload operator, on a POD type, I
> > see no way to make this work. Same problem with every solution you're
> > proposing with a parenthesis ( before the 1.
>
> I was thinking more about using va_args inside the operator()(...).
> Then , can be overloaded to go to the next row.

Oh I see. I have not much experience with va_args and wondered if that was 
considered a clean practice in c++ (and a quick google search suggests it 
is "not considered typesafe" and is "generally avoided in c++").

>
> I wonder how tvmet gets
> m = 1, 2,
>     3, 4;
>
> to work if the , operator is only overloaded in the Matrix<> class...

Because in tvmet, the Matrix<> class has an overloaded operator= taking a 
scalar and returning a CommaInitializer. So "m = 1" returns a 
CommaInitializer, and then ", 2" calls CommaInitializer::operator, .

My problem is that this is not compatible with the idea of allowing to 
construct a matrix by blocks i.e. taking matrices in the initialization list.
Indeed the matrix::operator=(matrix) already has the meaning of assignment...

Cheers,

Benoit

Attachment: signature.asc
Description: This is a digitally signed message part.



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/