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
I had this little dirty piece of code, and thought I'll leave it here for when there is some common ground between BlockArrays.jl and BlockDiagonals.jl.
using LinearAlgebra, BlockArrays, BlockDiagonals
Base.@propagate_inboundsfunction LinearAlgebra.mul!(y::BlockMatrix, A::BlockDiagonal, x::BlockMatrix,
α::Number=true, β::Number=false)
yblocks = y.blocks
xblocks = x.blocks
blockmaps = BlockDiagonals.blocks(A)
ym, yn =size(yblocks)
xm, xn =size(xblocks)
Am =length(blockmaps)
# second condition could probably be relaxed
(ym == Am == xm && yn == xn ==1) ||error("blocks mismatching")
for (yi, Ai, xi) inzip(yblocks, blockmaps, xblocks)
# some kind of elegant size checking
(size(yi, 1) ==size(Ai, 1) &&size(xi, 1) ==size(Ai, 2) &&size(yi, 2) ==size(xi, 2)) ||throw(DimensionMismatch())
endfor (yi, Ai, xi) inzip(yblocks, blockmaps, xblocks)
# this currently only works if none of the blocks is a BlockDiagonal matrixmul!(yi, Ai, xi, α, β)
endreturn y
end
I had this little dirty piece of code, and thought I'll leave it here for when there is some common ground between
BlockArrays.jl
andBlockDiagonals.jl
.Then
is probably nice to have.
The text was updated successfully, but these errors were encountered: