-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make compatible with BlockBandedMatrices.jl #8
Comments
Thanks for opening this! I was thinking that it'd be nice for this package to work nicely within the BlockArrays/Matrices ecosystem, but it's not fully decided, and a little extra guidance would be appreciated!
I see that
What did you have in mind specifically? I wonder if instead of having BlockDiaognal as part of the BlockArray ecosystem, we should instead just improve LinearAlgebra's Would welcome feedback/comments/suggestions and of course PRs! pinging @ararslan who has contributed here and may or may not have opinions :) |
Definitely not. We can move
I haven't thought it through much, but I suppose making const BlockDiagonal{T,MT<:AbstractMatrix{T}} = BlockMatrix{T,Diagonal{MT},DefaultBlockSizes{2}} might be a good way. Note |
Hmm, interesting, there's quite a significant conceptual difference between The BlockDiagonal assumes the underlying structure is a The "BlockMatrix{Diagonal}" assumes the underlying structure is [edited for clarity] |
That is not correct; julia> A = BlockArray(randn(6,6), 1:3,1:3)
3×3-blocked 6×6 BlockArray{Float64,2}:
-0.84975 │ 2.20661 -0.920463 │ 1.9042 -2.02121 -0.0278585
───────────┼────────────────────────┼──────────────────────────────────────
-1.38429 │ -0.410338 -0.311795 │ 1.47326 -0.36143 1.64884
0.831705 │ -0.658984 -1.27877 │ 1.48502 0.180917 -0.270828
───────────┼────────────────────────┼──────────────────────────────────────
-1.05782 │ -0.468753 -1.10017 │ -0.00996191 -0.0705051 -0.146721
-1.9989 │ 0.856402 1.71011 │ 0.143385 1.43957 -0.00442993
0.266811 │ -0.174526 0.142927 │ -0.970129 -0.9923 1.1756
julia> diag(A)
6-element Array{Float64,1}:
-0.849750393735063
-0.41033810902489665
-1.2787711809201605
-0.009961911521250116
1.4395683893644051
1.1756042915582254 |
ah, sorry, i didn't mean that it was true of BlockArrays in general, only of the "Diagonal BlockArray" julia> blocks = [rand(2, 2), rand(3, 3)];
julia> BD = BlockDiagonal(blocks);
julia> diag(BD)
5-element Array{Float64,1}:
0.4462094596368906
0.6789518568486066
0.8103392123794502
0.3730887997881511
0.25490783919204985
julia> BA = BlockArray(Diagonal(blocks));
julia> diag(BA)
2-element Array{Array{Float64,2},1}:
[0.446209 0.173019; 0.720358 0.678952]
[0.810339 0.895358 0.722163; 0.439333 0.373089 0.271466; 0.794175 0.673562 0.254908] |
That is a bug. |
Actually, it’s not a bug: you want |
Thanks a lot for your help! I'm going to play around with this a bit more and try figure out what a better integration with BlockArrays might be :D |
It seems to me that this package's functionality could be fully folded into BlockArrays, though I recall some hesitance from @eperim about that. After all, a block diagonal matrix is a straightforward special case of a block matrix. |
I would be fine with that. In fact, I think all |
My hesitation was mainly in adding extra dependencies to this package, but that has already happened, so, as long as we don't lose any of the functionalities here, I have nothing against it. |
I've not had time to work on this for a while, but at some point i would like to both...
of course, i'd be delighted to see someone else do this first! I hope to have time later this summer :) |
I think I will close this and open an issue on BlockArrays.jl for |
Note https://github.com/JuliaMatrices/BlockBandedMatrices.jl exists. We should make sure these packages are compatible in terms of the "block-banded" interface: e.g.,
blockbandwidths(::BlockDIagonal)
should return(0,0)
.Also, there is a
BlockArray
withDiagonal
backend which should also be supported:https://github.com/JuliaArrays/BlockArrays.jl/blob/78fcde4b63a607ae6e63d76e85f4685e33637ea9/test/test_blockarrayinterface.jl#L79
The text was updated successfully, but these errors were encountered: