gls : An algorithm for solving a general linear system of equations

The gls algorithm is useful for solving the general linear system of equations that arise in the direct boundary element method with the most general boundary conditions. The system of equations has the form


where A and B are n×n matrices, c is a known n-vector and x and y are the unknown n-vectors that are to be found. The individual components of x and y are also related by a set of n equations of the form

αi xi+ βi yi=fi for i=1..n or αTx+βTy=f .

The gls algorithm works through rearranging the system to place it in standard form and then calls the standard method of LU factorisation and hence the solution is an O(n3) operation. A further algorithm regls is included, this allows a change in the vectors f and/or c and re-use information from gls in order to compute additional solutions in O(n2) time.

The gls algorithm is implemented on three platforms - Matlab, Excel-VBA and Fortran. In Matlab the same codes can be used for real- or complex-valued problems, in Fortran different codes are available for real- and complex-valued problems and in Excel-VBA only real-valued problems are covered. Test codes are also available and these can be downloaded and run to build confidence in the software. The Matlab codes are also applied to a simple boundary element problem of solving Laplace's equation interior to a unit square, demontrating the gls algorithm in an application. Further information on the gls algorithm can be found on the following link.

Matlab (Freemat/Octave/Scilab)

In Matlab the routines gls.m and regls.m are able to solve systems with real or complex values. The codes require LUfbsubs.m in order to carry out the forward and backward substitution. The routines gls_real_t.m and gls_complex_t.m test problems, finding solutions with real or complex values.

The gls.m and regls.m codes are tested in an implementation of the boundary element method for interior two-dimensional problems with a general Robin boundary condidtion. The test problem is that of the unit square with analytic solution φ=2(x2-y2). The codes required can be downloaded from . The codes required are the main test code interiorSquareTestRobin.m , and the functions lbem2.m , lbem2_on.m , l2lc.m , square_general.m , gls.m , regls.m , gl.m , vertices.m , dist.m , dotproduct.m , norm2.m , vector.m , svecsize.m , vecsize.m . More details on the test problems can be found on this guide.


In Fortran the routine GLS in GLS2.FOR and REGLS in REGLS.FOR are for real-valued problems and CGLS in CGLS2.FOR and CREGLS in CREGLS.FOR are for complex-valued problems.


In Excel-VBA, the codes gls.bas and regls.bas can be found on the Excel spreadsheet GLS.xlsm . The spreadsheet also contains typical test problems and guides are linked to the spreaddsheet.