RE: [eigen] How about pseudo-inverse? |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: <eigen@xxxxxxxxxxxxxxxxxxx>
- Subject: RE: [eigen] How about pseudo-inverse?
- From: <hamelin.philippe@xxxxxxx>
- Date: Thu, 21 Jan 2010 15:58:21 -0500
- Thread-index: Acqa3C4n15UX7Zp+T8e44It63fN46AAAAcgw
- Thread-topic: [eigen] How about pseudo-inverse?
Using exactly the code submitted the error is:
'max' was not declared in this scope
This error disappear if I include <algorithm> and replace 'max' with 'std::max'.
-----Message d'origine-----
De : Listengine [mailto:listengine@xxxxxxxxxxxxxxxxx] De la part de Benoit Jacob
Envoyé : 21 janvier 2010 15:56
À : eigen@xxxxxxxxxxxxxxxxxxx
Objet : Re: [eigen] How about pseudo-inverse?
oh. We are indeed using std::max. Normally this shouldn't give you an
error, you shouldn't have anything to do about it. What exact
compilation error do you get?
Benoit
2010/1/21 <hamelin.philippe@xxxxxxx>:
> I already had included <Eigen/Array>. I used std::max, is it ok?
>
> -----Message d'origine-----
> De : Listengine [mailto:listengine@xxxxxxxxxxxxxxxxx] De la part de Benoit Jacob
> Envoyé : 21 janvier 2010 14:39
> À : eigen@xxxxxxxxxxxxxxxxxxx
> Objet : Re: [eigen] How about pseudo-inverse?
>
> You probably need #include<Eigen/Array>
>
> This annoyance has just been addressed in the development branch.
>
> 2010/1/21 <hamelin.philippe@xxxxxxx>:
>> I have problem compiling the following code due to the "max" function. The compiler tells me that it haven't been decladed in this scope. Does this function makes reference to the standard C++ max function or one from Eigen2 ?
>>
>> Philippe
>>
>> -----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
>>
>>
>>
>>
>>
>
>
>
>
>