1
0
mirror of https://github.com/kalmarek/SmallHyperbolic synced 2024-11-09 04:05:27 +01:00

add eigvals_rump and immediately conjugate in safe_eigvals

This commit is contained in:
kalmarek 2020-05-26 01:14:57 +02:00
parent a82b1af8f7
commit 62c8a09cc9
No known key found for this signature in database
GPG Key ID: 8BF1A3855328FC15

View File

@ -144,6 +144,29 @@ function LinearAlgebra.eigvals(A::acb_mat)
return CC.(λ) return CC.(λ)
end end
function eigvals_rump(A::acb_mat)
n = nrows(A)
CC = base_ring(A)
p = prec(CC)
λ_approx = AcbVector(n, p)
R_approx = similar(A)
v = approx_eig_qr!(λ_approx, R_approx, A)
λ = AcbVector(n, p)
b = ccall(
(:acb_mat_eig_multiple_rump, libarb),
Cint,
(Ptr{acb_struct}, Ref{acb_mat}, Ptr{acb_struct}, Ref{acb_mat}, Int),
λ,
A,
λ_approx,
R_approx,
p,
)
return CC.(λ)
end
function _count_multiplicites(evs) function _count_multiplicites(evs)
λ_m = Vector{Tuple{acb,Int}}() λ_m = Vector{Tuple{acb,Int}}()
sizehint!(λ_m, length(evs)) sizehint!(λ_m, length(evs))
@ -165,11 +188,11 @@ function _count_multiplicites(evs)
end end
function safe_eigvals(m::acb_mat) function safe_eigvals(m::acb_mat)
evs = eigvals(m) # evs = eigvals_rump(m)
all(isfinite.(evs)) && return evs # all(isfinite.(evs)) && return evs
CC = base_ring(m) CC = base_ring(m)
X = matrix(CC, rand(CC, size(m))) X = matrix(CC, rand(CC, size(m)))
evs = eigvals(X * m * inv(X)) evs = eigvals_rump(X * m * inv(X))
return evs return evs
all(isfinite.(evs)) && return evs all(isfinite.(evs)) && return evs
throw(ArgumentError("Could not compute eigenvalues")) throw(ArgumentError("Could not compute eigenvalues"))