Cyclic-banded-matrix is fortran 90+ source code for solving cyclic/periodic square matrices. The algorithm is detailed in band_matrix.pdf
I have not found any previous version of this algorithm and it is entirely my derivation. If I have reinvented the wheel, there being nothing new under the sun, it would be interesting to see the previous attribution.
The error rate increases more rapidly with N than an LU decomposition, but is O(N*KU) in speed. The matrix needs to be diagonally dominant.
Two routines are included, dctsv.f90 which solves periodic tridiagonal systems, and dcbsv.f90, which solves general banded periodic matrices. They are written to be reasonably easily incorporated into code using LAPACK (Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.November 2006) and the interfaces have been deliberately made as compatible as possible with their non-cyclic LAPACK counterparts dgbsv.f and dgtsv.f Both use XERBLA error reporting and require linking with LAPACK & BLAS.
Removing XERBLA from dctsv.f90 removes the LAPACK/BLAS dependency, and is provided as dctsv_nolapack.f90
Substitution of intrinsic Fortran array operators instead of LAPACK & BLAS calls and substitution of LAPACK's dgesv.f & dgetr(fsi).f by another suitable general matrix solver with inversion (e.g. the included gauss-jordan.f90) is provided as dcbsv_nolapack.f90
A fortran 90 module LapackInterface.f90 is included for compatibility with FORTRAN 77. Note that the module only needs to be compiled once and is only needed for LAPACK/BLAS compatibility.
A simple test program is included,
Using gfortran
gfortran -c LapackInterface.f90
gfortran testme.f90 dctsv.f90 dcbsv.f90 gauss-jordan.f90 -llapack -lblas
or
gfortran testme.f90 LapackInterface.f90 dctsv.f90 dcbsv.f90 gauss-jordan.f90 -llapack -lblas
or (after commenting out dgesv in testme.f90 line 37)
gfortran testme.f90 dctsv.f90 dcbsv.f90 gauss-jordan.f90
./a.out
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.