-
Notifications
You must be signed in to change notification settings - Fork 14
BlockSkylineMatrix–Diagonal arithmetic, fix BlockDiagonal #58
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
Conversation
My fix for #57 basically mirrors LinearAlgebra's implementation for I don't know if that is a good idea, since |
I use internal functionality in Base all the time, for some things there's no other way, for others its easier to just fix bugs introduced by this in future versions when they arise. |
Fair enough. I should mention that I consciously did not try to support arithmetic with a |
What BlockArrays.jl does is to take the union of all blocks, that is, if you add a vector with block sizes [1,2,2] to one with block sizes [3,1,1] you get one with block sizes [1,2,1,1]. I feel like block skyline structure would be preserved under this, though perhaps I haven't thought it through enough |
What I mean is this slightly odd case:
I think the easiest is to just grow the block-bandwidths to be at least |
I finally got around to fixing the general case as well, so now we can do: julia> M
4×4-blocked 10×10 BlockSkylineMatrix{Int64,Array{Int64,1},BlockBandedMatrices.BlockSkylineSizes{Tuple{BlockArrays.BlockedUnitRange{Array{Int64,1}},BlockArrays.BlockedUnitRange{Array{Int64,1}}},Array{Int64,1},Array{Int64,1},BandedMatrices.BandedMatrix{Int64,Array{Int64,2},Base.OneTo{Int64}},Array{Int64,1}}}:
⋅ │ ⋅ ⋅ │ ⋅ ⋅ ⋅ │ ⋅ ⋅ ⋅ ⋅
───┼────────┼───────────┼────────────
⋅ │ ⋅ ⋅ │ ⋅ ⋅ ⋅ │ ⋅ ⋅ ⋅ ⋅
⋅ │ ⋅ ⋅ │ ⋅ ⋅ ⋅ │ ⋅ ⋅ ⋅ ⋅
───┼────────┼───────────┼────────────
1 │ ⋅ ⋅ │ ⋅ ⋅ ⋅ │ ⋅ ⋅ ⋅ ⋅
1 │ ⋅ ⋅ │ ⋅ ⋅ ⋅ │ ⋅ ⋅ ⋅ ⋅
1 │ ⋅ ⋅ │ ⋅ ⋅ ⋅ │ ⋅ ⋅ ⋅ ⋅
───┼────────┼───────────┼────────────
⋅ │ 1 1 │ ⋅ ⋅ ⋅ │ ⋅ ⋅ ⋅ ⋅
⋅ │ 1 1 │ ⋅ ⋅ ⋅ │ ⋅ ⋅ ⋅ ⋅
⋅ │ 1 1 │ ⋅ ⋅ ⋅ │ ⋅ ⋅ ⋅ ⋅
⋅ │ 1 1 │ ⋅ ⋅ ⋅ │ ⋅ ⋅ ⋅ ⋅
julia> T
10×10 Tridiagonal{Int64,Array{Int64,1}}:
2 3 ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
1 2 3 ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
⋅ 1 2 3 ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
⋅ ⋅ 1 2 3 ⋅ ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ 1 2 3 ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ ⋅ 1 2 3 ⋅ ⋅ ⋅
⋅ ⋅ ⋅ ⋅ ⋅ 1 2 3 ⋅ ⋅
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 1 2 3 ⋅
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 1 2 3
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 1 2
julia> M+T
4×4-blocked 10×10 BlockSkylineMatrix{Int64,Array{Int64,1},BlockBandedMatrices.BlockSkylineSizes{Tuple{BlockArrays.BlockedUnitRange{Array{Int64,1}},BlockArrays.BlockedUnitRange{Array{Int64,1}}},Array{Int64,1},Array{Int64,1},BandedMatrices.BandedMatrix{Int64,Array{Int64,2},Base.OneTo{Int64}},Array{Int64,1}}}:
2 │ 3 0 │ ⋅ ⋅ ⋅ │ ⋅ ⋅ ⋅ ⋅
───┼────────┼───────────┼────────────
1 │ 2 3 │ 0 0 0 │ ⋅ ⋅ ⋅ ⋅
0 │ 1 2 │ 3 0 0 │ ⋅ ⋅ ⋅ ⋅
───┼────────┼───────────┼────────────
1 │ 0 1 │ 2 3 0 │ 0 0 0 0
1 │ 0 0 │ 1 2 3 │ 0 0 0 0
1 │ 0 0 │ 0 1 2 │ 3 0 0 0
───┼────────┼───────────┼────────────
⋅ │ 1 1 │ 0 0 1 │ 2 3 0 0
⋅ │ 1 1 │ 0 0 0 │ 1 2 3 0
⋅ │ 1 1 │ 0 0 0 │ 0 1 2 3
⋅ │ 1 1 │ 0 0 0 │ 0 0 1 2 i.e. the block-bandwidths are grown as necessary. I've implemented |
Codecov Report
@@ Coverage Diff @@
## master #58 +/- ##
==========================================
+ Coverage 79.54% 81.84% +2.30%
==========================================
Files 10 10
Lines 787 865 +78
==========================================
+ Hits 626 708 +82
+ Misses 161 157 -4
Continue to review full report at Codecov.
|
I also added |
BTW, nightly is failing: https://travis-ci.org/github/JuliaMatrices/BlockBandedMatrices.jl/jobs/704067097#L326 |
Don’t worry about nightly. I’ll get 1.5 working once it’s rc2 as I’m waiting for a backport |
Ok, then this PR is good to go from my point of view. |
I implemented a fix for #57 and made sure
BlockDiagonal
does not useBlockSizes
anymore. I also exportedBlockDiagonal
.The
MulAdd
s still need to be fixed though:https://github.com/JuliaMatrices/BlockBandedMatrices.jl/blob/657b48059ab3d5f720fdf7efb2cd9eecb1dfbdd3/src/linalg.jl#L113-L148