Re: [eigen] inconsistent cwise() support

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


2009/11/18 Schleimer, Ben <bensch128@xxxxxxxxx>:
> Hi,
>     I wanted to stop lurking and jump in with my two cents.

Hi!
it's been a long time!

> I think from a user's perspective it would be clearest if operations that
> are component wise are always marked with cwise() or array(). Example:
>
> MatrixdX matProd = A * B; // legal, indicates the matrix product of A and B
> MatrixdX compProd = A.cwise() * B.cwise(); // legal, indicates the
> component product of A and B
> MatrixdX invalidProd = A.cwise() * B; // illegal, this isn't a matrix
> product or pre-component product
> MatrixdX invalidProd = A * B.cwise(); // illegal, same as above

Yes, that's exactly where we are going, but with array() instead of cwise()..

> likewise, exp() would be the same:
> A.exp() -> matrix exponential
> A.cwise().exp() -> per-component exponential

Same here.

>
> I'd advocate for the sake of consistency that:
> MatrixdX sum = A.cwise() + B.cwise(); // legal

Same here.

> MatrixdX sum = A + B; // illegal

For addition there is no ambiguity at all, since matrix addition is
coefficient-wise addition. Also, for matrix addition, this matches the
natural mathematical notation. Thus, i don't see a reason to make that
illegal.

> Adding .cwise() (or .array()) to the end of the matrix name is not a huge
> burden and makes the subjects of the operation explicit.

Well, I think it's a big burden for such a common operation (the point
of tolerating such a .array() syntax elsewhere is that these are less
common operations on matrices), and I don't see how it is more
explicit since there was no ambiguity.

Benoit



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