Hi Thomas,
you are definitely right. I was fooled by the "nice" result of the
JAMA calculation, not noticing that it is there that I was extracting
values in a strange order.

I now made some 3x3 tests on known results and also with the A * v =
lambda * v constraint and everything is alright.

I still have to figure out how to properly use the results to split
higher elevation parts from lower z parts in a x,y,z dataset, but the
eigenvectors and values are in the right place now.

Thanks,
Andrea




On Mon, Nov 11, 2013 at 1:21 PM, Thomas Neidhart
<thomas.neidh...@gmail.com> wrote:
> On 11/11/2013 11:40 AM, andrea antonello wrote:
>> Hi Thomas,
>> thanks for your reply.
>>
>>> the result of CM and jama are identical, the difference is just in the
>>> way how the data is stored.
>>>
>>> Afaik in jama calling getV() returns a vector in row format whereas in
>>> CM the are stored in column format.
>>>
>>> If you transpose the matrix (or call getVT()) you will see that the
>>> vectors are identical, except for the signs and order. The reason for
>>> this is that for CM the eigenvalues/eigenvectors are sorted in
>>> descending order in case of a symmetric matrix, which is the case for
>>> your matrix.
>>
>> the problems is that the result is not just different in the
>> transposed way. And in fact if I pick the getVT,results are still not
>> the same.
>> The result seems to be reflected on the secondary diagonal, not the
>> primary diagonal.
>>
>> Furthermore, if I use the API, I do not expect to be problems of rows
>> and columns, so if I use:
>>
>> double eigenValue = eigenDecomposition.getRealEigenvalue(i);
>> RealVector eigenVector = eigenDecomposition.getEigenvector(i);
>>
>> I expect the eigenvector and eigenvalue to be the right ones for the
>> given index, no matter how the results are given in the matrixes.
>>
>> But the results I get are, for the same eigenvalue:
>> CM: eigenVal: 0.8056498828134406, eigenVect: [0.9015723557614027,
>> 0.19005937823202243, 0.38864472217295326
>> JAMA: eigenVal: 0.8056498828134406, eigenVect: [-0.7731388420716028,
>> 0.5012101463530931, -0.38864472217295326]
>>
>> I am still quite puzzled about what I am missing.
>
> I do not know how you get the eigenvector from jama, as there is no
> getEigenVector method.
>
> The class javadoc of their EigenvalueDecomposition states:
>
>     columns of V represent the eigenvectors in the sense that A*V = V*D,
>     i.e. A.times(V) equals V.times(D).  The matrix V may be badly
>     conditioned, or even singular, so the validity of the equation
>     A = V*D*inverse(V) depends upon V.cond().
>
> Looking at your example it looks like you took the rows of V to extract
> your eigenvector.
>
> You can also easily verify if your eigenvector is correct:
>
>  A * v = lambda * v
>
> Thomas
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
> For additional commands, e-mail: user-h...@commons.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org

Reply via email to