Re: [eigen] part<SelfAdjoint> in Eigen3

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


2010/7/29 ESCANDE Adrien 222264 <adrien.escande@xxxxxx>:
> Hello,
>
>
>
> Eigen2 documentation mentions the way to obtain an optimized computation for
> an expression evaluating to a selfadjoint matrix:
>
> n.part<SelfAdjoint>() = m+m.adjoint ;                 (1)
>
> n.part<SelfAdjoint>() = (m*m.adjoint()).lazy();      (2)
>
>
>
> I didn’t find the way to have that in Eigen3 (MatrixBase>Derived>::part is
> still there but flagged as deprecated). The Porting from Eigen2 to Eigen3
> page does not mention this case (it gives only the translation for
> part<SelfAdjoint|Upper> and part<SelfAdjoint|Lower>). Is there a new direct
> way to perform such computations?

The new method is selfadjointView().

n.selfadjointView<Lower>()
n.selfadjointView<Upper>()


>
> And what would be the best way to write (2) when m itself is selfadjoint?
>

Gael would know better, but I think that your best bet is rankUpdate() here..

n.setZero();
n.selfadjointView<Upper>().rankUpdate(m);

I can't see any way to do that using arithmetic operators, but that
seems OK as indeed the API for doing that should only take one operand
m.

What I am a bit more puzzled about is that this API forces the user to
pass Upper... I need an explanation as to why this is useful ?

Maybe it would be useful to add a productByAdjoint(), perhaps
abbreviated as .xxt(), method in MatrixBase so the user could do:

n = m.productByAdjoint();

?

Benoit

>
>
> Adrien
>
>
>
>



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