-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support broadcasting over structured block matrices (#53909)
Fix https://github.com/JuliaLang/julia/issues/48664 After this, broadcasting over structured block matrices with matrix-valued elements works: ```julia julia> D = Diagonal([[1 2; 3 4], [5 6; 7 8]]) 2×2 Diagonal{Matrix{Int64}, Vector{Matrix{Int64}}}: [1 2; 3 4] ⋅ ⋅ [5 6; 7 8] julia> D .+ D 2×2 Diagonal{Matrix{Int64}, Vector{Matrix{Int64}}}: [2 4; 6 8] ⋅ ⋅ [10 12; 14 16] julia> cos.(D) 2×2 Matrix{Matrix{Float64}}: [0.855423 -0.110876; -0.166315 0.689109] [1.0 0.0; 0.0 1.0] [1.0 0.0; 0.0 1.0] [0.928384 -0.069963; -0.0816235 0.893403] ``` Such operations show up when using `BlockArrays`. The implementation is a bit hacky as it uses `0I` as the zero element in `fzero`, which isn't really the correct zero if the blocks are rectangular. Nonetheless, this works, as `fzero` is only used to determine if the structure is preserved.
- Loading branch information
Showing
3 changed files
with
63 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters