Skip to content

Commit

Permalink
fix #29392: correct ambiguity resolving fallback for of (*|/)(::Numbe…
Browse files Browse the repository at this point in the history
…r, ::SymOrHerm)
  • Loading branch information
fredrikekre committed Oct 2, 2018
1 parent a2df80e commit 964bae7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions stdlib/LinearAlgebra/src/symmetric.jl
Original file line number Diff line number Diff line change
Expand Up @@ -442,9 +442,9 @@ mul!(C::StridedMatrix{T}, A::StridedMatrix{T}, B::Hermitian{T,<:StridedMatrix})

for T in (:Symmetric, :Hermitian), op in (:*, :/)
# Deal with an ambiguous case
@eval ($op)(A::$T, x::Bool) = ($T)(($op)(A.data, x), sym_uplo(A.uplo))
@eval ($op)(A::$T, x::Bool) = broadcast($op, A, x)
S = T == :Hermitian ? :Real : :Number
@eval ($op)(A::$T, x::$S) = ($T)(($op)(A.data, x), sym_uplo(A.uplo))
@eval ($op)(A::$T, x::$S) = broadcast($op, A, x)
end

function factorize(A::HermOrSym{T}) where T
Expand Down
9 changes: 9 additions & 0 deletions stdlib/LinearAlgebra/test/symmetric.jl
Original file line number Diff line number Diff line change
Expand Up @@ -517,4 +517,13 @@ end
@test Hermitian(A, :U)[1,1] == Hermitian(A, :L)[1,1] == real(A[1,1])
end

@testset "issue #29392" begin
S = Symmetric(rand(Float64, 2, 2))
H = Hermitian(rand(ComplexF64, 2, 2))
@test (2.0 * S)::Matrix{Float64} == (S * 2.0)::Matrix{Float64}
@test (2.0 * H)::Matrix{ComplexF64} == (H * 2.0)::Matrix{ComplexF64}
@test (S / 2.0)::Matrix{Float64} == Matrix(S) / 2.0
@test (H / 2.0)::Matrix{Float64} == Matrix(H) / 2.0
end

end # module TestSymmetric

0 comments on commit 964bae7

Please sign in to comment.