https://github.com/briochemc/blockdiagonalfactors.jl
Factorize only the diagonal blocks and solve linear systems faster this way
https://github.com/briochemc/blockdiagonalfactors.jl
Last synced: 3 months ago
JSON representation
Factorize only the diagonal blocks and solve linear systems faster this way
- Host: GitHub
- URL: https://github.com/briochemc/blockdiagonalfactors.jl
- Owner: briochemc
- License: mit
- Created: 2019-05-30T05:16:02.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-02-08T22:53:43.000Z (over 5 years ago)
- Last Synced: 2024-10-12T10:30:02.844Z (7 months ago)
- Language: Julia
- Size: 13.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Citation: CITATION.bib
Awesome Lists containing this project
README
# BlockDiagonalFactors
This package allows you to solve linear systems of the type `M * x = b` where `M` is block diagonal (sparse or not).
It is particularly efficient if some of the blocks of `M` are repeated, because it will only compute the factorizations of these repeated objects once.### Usage
Consider the block-diagonal matrix
```julia
M = [A ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
⋅ A ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
⋅ ⋅ B ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ A ⋅ ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ ⋅ C ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ ⋅ ⋅ A ⋅ ⋅ ⋅
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ C ⋅ ⋅
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ B ⋅
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ A]
```Instead of creating that big matrix, factorizing it whole, or factorizing each block, you can create a `BlockFactors` or `SparseBlockFactors` object (depending if `A`, `B`, and `C` are sparse) via the following syntax
```julia
# Form an array of the matrices
Ms = [A, B, C]# and an array of "repetition" indices
indices = [1, 1, 2, 1, 3, 1, 3, 2, 1]# to create the Block Diagonal Factors (BDF) object
BDF = factorize(Ms, indices)
```This way `A`, `B`, and `C` are factorized only once.
Then, you can solve for linear system `M * x = b`
- via backslash (same as `M \ b`)```julia
x = BDF \ b
```- via the inplace (same as `ldiv!(M, b)`)
```julia
ldiv!(BDF, b)
```- or via the inplace (same as `ldiv!(x, M, b)`)
```julia
ldiv!(x, BDF, b)
```### How it works
The package simply creates two new types, `BlockFactors` or `SparseBlockFactors`, which look like
```julia
struct (Sparse)BlockFactors{Tv}
factors::Vector
indices::Vector{<:Int}
m::Int
n::Int
end
```
and overloads `factorize`, `lu`, and other factorization functions to create those objects from an array of matrices and the repeating indices.
In order to solve linear systems it also overloads `\` and `ldiv!`.
That's it!### Cite it!
If you use this package directly, please cite it!
Use the [CITATION.bib](./CITATION.bib), which contains a bibtex entry for the software (coming soon).