Re: [eigen] new tutorial on writing functions taking Eigen types as paramters

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


2010/8/5 Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>:
> On Thu, Aug 5, 2010 at 3:57 AM, Benoit Jacob <jacob.benoit.1@xxxxxxxxx> wrote:
>>> I have allowed myself to make directly some changes into your page,
>>> tell me if you'd have preferred discussing a patch first.
>>>
>>> Basically:
>>>  - i have rephased  the beginning to be more precise.
>
> I like your changes - now the page looks really nice.

Cool!

>
> One question, maybe that goes to Gael as well. I am stating at some
> point that the examples at the bottom (the cov function) can be used
> on Arrays too. This is not completely correct, because the matrix
> product has a different meaning (I could use .matrix()) but it does
> not even compile. Is this expected. I was thinking that for all those
> methods (operator*, rowwise().sum(), etc.) it should definitely be
> possible to use them on Matrix and Array.

There are 2 different things here:
 - the fact that operator* has a really different meaning on matrices
and on arrays, is of course wanted.
 - but the fact that .matrix() fails on a matrix is not wanted, IMO.
It's just that we forgot to add a trivial .matrix() there (of course
just returning reference to *this) and likewise, add trivial .array()
on array expressions.

Looking back at this page I see a few more places that have room for
improvement:
1) the first Array example,
    std::cout << "max: " << (a.max(b)).maxCoeff() << std::endl;
is a bit not-real-world. How about just taking 1 parameter 'a' and
doing a.abs().maxCoeff() ? This is definitely array-specific.

2) the phrase "simple functions" (used to mean "function taking a
plain Matrix argument") is not precise/explicit enough, and gives the
impression that Eigen is something complicated in which simple things
don't work! Why not e.g. "When does passing plain Matrix arguments
fail?"

3) the section "How to resize matrices in generic implementations?": two things:
  - since you want to write about this, why not just introduce the
base class DenseStorageBase? It is the base class for Matrix and Array
i.e. anything that is a plain object as opposed to an abstract
expression, hence can be resized. DenseStorageBase inherits either
MatrixBase or ArrayBase, depending on the XprKind of the Derived type.
  - The title itself,  "How to resize matrices in generic
implementations?" is not precise enough, why not e.g. "How to write
functions resizing generic arguments" ?

Cheers,
Benoit

>
> Regards,
> Hauke
>
>
>



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