setmat


setmat, a FORTRAN77 code which sets and gets matrix entries using a variety of matrix storage formats.

The code tries to allow the user to ignore as much as possible the actual storage method used for the matrix, so that storage saving methods such as band, border-band, or compressed storage can be used, and interesting things like Gauss elimination, printing out the matrix, or computing a jacobian, can be done.

The first thing to decide is the storage method to be used. The vector ISTORE contains some information about this, and in the compressed storage case, the array IA contains a great deal of information.

Recall that a matrix stored in the LINPACK band format is given a lower and upper bandwidth, ML and MU. Also, a border-banded matrix can be described as an N1 by N1 square banded matrix A, a full N1 by N2 strip B, a full N2 by N1 strip C, and a full storage N2 by N2 matrix D.

Dense, full storage matrix:

Set ISTORE(1)=0, dimension IA(1,1) but ignore it otherwise.

Banded, full storage matrix:

(all the zeroes are stored, but never referenced) set ISTORE(1)=1, ISTORE(2)=ML, ISTORE(3)=MU, set NROW.ge.NCOL. dimension IA(1,1) and ignore it otherwise. you can use the LINPACK routines sgefa/sgesl to solve linear systems.

Banded, LINPACK band storage matrix:

set ISTORE(1)=2, set ISTORE(2)=ML, set ISTORE(3)=MU, set NROW.ge.2*ML+MU+1 dimension IA(1,1) but ignore it otherwise. you may call sgbfa/sgbsl to solve linear systems.

Banded, LSODI band storage matrix:

set ISTORE(1)=3 set ISTORE(2)=ML set ISTORE(3)=MU set NROW.ge.ML+MU+1. dimension IA(1,1) but ignore it otherwise. Note that the only use for this format is when a user jacobian routine is called by LSODI. In such a case, LSODI passes the values of ML, MU, and NROW. Rather than try to add entries to the matrix yourself, you can call ADDMAT to do it for you, and avoid the messy calculation of indices.

Border-banded matrix:

For a border banded matrix, set ISTORE(1)=4, set ISTORE(2)=ML (lower band for matrix a) set ISTORE(3)=MU (upper band for matrix a) set ISTORE(4)=N1 (order of matrix a) set ISTORE(5)=N2 (order of matrix d) set NROW=1. it is your responsibility to set aside enough storage for the matrix A, namely, at least (2*ML+MU+1)*N1 + 2*N1*N2 + N2*N2. dimension IA(1,1) but ignore it otherwise. you can use the routines in bormat (sbbfa/sbbsl) to solve linear systems involving this matrix.

Compressed storage matrix:

for a compressed storage matrix, set ISTORE(1)=5, set NROW as the row dimension of the array IA, as declared in the routine where values are put into IA. that is, normally, set NROW to the first dimension of IA. of course, NROW must be at least large enough to store all the nonzero entries in any row. set the array IA(NROW,NCOL), where for a fixed equation J, IA(I,J)=0 except that every column K in which a nonzero occurs should be an entry of IA. Thus, if equation 4 has nonzero entries in A(1,4), A(17,4) and A(33,4), set IA(1,4)=1, IA(2,4)=17, IA(3,4)=33 and IA(*,4) to 0 for any entries greater than the third. Normally, this mode could only be used with a Gauss-Seidel or Jacobi routine for solving linear systems, but care must be taken to insure that the matrix is suitable for such an iteration. For example, a positive definite symmetric matrix would be acceptable.

Licensing:

The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.

Languages:

setmat is available in a FORTRAN77 version.

Related Data and Programs:

setmat_test

LINPACK, a FORTRAN77 library which is a linear algebra library.

LINPLUS, a FORTRAN90 library which carries out simple manipulations of matrices in a variety of formats.

Source Code:


Last revised on 16 October 2023.