# Way to speed up a 2x2 block matrix solver?

**URL:** <https://discourse.julialang.org/t/way-to-speed-up-a-2x2-block-matrix-solver/20628>\
**Category:** Performance\
**Tags:** package\
**Created:** [February 10, 2019, 7:31pm UTC](https://discourse.julialang.org/t/way-to-speed-up-a-2x2-block-matrix-solver/20628 "2019-02-10T19:31:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![djsegal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/djsegal/32/13752_2.png) [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Post date:** [February 10, 2019, 7:31pm UTC](https://discourse.julialang.org/t/way-to-speed-up-a-2x2-block-matrix-solver/20628/1 "2019-02-10T19:31:33Z")

</div>

Hi All,

So I made a [package](https://github.com/djsegal/BlockwiseInversion.jl) that solves a 2x2 block system, according to:

> **[Invertible matrix | Blockwise inversion](https://en.wikipedia.org/wiki/Invertible_matrix#Blockwise_inversion)**
>
> Matrices can also be inverted blockwise by using the following analytic inversion formula:

This assumes that you have some matrix that is predominantly banded.

* * *

Using BandedMatrix.jl, I tried to take a crack at optimizing the solver for such a system.

Could you guys take a look at it and point out any obvious efficiency errors?

The main files to look at are:

- [`FourBlockMatrix` struct](https://github.com/djsegal/BlockwiseInversion.jl/blob/master/src/four_block_matrix.jl)
- [`ldiv` method](https://github.com/djsegal/BlockwiseInversion.jl/blob/master/src/ldiv.jl)
- [`runtests` file](https://github.com/djsegal/BlockwiseInversion.jl/blob/master/test/runtests.jl)

// the use case is a 2-D finite difference where I put all the boundary points at the end of a matrix

(edit: may also be related to BlockBandedMatrices issue [#23](https://github.com/JuliaMatrices/BlockBandedMatrices.jl/issues/23))
