Skip to content

Commit

Permalink
Correct lyap definition for complex scalar arguments (#39901)
Browse files Browse the repository at this point in the history
  • Loading branch information
Regan-Koopmans authored Mar 16, 2021
1 parent ae26fc6 commit da96fef
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion stdlib/LinearAlgebra/src/dense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1568,4 +1568,4 @@ function lyap(A::StridedMatrix{T}, C::StridedMatrix{T}) where {T<:BlasFloat}
rmul!(Q*(Y * adjoint(Q)), inv(scale))
end
lyap(A::StridedMatrix{T}, C::StridedMatrix{T}) where {T<:Integer} = lyap(float(A), float(C))
lyap(a::T, c::T) where {T<:Number} = -c/(2a)
lyap(a::Union{Real,Complex}, c::Union{Real,Complex}) = -c/(2real(a))
4 changes: 4 additions & 0 deletions stdlib/LinearAlgebra/test/dense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,10 @@ end
@test diag(zeros(0,1),2) == []
end

@testset "issue #39857" begin
@test lyap(1.0+2.0im, 3.0+4.0im) == -1.5 - 2.0im
end

@testset "Matrix to real power" for elty in (Float64, ComplexF64)
# Tests proposed at Higham, Deadman: Testing Matrix Function Algorithms Using Identities, March 2014
#Aa : only positive real eigenvalues
Expand Down

0 comments on commit da96fef

Please sign in to comment.