Re: [eigen] issue 77: map with stride

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


On Mon, Jan 18, 2010 at 6:25 AM, Benoit Jacob <jacob.benoit.1@xxxxxxxxx> wrote:
>> Finally, regarding the RowMajorBit flag, here is a proposal: What about add a ColMajorBit flag (i.e., RowMajorBir=1 and ColMAjorBit=2). For vectors we would ensure that Flags&(RowMajorBit|ColMajorBit)==0, and expressions having no preferred orders like some matrix products and binary ops between a colmajor and a rowmajor matrices could have both bit flag.
>
> This is a bit more elegant than our current design, yes.
>
> This can also lead to a slightly better logic determining storage
> orders, for example in:
>
>  RowMajorMatrix + ColMajorMatrix + ColMajorMatrix2
>
> the first + could say "i dont care about the storage order" so the 2nd
> + chooses column-major. But I don't see that happening a lot in
> practice.
>
> FYI, I spent time thinking if/how we should do such a change also to
> the Options parameter of Matrix. The answer is no:
>  - 0 must stay the default value in all cases including matrices, as
> this is a bit field touched by the user.
>  - so 0 would have to mean "column major, and nevermind if it's a vector"
>  - so a column-major matrix could have either 0 or ColMajor here.
>  - that's 2 separate types meaning exactly the same thing: a recipe to
> generate redundant template instantiations. Bad.
>
> So in all cases, the Options template parameter to Matrix stays as-is.
> So there would be a discrepancy between it and MatrixBase::Flags.
> Perhaps that negates the elegance benefit of the proposed change to
> MatrixBase::Flags?

Indeed, it would be quite unfortunate that ColMajor would be different
than ColMajorBit... On the other hand, I'm not sure that 0 really has
to mean ColMajor, and I think that the following exclusive set of
flags could work well:
- ColMajor = ColMajorBit
- RowMajor = RowMajorBit
- NoMajor = 0

Indeed, let's have a look at the three reasons a user has to play with
the Options parameter:
- the user wants a row major matrix => no change
- the user wants to add the DontAlign option => if that's a column
major matrix he must "or" it with ColMajor and he can keep DontAlign
alone for vectors.
- the user wants to set the default values of MaxRows and/or MaxCols
=> he must use ColMajor while currently he can also write a
meaningless "0". If the actual matrix type is a vector, then he can
either use Align, NoOrder, or... "0".

Here the points are that:
1 - such a change makes Matrix declarations more explicit,
2 - the two cases where the user would now have to bother about
explicitly setting ColMajor are extremely rare uses cases, so that's
no big deal.

Of course wrong values of Options would be cough at compile time.

Finally, I agree that:

"If the actual matrix type is a vector, then he can either use Align,
NoOrder, or... 0."

is still not perfect. Perhaps the "NoOrder" is not needed, or maybe
you have a better name to propose ?

gael



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