In general you cannot sort the eigenvalues of a non-symmetric eigenproblem
because the eigenvalues can be complex.
The right solution is to solve the symmetric problem instead of sorting the
values because it is typically much faster to solve a symmetric problem.
For eigfact, you can use the Symmetric type, e.g.
julia> Asym=A*Diagonal(randn(4))*A'
4x4 Array{Float64,2}:
2.04501 -0.503528 0.530358 1.329
-0.503528 0.223803 -3.61019 -0.724645
0.530358 -3.61019 2.23592 2.52107
1.329 -0.724645 2.52107 1.30232
julia> eigfact(Asym)[:values]
4-element Array{Float64,1}:
6.57111
2.05577
0.000216445
-2.82005
julia> eigfact(Symmetric(Asym))[:values]
4-element Array{Float64,1}:
-2.82005
0.000216445
2.05577
6.57111
but this doesn't work for eigs yet. I am looking into it. Is your problem
sparse?
2014-04-26 15:12 GMT+02:00 Ethan Anderes <[email protected]>:
>
> Yeah, of course I feel silly whining about it because I could just sort
them. However, I'm making quite a few calls to eigs where all the arguments
should be symmetric but I get numerical non-symmetry in ways that I can't
predict. Therefore each call to d,v = eigs(..) now needs two extra lines to
sort the d and v, even though some of the calls don't need it.
>
> A = rand(10,10)
> d, = eigs(A' * A) # <- symmetric arg
> d, = eigs(A' * diagm(rand(10)) * A) # <- non-symmetric arg sometimes...
>
>
> So yeah, not a big problem for me, but maybe an issue for someone who has
a performance critical loop in their code and doesn't want to add two lines
of code each pass.
>
> Cheers,
> Ethan
--
Med venlig hilsen
Andreas Noack Jensen