Skip to content

Commit d0fac8c

Browse files
authored
Generalize Diagonal * AdjOrTransAbsMat to arbitrary element types (#52389)
1 parent ebb7b2a commit d0fac8c

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

src/diagonal.jl

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -320,15 +320,6 @@ end
320320
rmul!(A::AbstractMatrix, D::Diagonal) = @inline mul!(A, A, D)
321321
lmul!(D::Diagonal, B::AbstractVecOrMat) = @inline mul!(B, D, B)
322322

323-
function (*)(A::AdjOrTransAbsMat, D::Diagonal)
324-
Ac = copy_similar(A, promote_op(*, eltype(A), eltype(D.diag)))
325-
rmul!(Ac, D)
326-
end
327-
function (*)(D::Diagonal, A::AdjOrTransAbsMat)
328-
Ac = copy_similar(A, promote_op(*, eltype(A), eltype(D.diag)))
329-
lmul!(D, Ac)
330-
end
331-
332323
function __muldiag!(out, D::Diagonal, B, _add::MulAddMul{ais1,bis0}) where {ais1,bis0}
333324
require_one_based_indexing(out, B)
334325
alpha, beta = _add.alpha, _add.beta

test/diagonal.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ using .Main.InfiniteArrays
1818
isdefined(Main, :FillArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "FillArrays.jl"))
1919
using .Main.FillArrays
2020

21+
isdefined(Main, :SizedArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "SizedArrays.jl"))
22+
using .Main.SizedArrays
23+
2124
const n=12 # Size of matrix problem to test
2225
Random.seed!(1)
2326

@@ -778,6 +781,11 @@ end
778781
D = Diagonal(fill(M, n))
779782
@test D == Matrix{eltype(D)}(D)
780783
end
784+
785+
S = SizedArray{(2,3)}(reshape([1:6;],2,3))
786+
D = Diagonal(fill(S,3))
787+
@test D * fill(S,2,3)' == fill(S * S', 3, 2)
788+
@test fill(S,3,2)' * D == fill(S' * S, 2, 3)
781789
end
782790

783791
@testset "Eigensystem for block diagonal (issue #30681)" begin

0 commit comments

Comments
 (0)