Open eschnett opened 2 years ago
Yes please! I believe the issue is that LU is currently only implemented in LAPACK so a Julia native implementation would be fantastic
I've looked at the code for LU decomposition in BandedMatrices.jl
, and it's not clear to me which part of the code would need to stay and which part should be rewritten. It seems that some LU decomposition functionality is there, but it's not implemented in an ideal way – e.g. it seems the L
factor is full instead of banded.
BandedLU
necessary? It seems that the Base LU
type would suffice.lu!
states "l of the bands are ignored and overwritten". That seems weird. The problem seems to be that the LAPACK function dgbsv
allows (and here requires) over-allocating storage, which is not supported by this package. If there is no functionality to resize banded matrices without de-allocating storage, then filling the extra bands with zeros might be a good approach?I suggest you read the docs on LAPACK's gbtrf:
Is the type BandedLU necessary? It seems that the Base LU type would suffice.
Yes since gbtrf
does not actually permute the rows in memory (as that would destroy banded structure), instead it just records where the pivots were. So it's not the same format as LinearAlgebra.LU
.
Should the pivot search remain? A pivot search destroys the band structure. One could remove it, and ask people to convert to a full matrix if they want a pivot search.
Yes because you maintain bandedness if you do what LAPACK does.
I am interested in supporting types that are not supported by LAPACK. Would it make sense to remove the calls to LAPACK, implementing the respective functions in Julia?
No, still use LAPACK for BLAS types. Only use the Julia implementation for general types. You can use BigFloat
as a test.
A comment in the function lu! states "l of the bands are ignored and overwritten". That seems weird. The problem seems to be that the LAPACK function dgbsv allows (and here requires) over-allocating storage, which is not supported by this package. If there is no functionality to resize banded matrices without de-allocating storage, then filling the extra bands with zeros might be a good approach?
I don't agree: we do allow overallocating storage, e.g., if the data
is a (strided) view of a bigger array.
Hi, FYI: I did some similar job for dgemm etc in sparspak: https://github.com/PetrKryslUCSD/Sparspak.jl/blob/main/src/Utilities/GenericBlasLapackFragments.jl
This was based on the netlib fortran code.
I needed to invert large banded matrices, and I found that BandedMatrices.jl didn't support this operation. For example:
This uses a full matrix to store
L
, which is not good for me.Similarly, when using rational numbers, I found that
I have taken the liberty of implementing the functionality that I need outside of BandedMatrices.jl. See here for the functions I implemented.
The respective functionality is good enough for me, but is not quite generic. For example, I implemented
\
to solve a linear system, but not an in-placeldiv!
. These functions also don't support a banded RHS for\
.I would be happy to contribute this to
BandedMatrices.jl
. If you are interested, then please let me know how this could/should be integrated into your package. Otherwise, feel free to copy the code I wrote. This code is inspired (copied/translated) from Wikipedia (see the URL above), LAPACK (dtrsm), and the Julia LinearAlgebra package.