yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #03321
Re: EigenDecomposition wrapper problem
> I'm trying to create a wrapper for Eigen library. Almost all functions
> are already done, but I have a problem with EigenDecomposition.
> Unfortunately, I never used this functions and do not clearly
> understand what it implements.
>
> Eigen library has an EigenSolver for those tasks
> http://eigen.tuxfamily.org/dox/classEigen_1_1EigenSolver.html
>
> I tried to get all values from that solver and compare with results,
> what Wm3 gives. It is completely different.
Using numpy to check:
>>> from numpy import array
>>> fron numpy.linalg import eig
>>> a=array([[-26.8141,20.0536,-37.6382],[-17.0536,-4.37217,13.4546],[39.0891,8.34892,-21.6416]])
>>> eig(a) ## http://docs.scipy.org/doc/numpy/reference/generated/numpy.linalg.eig.html
(array([-26.91393664+42.69101435j, -26.91393664-42.69101435j, 1.00000328 +0.j ]),
array([[ 0.70584131+0.j , 0.70584131+0.j , 0.05979811+0.j ],
[-0.03806586+0.30786093j, -0.03806586-0.30786093j, 0.89863520+0.j ],
[-0.01840919-0.63657033j, -0.01840919+0.63657033j, 0.43460208+0.j ]]))
You've picked matrix that has complex eigenvalues, that explains the
difference; eigen handles it just fine ("(real,imag)" notation), wm3
obviously doesn't. (the matrix should be positive definite for real
eigenvalues, iirc).
Cheers, Vaclav
> Here is the source matrix:
>
> -26.8141 20.0536 -37.6382
> -17.0536 -4.37217 13.4546
> 39.0891 8.34892 -21.6416
>
>
> =======================
> wm3:
>
> tRot:
> -0.698021 -0.0166317 -0.715884
> 0.339616 -0.887829 -0.310515
> -0.630419 -0.459872 0.625372
>
> tDiag:
> -70.5641 0 0
> 0 2.97262 0
> 0 0 14.7635
>
> =======================
> Eigen:
> eigenvalues:
> (-26.91,42.69)
> (-26.91,-42.69)
> (1,0)
>
> eigenvectors:
> (-0.117,0.6961) (-0.117,-0.6961) (0.0598,0)
> (-0.2973,-0.08855) (-0.2973,0.08855) (0.8986,0)
> (0.6308,0.08732) (0.6308,-0.08732) (0.4346,0)
>
> pseudoEigenvalueMatrix:
> -26.91 42.69 0
> -42.69 -26.91 0
> 0 0 1
>
> pseudoEigenvectors:
> -0.1654 0.9844 0.0598
> -0.4204 -0.1252 0.8986
> 0.8921 0.1235 0.4346
> =======================
Follow ups
References