Skip to content

Commit e730971

Browse files
committed
Fix real geev eigenvectors
1 parent 097eac5 commit e730971

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

lib/cusolver/linalg.jl

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,22 @@ end
140140

141141
function LinearAlgebra.eigen(A::CuMatrix{T}) where {T<:BlasReal}
142142
A2 = copy(A)
143-
r = Xgeev!('N', 'V', A2)
144-
return Eigen(sorteig!(r[1], r[3])...)
143+
W, _, VR = Xgeev!('N', 'V', A2)
144+
C = Complex{T}
145+
U = CuMatrix{C}([1. 1.; im -im])
146+
VR = CuMatrix{C}(VR)
147+
h_W = collect(W)
148+
n = length(W)
149+
j = 1
150+
while j <= n
151+
if imag(h_W[j]) == 0
152+
j += 1
153+
else
154+
VR[:,j:j+1] .= VR[:,j:j+1] * U
155+
j += 2
156+
end
157+
end
158+
return Eigen(sorteig!(W, VR)...)
145159
end
146160
function LinearAlgebra.eigen(A::CuMatrix{T}) where {T<:BlasComplex}
147161
A2 = copy(A)

0 commit comments

Comments
 (0)