Skip to content

Commit 96d130a

Browse files
authored
Fix adjoint-Diagonal multiplication for non-square elements (#317)
* Diagonal mul zerosadj ambiguity * missing adjoint in adj-diag mul * Fix test for non-square
1 parent 8c7ace3 commit 96d130a

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/fillalgebra.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,8 @@ end
300300

301301
*(a::Adjoint{T, <:AbstractMatrix{T}} where T, b::AbstractZeros{<:Any, 1}) = mult_zeros(a, b)
302302

303-
*(a::AdjointAbsVec{<:Any,<:AbstractZerosVector}, D::Diagonal) = (D*a')'
303+
*(D::Diagonal, a::AdjointAbsVec{<:Any,<:AbstractZerosVector}) = (a' * D')'
304+
*(a::AdjointAbsVec{<:Any,<:AbstractZerosVector}, D::Diagonal) = (D' * a')'
304305
*(a::TransposeAbsVec{<:Any,<:AbstractZerosVector}, D::Diagonal) = transpose(D*transpose(a))
305306
function _triple_zeromul(x, D::Diagonal, y)
306307
if !(length(x) == length(D.diag) == length(y))

test/runtests.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,6 +1487,14 @@ end
14871487
D = Diagonal([[1 2; 3 4], [1 2 3; 4 5 6]])
14881488
@test @inferred(Zeros(TSM, 2,2) * D) == zeros(TSM, 2,2) * D
14891489

1490+
D = Diagonal(fill(SMatrix{2,3}(fill(im,6)),1))
1491+
Z = Zeros(SMatrix{2,3,ComplexF64,6},1)
1492+
@test D * Z' == fill(zero(SMatrix{2,2,ComplexF64,4}),1,1)
1493+
1494+
D = Diagonal(fill(zeros(2,3), 2))
1495+
Z = Zeros(SMatrix{2,3,Float64,6}, 2)
1496+
@test Z' * D == Array(Z)' * D
1497+
14901498
# doubly nested
14911499
A = [[[1,2]]]'
14921500
Z = Zeros(SMatrix{1,1,SMatrix{2,2,Int,4},1},1)

0 commit comments

Comments
 (0)