RE: [eigen] How about pseudo-inverse?

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


Ok I now understand what the select() function does. I compared with the Matlab code and it seems identical.  

-----Message d'origine-----
De : Listengine [mailto:listengine@xxxxxxxxxxxxxxxxx] De la part de Ricard Marxer Piñón
Envoyé : 21 janvier 2010 11:59
À : eigen@xxxxxxxxxxxxxxxxxxx
Objet : Re: [eigen] How about pseudo-inverse?

In this snippet the "select()" method will set to 0 those singular
values that are under the tolerance.  I really don't know how they do
it in Matlab.  The comment is because in the Wikipedia they say, that
Matlab puts a threshold on the singular value, but I must confess I
don't know what they do with those singular values that fall under
that threshold.

But I warn you, I'm no expert, so better check against other sources
or test with sample data.  I would appreciate if you see any errors to
let me know so that I could fix it in my code as well.

cheers,
ricard

On Thu, Jan 21, 2010 at 4:57 PM,  <hamelin.philippe@xxxxxxx> wrote:
> Hi,
> You selected only the singular values over the tolerance. However, you don't select the corresponding values on V and U? I just compared to the Matlab code so maybe I'm just confused.
>
> Philippe
>
> -----Message d'origine-----
> De : Listengine [mailto:listengine@xxxxxxxxxxxxxxxxx] De la part de Ricard Marxer Piñón
> Envoyé : 21 janvier 2010 10:16
> À : eigen@xxxxxxxxxxxxxxxxxxx
> Objet : Re: [eigen] How about pseudo-inverse?
>
> Hi,
>
> I implemented my own version like this.  But I don't know if it is
> really correct, so please correct me if I'm wrong:
>
> #include <Eigen/Core>
> #include <Eigen/Array>
> #include <Eigen/SVD>
>
> typedef Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic > MatrixXR;
>
> // SVD method
> void pseudoInverse(const MatrixXR& a, MatrixXR* result, Real epsilon) {
>  Eigen::SVD<MatrixXR> svd = a.svd();
>
>  // As done in Matlab:
>  // http://en.wikipedia.org/wiki/Moore-Penrose_pseudoinverse
>  Real tolerance = epsilon * max(a.cols(), a.rows()) *
> svd.singularValues().cwise().abs().maxCoeff();
>
>  (*result) = svd.matrixV() * (svd.singularValues().cwise() >
> tolerance).select(svd.singularValues().cwise().inverse(),
> 0).asDiagonal() * svd.matrixU().adjoint();
> }
>
> ricard
>
> On Thu, Jan 21, 2010 at 3:55 PM,  <hamelin.philippe@xxxxxxx> wrote:
>> Hello,
>> I'm just new to the mailing list (and to Eigen2). I'm currently programming
>> an underwater vehicle simulator using Eigen2. I actually need the
>> pseudo-inverse of a rectangular matrix. I didn't find anything about that in
>> the code. There's seems to be a preliminary version of the SVD which could
>> help to do pseudo-inverse. So, does anyone has something to suggest to me
>> about that?
>>
>> Thank you,
>>
>> Philippe Hamelin, ing. jr, M. Ing
>> Chercheur / Researcher
>>
>> Tel: (450) 652-8499 x2198
>> Fax: (450) 652-1316
>>
>> Institut de recherche d'Hydro-Québec
>> Unité robotique et civil
>> 1740, boul. Lionel-Boulet
>> Varennes (QC) J1X 1S1, Canada
>>
>>
>
>
>
> --
> ricard
> http://www.ricardmarxer.com
> http://www.caligraft.com
>
>
>
>
>



-- 
ricard
http://www.ricardmarxer.com
http://www.caligraft.com





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