ADAS Subroutine xxminv
SUBROUTINE XXMINV( LSOLVE , NDMAX , NDIM , & A , B , DINT & ) C----------------------------------------------------------------------- C C ****************** FORTRAN77 SUBROUTINE: XXMINV ********************* C C PURPOSE: MATRIX INVERSION WITH ACCOMPANYING SOLUTION OF LINEAR C EQUATIONS IF REQUESTED. C C C CALLING PROGRAM: GENERAL USE C C C SUBROUTINE: C C INPUT : (L*4) LSOLVE = .TRUE. => SOLVES SET OF 'N' LINEAR C EQUATIONS A.X = B, WHERE A,X,B C ARE MATRICES/VECTORS AND: C A = 'A(,)' ON INPUT C X = 'B()' ON OUTPUT C B = 'B()' ON INPUT C .FALSE. => DOES NOT SOLVE ANY EQUATIONS C AND 'B()' IS NOT USED. C C INPUT : (I*4) NDMAX = MAXIMUM VALUE OF 'N' ALLOWED. I.E. C PHYSICAL DIMENSION OF INPUT MATRICES. C INPUT : (I*4) NDIM = DIMENSIONALITY 'N' OF MATRIX/EQUATIONS C TO BE SOLVED. C C I/O : (R*8) A(,) = 'N' BY 'N' MATRIX C INPUT : MATRIX TO BE INVERTED C OUTPUT: INVERTED MATRIX C I/O : (R*8) B() = USED ONLY IF 'LSOLVE=.TRUE.'WHEN THE SET C OF 'N' LINEAR EQUATIONS ARE TO BE SOLVED. C A.X = B C INPUT : RIGHT HAND SIDE VECTOR 'B' C OUTPUT: SOLUTION VECTOR 'X' C C OUTPUT: (R*8) DINT = +1 OR -1 DEPENDING ON WHETHER THE NUMBER C OF ROW INTERCHANGES WAS EVEN OR ODD, C RESPECTIVELY. C C (I*4) NLMAX = PARAMETER: MUST BE >= 'NDMAX' C C (I*4) LROW = ROW OF INPUT 'A(*,)' CONTAINING LARGEST C NON-ZERO ELEMENT. C (I*4) LCOLUM = COLUMN OF INPUT 'A(,*)' CONTAINING LARGEST C NON-ZERO ELEMENT. C 'LROW' & 'LCOLUM' => PIVOT POSITION IN A(,) C (I*4) I1 = ARRAY INDICES: 1ST LEVEL C (I*4) I2 = ARRAY INDICES: 2ND LEVEL C (I*4) I3 = ARRAY INDICES: 3RD LEVEL C C (R*8) DMAX = LARGEST NON-ZERO ELEMENT OF 'A(,)', C AND EQUALS 'ABS(A(LROW,LCOLUM))' C (R*8) SWAP = TEMPORARAY STORAGE WHEN INTERCHANGING C ROWS/COLUMNS. C (R*8) TVAL = TEMPORARY STORAGE OF VALUES IN NON-PIVOT C ROWS. C C (I*4) IPIVOT() = NUMBER OF TIMES PIVOT FOUND IN COLUMN C DIMENSION: COLUMN INDEX C (I*4) INDX(,1) = ROW OF PIVOT IN 'A(,)' C DIMENSION: PIVOT INDEX C (I*4) INDX(,2) = COLUMN OF PIVOT IN 'A(,)' C DIMENSION: PIVOT INDEX C C (R*8) PIVOT() = 'DMAX' FOR PIVOT: DIMENSION PIVOT INDEX C C C ROUTINES: NONE C C NOTE: THIS IS A STRUCTURED VERSION OF THE SUBROUTINE 'MATINV' WRITTEN C BY HUGH SUMMERS. C C AUTHOR: PAUL E. BRIDEN (TESSELLA SUPPORT SERVICES PLC) C K1/0/81 C JET EXT. 4569 C C DATE: 31/08/90 C C UPDATE: 15/05/92 - PE BRIDEN - INCREASED NLMAX FROM 50 -> 75 C C UPDATE: 26/06/92 - PE BRIDEN - INCREASED NLMAX FROM 75 -> 200 C C VERSION: 1.2 DATE: 04-05-2000 C MODIFIED: RICHARD MARTIN C CHANGED DOCUMENTATION FOR NDIM. C C VERSION : 1.3 C DATE : 20-12-2001 C MODIFIED : Martin O'Mullane C - Removed mainframe listing information beyond column 72. C C VERSION: 1.4 DATE: 02-03-2003 C MODIFIED: Martin O'Mullane & Allan Whiteford C - Increased NLMAX to 801 and improved error message. C C VERSION: 1.5 DATE: 29-05-2003 C MODIFIED: Martin O'Mullane C - Increased NLMAX to 1201. C C----------------------------------------------------------------------- C----------------------------------------------------------------------- INTEGER NDIM, NDMAX LOGICAL LSOLVE REAL*8 A(NDMAX,NDMAX), B(NDMAX), DINT