next up previous index
Next: F011 Repeated Solution Up: CERNLIB Previous: F004 Matrix Multiplication

F010 Linear Equations, Matrix Inversion

Routine ID: F010
Author(s): G.A. ErskineLibrary: KERNLIB
Submitter: Submitted: 18.12.1979
Language: FortranRevised: 27.11.1984

Subroutine tEQN (where t=R , D or C as described below) solves the matrix equation

AX=B,&sp;(*)

which represents a system of N simultaneous linear equations with K right-hand sides:

j=1Naijxjk=bik,&sp;(i=1,2,...,N, k=1,2,...,K).

Subroutine tINV computes the inverse of a square matrix A. Subroutine tEQINV solves the system (*) and also computes the inverse of A, but is appreciably slower than tEQN.

If the determinant of A is also required, or if several systems of the form (*) are to be solved sequentially with the same coefficient matrix A but differing right-hand sides B, the subroutines in RFACT (F011) should be used.

Structure:

SUBROUTINE subprograms
User Entry Names: RINV, REQN, REQINV, DINV, DEQN, DEQINV, CINV, CEQN, CEQINV
Internal Entry Names: F010PR
Files Refeenced: Printer
External References: RFACT, RFEQN, RFINV, DFACT, DFEQN, DFINV, CFACT, CFEQN, CFINV,
TMPRNT (F011), KERMTR (N001), ABEND (Z035)

Usage:

For t=R (type REAL), t=D (type DOUBLE PRECISION), t=C (type COMPLEX):

    CALL tEQN  (N,A,IDIM,IR,IFAIL,K,B)
    CALL tINV  (N,A,IDIM,IR,IFAIL)
    CALL tEQINV(N,A,IDIM,IR,IFAIL,K,B)
N
( INTEGER) Order of the square matrix A.
A
(Type according to t) Two-dimensional array whose first dimension has the value IDIM.
IDIM
( INTEGER) First dimension of array A (and of array B if K > 1 ).
IR
( INTEGER) Array of at least N elements, required as working space.
IFAIL
( INTEGER) On exit, IFAIL will be set to -1 if A is found to be singular, and to 0 otherwise. (Singularity will often go undetected because of rounding errors during factorization even if the elements of A have integral values.)
K
( INTEGER) Number of columns of the matrices B and X.
B
(Type according to t) In general, a two-dimensional array whose first dimension has the value IDIM. B may be one-dimensional if K = 1 .
These subroutines must be called with matrix A in array A and matrix B in array B. Then, provided the matrix A is non-singular, IFAIL will be set to 0 and arrays A and B will be set as follows:
tEQN
The solution X replaces B. The matrix A is destroyed.
tINV
The inverse A-1 of A replaces A.
tEQINV
The solution X replaces B, and the inverse A-1 of A replaces A.
If the matrix A is singular, IFAIL will be set to -1 . In this case the contents of A is unpredictable and the contents of B is unchanged.

Method:

Triangular factorization with row interchanges, implemented by in-line code if N ≤3 and by calls to library program RFACT (F011) if N > 3 . If N<1 or IDIM<N or K < 1 , a message is printed and program execution is terminated by calling ABEND (Z035).

Examples:

Assume that the 10 x10 matrix A and the 10 x3

matrix B are stored according to the Fortran convention in arrays A and B respectively of a program containing declarations

    DIMENSION IR(25)
    DOUBLE PRECISION A(25,30),B(25,10)
To replace B by the 10 x3 solution matrix X of the system of equations AX=B and to replace A by A-1 , with a jump to label 100 if A is singular:
    CALL DEQINV (10,A,25,IR,IFAIL,3,B)
    IF(IFAIL .NE. 0) GO TO 100

F011



next up previous index
Next: F011 Repeated Solution Up: CERNLIB Previous: F004 Matrix Multiplication


Janne Saarela
Mon Apr 3 15:06:23 METDST 1995