You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix zero elements for block-matrix kron involving Diagonal (#55941)
Currently, it's assumed that the zero element is identical for the
matrix, but this is not necessary if the elements are matrices
themselves and have different sizes. This PR ensures that `kron` for a
`Diagonal` has the correct zero elements.
Current:
```julia
julia> D = Diagonal(1:2)
2×2 Diagonal{Int64, UnitRange{Int64}}:
1 ⋅
⋅ 2
julia> B = reshape([ones(2,2), ones(3,2), ones(2,3), ones(3,3)], 2, 2);
julia> size.(kron(D, B))
4×4 Matrix{Tuple{Int64, Int64}}:
(2, 2) (2, 3) (2, 2) (2, 2)
(3, 2) (3, 3) (2, 2) (2, 2)
(2, 2) (2, 2) (2, 2) (2, 3)
(2, 2) (2, 2) (3, 2) (3, 3)
```
This PR
```julia
julia> size.(kron(D, B))
4×4 Matrix{Tuple{Int64, Int64}}:
(2, 2) (2, 3) (2, 2) (2, 3)
(3, 2) (3, 3) (3, 2) (3, 3)
(2, 2) (2, 3) (2, 2) (2, 3)
(3, 2) (3, 3) (3, 2) (3, 3)
```
Note the differences e.g. in the `CartesianIndex(4,1)`,
`CartesianIndex(3,2)` and `CartesianIndex(3,3)` elements.
0 commit comments