Skip to content

Commit 0ace4e3

Browse files
committed
Comments
1 parent a0ff394 commit 0ace4e3

File tree

2 files changed

+6
-24
lines changed

2 files changed

+6
-24
lines changed

ext/MatrixAlgebraKitGenericLinearAlgebraExt.jl

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -49,27 +49,11 @@ MatrixAlgebraKit.initialize_output(::typeof(eigh_vals!), A::AbstractMatrix, ::GL
4949

5050
function MatrixAlgebraKit.eigh_full!(A::AbstractMatrix, DV, ::GLA_QRIteration)
5151
eigval, eigvec = eigen!(Hermitian(A); sortby = real)
52-
D, V = DV
53-
if isnothing(D)
54-
D = Diagonal(eigval::AbstractVector{real(eltype(A))})
55-
else
56-
copyto!(D, Diagonal(eigval::AbstractVector{real(eltype(A))}))
57-
end
58-
if isnothing(V)
59-
V = eigvec::AbstractMatrix{eltype(A)}
60-
else
61-
copyto!(V, eigvec::AbstractMatrix{eltype(A)})
62-
end
63-
return D, V
52+
return Diagonal(eigval::AbstractVector{real(eltype(A))}), eigvec::AbstractMatrix{eltype(A)}
6453
end
6554

6655
function MatrixAlgebraKit.eigh_vals!(A::AbstractMatrix, D, ::GLA_QRIteration)
67-
if isnothing(D)
68-
D = eigvals!(Hermitian(A); sortby = real)
69-
else
70-
copyto!(D, eigvals!(Hermitian(A); sortby = real))
71-
end
72-
return D
56+
return eigvals!(Hermitian(A); sortby = real)
7357
end
7458

7559
function MatrixAlgebraKit.default_qr_algorithm(::Type{T}; kwargs...) where {T <: StridedMatrix{<:Union{Float16, ComplexF16, BigFloat, Complex{BigFloat}}}}

test/testsuite/eigh.jl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ function test_eigh_full(
3535
@test isunitary(V)
3636
@test all(isreal, D)
3737

38-
D2, V2 = eigh_full!(copy(A), (D, V))
39-
@test D2 === D
40-
@test V2 === V
38+
D2, V2 = eigh_full!(Ac, (D, V))
39+
@test A * V2 V2 * D2
4140

4241
D3 = @testinferred eigh_vals(A)
4342
@test D Diagonal(D3)
@@ -60,9 +59,8 @@ function test_eigh_full_algs(
6059
@test isunitary(V)
6160
@test all(isreal, D)
6261

63-
D2, V2 = eigh_full!(copy(A), (D, V); alg)
64-
@test D2 === D
65-
@test V2 === V
62+
D2, V2 = eigh_full!(Ac, (D, V); alg)
63+
@test A * V2 V2 * D2
6664

6765
D3 = @testinferred eigh_vals(A; alg)
6866
@test D Diagonal(D3)

0 commit comments

Comments
 (0)