Comments (21)
This isn't implemented yet. Note that the LU factorisation of a BandedBlockBandedMatrix
may have dense blocks, so when implemented it would consist of first converting to a BlockSkylineMatrix
and using the block banded LU factorisation. This is possible to implement using LAPack's dense LU on the column blocks, but we haven't got around to it.
from blockbandedmatrices.jl.
Is there anything I could do to help?
from blockbandedmatrices.jl.
If you want to try implementing it that would be great. The goal is to have lu!(::BlockSkylineMatrix)
return a BlockSkylineMatrix
. There are a few steps:
- Copy over
lu!(::StridedMatrix)
to LazyArrays.jl to work with general strided matrices. That is, something like
_lu!(_, A, pivot, check) = LinearAlgebra.lu!(A, pivot; check=check) # Fall back to standard `lu!`
function _lu!(::AbstractColumnMajor, A::AbstractMatrix{<:BlasFloat}, pivot, check)
if pivot === Val(false)
return generic_lufact!(A, pivot; check = check)
end
lpt = LAPACK.getrf!(A)
check && checknonsingular(lpt[3])
return LU{T,typeof(A)}(lpt[1], lpt[2], lpt[3])
end
lu!(A::AbstractMatrix, pivot::Union{Val{false}, Val{true}} = Val(true);
check::Bool = true) = _lu!(MemoryLayout(A), A, pivot, check)
- If
A
is aBlockSkylineMatrix
, thenL = colblockbandwidth(A,1)[K]; V = view(A, Block.(K:K+L)
is already aColumnMajor
, soLazyArrays.lu!
should work. We therefore just need to go block-column-by-block-column, calllu!
, (which modifiesA
in place), then use this to update the columns to the right ofA
. - The last part is
lu(A)
, which needs to padA
by adding extra blocks above the diagonal to capture the fill-in.
from blockbandedmatrices.jl.
Would the solver described in the following discourse post be useful for any of this?
from blockbandedmatrices.jl.
I believe doing a hierarchical solver with block matrix inversion can be used to reduce the complexity from O(n^2)
to O(n^(3/2))
, where n
is the total number of unknowns. The right way to do this would be to leverage https://github.com/JuliaMatrices/HierarchicalMatrices.jl.
That said, the first step is a proper standard LU decomposition, which while it is O(n^2)
can easily leverage LAPack, and hence get multithreading for free, and for moderate n
would surely be much faster than hierarchical solvers. Performance testing would then guide how many levels to use in a hierarchical solver.
from blockbandedmatrices.jl.
Putting the hierarchical matrices aside, how exactly is the LU decomposition not leveraging LAPack?
Is this like a 2 line fix or something much deeper?
// also, this segue should have probably gone on BandedMatrices... sorry about that π¬
from blockbandedmatrices.jl.
Not two lines, I outlined what needs to be done above.
from blockbandedmatrices.jl.
from blockbandedmatrices.jl.
Oh, BandedMatrices.jl already has a fast LU using LAPack, so I'm not sure I understand the point of block inversion except for BlockBandedMatrices.jl
from blockbandedmatrices.jl.
This was two separate issues.
At first, I wanted a black-box solution to quickly solving A\b
using BandedBlockBanded matrices.
After realizing this wasn't possible, I setup my matrix so that it has 4 blocks:
submatrix | type |
---|---|
A | Banded |
B | Sparse |
C | Sparse |
D | Dense |
Then using blockwise inversion, I setup a package that should in theory quickly do this. However I'm not getting the speedup I thought I'd get.
That's why I posted to discourse and thought it might be related to this issue. Apologies again for the confusion.
from blockbandedmatrices.jl.
This is the sort of thing SparseMatrixCSC
excels at, as it automatically deduces the optimal pivoting strategy. Is there a reason sparse matrices won't work for you here?
from blockbandedmatrices.jl.
It seemed like you could get a win in the limit of A
becoming the whole matrix? Shouldn't a diagonal solver beat a sparse array solver (assuming narrow bands)?
from blockbandedmatrices.jl.
For a well-conditioned banded matrix, UMFPack is almost as fast as LAPack, especially with OpenBLAS which has very slow banded solvers. My blog post https://approximatelyfunctioning.blogspot.com/2018/12/banded-matrices-and-ordinary.html gives some timing examples but these are with MKL. But even if you get a 4x speedup using a banded solver, that gain will probably be lost in a blockwise inversion.
from blockbandedmatrices.jl.
Can't it be done for BlockTridiagonalMatrix
first? There should be an analytical formula
from blockbandedmatrices.jl.
For example, for BlockTridiagonalMatrix
, the LU decomposition is known analytically. The issue is that the block of the decomposition could be dense whereas, in principle, we only need to store their action. I was thinking about using LazyArrays
for this. Would you recommand something else?
from blockbandedmatrices.jl.
Are you imagining an increasingly complicated operator tree? I don't think that's viable, and if it is LazyArrays.jl won't help since it templates the arguments, meaning having complicated operator trees requires excessive compiling.
For BlockTridiagonalMatrix
you wouldn't want this anyways since the blocks are dense, so its possible to do the linear algebra directly.
from blockbandedmatrices.jl.
My blocks are 1000 x 1000 so I am not sure I want to fill them in with a LU decomposition. Also the matrice A
is from a 5 points finite differences approximations, a bit like your Laplacian example but not homogenous. I was thinking about gauss seidel, but it is tranpose(A)
which is diagonally dominant, so the convergence is slow.
from blockbandedmatrices.jl.
I forgot to say that you were right, this is what I intended to do until I read your answer...
from blockbandedmatrices.jl.
Do you need to calculate the factorisation fast, or just invert systems fast? That is, are you using the same matrix with multiple right hand side?
The LU factors should be practically banded-block-banded (theyβll have exponential decay in the bands) so one option is to calculate the factorisation using dense LU and then compress the results.
But really this is a case where iterative methods are the go to solution.
from blockbandedmatrices.jl.
I need to invert systems fast. More precisely, I need to solve (I-A) \ rhs1
and (I-A/2) \ rhs2
. Right now, I am doing this with SparseArrays
: one third of the time is spent to build A
and 2/3 of the time to solve the two equations.
I tried iterative methods but I dont have a good preconditioner. The convergence is way too slow.
from blockbandedmatrices.jl.
Right. What you are asking for may not currently be possible. I don't think hierarchical solvers will help much here either as the involve dense inverses, that is, for an n^2 x n^2
matrix we need to invert log(n)
matrices of size n x n
. After this inverse is calculated it can be compressed. So usually they are only used when the same inverse is reused multiple times.
I have some vague ideas on using the fact that the inverse of banded matrices is banded + semi-separable, hence can be represented using a small amount of memory and I believe form an algebra, but I don't have time to pursue this at the moment (I'm hoping for an interested student at some point).
from blockbandedmatrices.jl.
Related Issues (20)
- Banded block banded matrix with different bandwidths for the blocks HOT 3
- Can we implement more properties of BandedBlockBandedMatrix? HOT 4
- StackOverFlow Error HOT 4
- Unable to assign entries through BlockIndex HOT 2
- Addition/broadcasting type unstable with mixed block range types HOT 1
- How to convert BandedBlockBandedMatrix to BandedMatrix (and preserve what's left of the sparsity)? HOT 1
- BlockBandedMatrix should have extra entries so subblocks are banded
- Performance of `BandedBlockBandedMatrix` `Vector` Multiplication HOT 2
- Infinite dim. BandedBlockBandedMatrices interaction with Symmetric() broken? HOT 2
- Make some of this package an extension in BlockArrays.jl
- A minor typo on homepage
- Performances of mul!(x, transpose(B), y) HOT 2
- Precompilation failure in mybinder.org HOT 3
- Incompatible with spy HOT 3
- 0.7 HOT 1
- Adding diagonal matrix to BlockBandedMatrix/BlockSkylineMatrix yields dense BlockArray HOT 1
- Constructors from Kronecker Products? HOT 9
- Update constructor docs HOT 1
- view(A,Block(K,K))[band(0)] = ... syntax not working HOT 2
- TagBot trigger issue HOT 41
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blockbandedmatrices.jl.