From f2c00cc0a3e13eed0bf1bf2668de6ed072fa0c2a Mon Sep 17 00:00:00 2001 From: mcognetta <cognetta.marco@gmail.com> Date: Mon, 30 Jul 2018 04:34:30 +0900 Subject: [PATCH 1/2] fixed dense times diagonal matrix multiplication --- stdlib/LinearAlgebra/src/bidiag.jl | 1 + stdlib/LinearAlgebra/test/bidiag.jl | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/stdlib/LinearAlgebra/src/bidiag.jl b/stdlib/LinearAlgebra/src/bidiag.jl index 89bf143b3a973..00e3abe76d527 100644 --- a/stdlib/LinearAlgebra/src/bidiag.jl +++ b/stdlib/LinearAlgebra/src/bidiag.jl @@ -504,6 +504,7 @@ const SpecialMatrix = Union{Bidiagonal,SymTridiagonal,Tridiagonal} # to avoid ambiguity warning, but shouldn't be necessary *(A::AbstractTriangular, B::SpecialMatrix) = Array(A) * Array(B) *(A::SpecialMatrix, B::SpecialMatrix) = Array(A) * Array(B) +*(A::AbstractMatrix, B::SpecialMatrix) = A_mul_B_td!(zeros(eltype(A),size(A)...), A, B) #Generic multiplication *(A::Bidiagonal{T}, B::AbstractVector{T}) where {T} = *(Array(A), B) diff --git a/stdlib/LinearAlgebra/test/bidiag.jl b/stdlib/LinearAlgebra/test/bidiag.jl index f90a13caddaa3..eff5192ff368e 100644 --- a/stdlib/LinearAlgebra/test/bidiag.jl +++ b/stdlib/LinearAlgebra/test/bidiag.jl @@ -290,6 +290,11 @@ srand(1) @test Matrix{Complex{Float64}}(BD) == BD end +# Issue 27176 +Diag = Tridiagonal([1,],[2,2],[1,]) +Dense = [0.42 0.18; 0.08 0.58] +@test typeof(Diag*Dense) == typeof(Dense*Diag) == typeof(Dense) + # Issue 10742 and similar let A = Bidiagonal([1,2,3], [0,0], :U) @test istril(A) From 07fc1c850863988b4b6e4fad1dc63c2dca01caec Mon Sep 17 00:00:00 2001 From: mcognetta <cognetta.marco@gmail.com> Date: Mon, 6 Aug 2018 11:53:54 +0900 Subject: [PATCH 2/2] removing ambiguity --- stdlib/LinearAlgebra/src/bidiag.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/LinearAlgebra/src/bidiag.jl b/stdlib/LinearAlgebra/src/bidiag.jl index 00e3abe76d527..d412c21f55a94 100644 --- a/stdlib/LinearAlgebra/src/bidiag.jl +++ b/stdlib/LinearAlgebra/src/bidiag.jl @@ -502,7 +502,7 @@ end const SpecialMatrix = Union{Bidiagonal,SymTridiagonal,Tridiagonal} # to avoid ambiguity warning, but shouldn't be necessary -*(A::AbstractTriangular, B::SpecialMatrix) = Array(A) * Array(B) +#*(A::AbstractTriangular, B::SpecialMatrix) = Array(A) * Array(B) *(A::SpecialMatrix, B::SpecialMatrix) = Array(A) * Array(B) *(A::AbstractMatrix, B::SpecialMatrix) = A_mul_B_td!(zeros(eltype(A),size(A)...), A, B)