Re: [eigen] Unifying decomposition interfaces

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


2009/5/20 Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>:
> Hi there,
>
> I recognized that some of Eigen's decompositions offer a public method
>
>  void compute(MatrixType&)
>
> while others do not. IMHO, a public compute method is useful - it
> allows the user to reuse decomposition objects without the need to
> allocate the required intermediate members on and on. A particular use
> case in which I need this is for the Eigenvalue decomposition.
> Consider the case in which you want to compute the Eigenvalue
> decompositions of the Hessian (just a 2x2 matrix in this case) of each
> pixel in an image. Recreating the decomposition object in this case is
> unnecessary and actually costs a lot of time.

In such an extreme case as 2x2, eventually we want to have fixed-size
specializations for all decompositions.
But your point still holds for slightly larger sizes like 8x8.

>
> I tried to unify the decomposition interfaces (PartialLU, LU, QR, SVD,
> Cholesky, Eigensolver) in the following way:
>
> 1) if not already existing, add a public method 'void compute(MatrixType&)'
> 2) add a default ctor to all decompositions

I agree with this change

> The second step is required in order to spare the user from the need
> of creating decomposition objects with a dummy matrix in cases they
> actually intend to use them via compute(...).
>
> I created a fork with the required changes and would like to hear your
> opinions about them and the idea in general.
>
> The fork can be found here: http://bitbucket.org/hauke/eigen2/overview/

I just had a look at LU and have 2 remarks.
a) we'll have to decide how to guard against using an uninitialized
decomposition. I would like to advocate using ei_assert(). In
decompositions that store a pointer to the original matrix, this is a
great thing to test for. Otherwise add a bool m_initialized member.
b) you name the pointer m_pOriginalMatrix. So far we didn't do the
"p". I would advocate m_originalMatrix: the compiler takes care
already of checking that we're remembering that it's a pointer (so we
must use ->...)

Cheers,
Benoit



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