From 69fbcaae15cb7f58d165f8d9c9d8b8c8af5dbc3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Thu, 29 Feb 2024 21:46:00 +0100 Subject: [PATCH] Fix product of Complex with Hermitian (#265) --- src/dispatch.jl | 7 ------- test/dispatch.jl | 8 ++++++++ test/dummy.jl | 2 ++ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/dispatch.jl b/src/dispatch.jl index 20f98e36..5ba9d607 100644 --- a/src/dispatch.jl +++ b/src/dispatch.jl @@ -484,13 +484,6 @@ function Base.:*(α::Number, A::LinearAlgebra.Symmetric{<:AbstractMutable}) return LinearAlgebra.Symmetric(B, c) end -function Base.:*(α::Number, A::LinearAlgebra.Hermitian{<:AbstractMutable}) - c = LinearAlgebra.sym_uplo(A.uplo) - B = c == :U ? _mult_upper(α, A) : _mult_lower(α, A) - return LinearAlgebra.Hermitian(B, c) -end - -# Fix ambiguity identified by Aqua.jl. function Base.:*(α::Real, A::LinearAlgebra.Hermitian{<:AbstractMutable}) c = LinearAlgebra.sym_uplo(A.uplo) B = c == :U ? _mult_upper(α, A) : _mult_lower(α, A) diff --git a/test/dispatch.jl b/test/dispatch.jl index 5856459c..3c8eade2 100644 --- a/test/dispatch.jl +++ b/test/dispatch.jl @@ -55,3 +55,11 @@ end @test all(MA.isequal_canonical.(2 * LinearAlgebra.Hermitian(A, :L), D)) @test all(MA.isequal_canonical.(2 * LinearAlgebra.Hermitian(A, :U), D)) end + +@testset "*(::Complex, ::Hermitian)" begin + A = BigInt[1 2; 2 3] + B = LinearAlgebra.Hermitian(DummyBigInt.(A)) + C = 2im * A + @test 2im * B == C + @test C isa Matrix{Complex{BigInt}} +end diff --git a/test/dummy.jl b/test/dummy.jl index c84e55bb..2121661c 100644 --- a/test/dummy.jl +++ b/test/dummy.jl @@ -171,3 +171,5 @@ end function Base.:^(x::DummyBigInt, y::Union{Integer,UniformScaling{<:Integer}}) return DummyBigInt(x.data^y) end + +Base.:*(x::Complex, y::DummyBigInt) = x * y.data