# commons-dev mailing list archives

##### Site index · List index
Message view
Top
From Phil Steitz <phil.ste...@gmail.com>
Subject Re: [Math] EigenDecompositionImpl#getEigenvector()
Date Sun, 20 Sep 2009 14:34:27 GMT
```Ted Dunning wrote:
> Numerical issues should not impinge on a computation this small.
>
> For reference, I replicated your computation and found reasonable
> eigenvalues and vectors:
>
>> m = matrix(c(0,1,-1,1,1,0,-1,0,1), nrow=3)
>> m
>      [,1] [,2] [,3]
> [1,]    0    1   -1
> [2,]    1    1    0
> [3,]   -1    0    1
>> eig(m)
> Error: could not find function "eig"
>> eigen(m)
> \$values
> [1]  2  1 -1
>
> \$vectors
>            [,1]      [,2]       [,3]
> [1,]  0.5773503 0.0000000  0.8164966
> [2,]  0.5773503 0.7071068 -0.4082483
> [3,] -0.5773503 0.7071068  0.4082483
>
>
> Your usage appears to be in accord with the suggested usage, but have you
> tried it with a tolerance of, say, 1e-3?
>
> On Sat, Sep 19, 2009 at 10:41 PM, Axel <axelclk@gmail.com> wrote:
>
>> Hello
>>
>> I'm trying to calculate the Eigenvectors of this Wikipedia example:
>> http://en.wikipedia.org/wiki/Eigenvalue_algorithm#Identifying_eigenvectors
>>
>> with this JUnit method:
>>
>>  public void testEigenDecomposition() {
>>    double[][] m = { { 0.0, 1.0, -1.0 }, { 1.0, 1.0, 0.0 }, { -1.0,
>> 0.0, 1.0 } };
>>    RealMatrix rm = new Array2DRowRealMatrix(m);
>>    assertEquals(rm.toString(),
>>
>>  "Array2DRowRealMatrix{{0.0,1.0,-1.0},{1.0,1.0,0.0},{-1.0,0.0,1.0}}");
>>    EigenDecompositionImpl ed = new EigenDecompositionImpl(rm,
>>        MathUtils.SAFE_MIN);
>>    RealVector rv0 = ed.getEigenvector(0);
>>    assertEquals(rv0.toString(), "{(NaN); (NaN); (NaN)}");
>>  }
>>
>> but I'm getting only {(NaN); (NaN); (NaN)} as a result vector.
>>
>> Is this intentionally (because of numerical inaccuracy?) or am I doing
>> something wrong in using EigenDecompositionImpl?
>>
>> --
>> Axel Kramer
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>> For additional commands, e-mail: dev-help@commons.apache.org
>>
>>
>
>
Thanks for reporting this. Looks like a bug. The eigenvalues are
being correctly computed but all three eigenvectors are coming out
<NaN, NaN, NaN>

This is being tracked as MATH-297.

Phil

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org