Previous Next Contents Generated Index Doc Set Home



Determinant and Inverse of an LU-Factored General Matrix

The subroutines described in this section compute the determinant and inverse of a general matrix A, which has been LU-factored by xGECO or xGEFA.

Calling Sequence

CALL DGEDI 
(DA, LDA, N, IPIVOT, DDET, DWORK, JOB)
CALL SGEDI 
(SA, LDA, N, IPIVOT, SDET, SWORK, JOB)
CALL ZGEDI 
(ZA, LDA, N, IPIVOT, ZDET, ZWORK, JOB)
CALL CGEDI 
(CA, LDA, N, IPIVOT, CDET, CWORK, JOB)






void dgedi 
(double *da, int lda, int n, int *ipivot, double *ddet, 
int job)
void sgedi 
(float *sa, int lda, int n, int *ipivot, float *sdet, 
int job)
void zgedi 
(doublecomplex *za, int lda, int n, int *ipivot, 
doublecomplex *zdet, int job)
void cgedi 
(complex *ca, int lda, int n, int *ipivot, complex 
*cdet, int job)

Arguments

xA

On entry, the LU factorization of the matrix A, as computed by xGECO or xGEFA.
On exit, the inverse of the original matrix A if the inverse was requested, otherwise it is unchanged.

LDA

Leading dimension of the array A as specified in a dimension or type statement. LDA max(1,N).

N

Order of the original matrix A. N 0.

IPIVOT

Pivot vector as computed by xGECO or xGEFA.

xDET

On exit, the determinant of the matrix A. The determinant is stored as b × 10expon where b is stored in DET(1) and expon is stored in DET(2). 1.0 |DET(1)| < 10.0 or DET(1) = 0.0.

xWORK

Scratch array with a dimension of N.

JOB

Determines which operation the subroutine will perform:

11

both determinant and inverse

01

inverse only

10

determinant only

Sample Program

 
      PROGRAM TEST
      IMPLICIT NONE
C
      INTEGER           INVDET, LDA, N
      PARAMETER        (INVDET = 11)
      PARAMETER        (N = 4)
      PARAMETER        (LDA = N)
C
      DOUBLE PRECISION  A(LDA,N), DET(2), RCOND, WORK(N)
      INTEGER           ICOL, IPIVOT(N), IROW, JOB
C
      EXTERNAL          DGECO, DGEDI
C
C     Initialize the array A to store the matrix A shown below. 
C     Its exact inverse also is shown below.
C
C         -3   1                         1    1  1  1  1
C     A =  1  -2   1        A**(-1) = - --- * 1  3  3  3
C              1  -2   1                 2    1  3  5  5
C                  1  -1                      1  3  5  7
C
      DATA A / -3.0D0, 1.0D0, 2*0.0D0, 1.0D0, -2.0D0, 1.0D0, 
     $        2*0.0D0, 1.0D0, -2.0D0, 1.0D0, 2*0.0D0, 1.0D0, 
     $         -1.0D0 /
C
      PRINT 1000
      PRINT 1010, ((A(IROW,ICOL), ICOL = 1, N), IROW = 1, N)
      CALL DGECO (A, LDA, N, IPIVOT, RCOND, WORK)
      JOB = INVDET
      CALL DGEDI (A, LDA, N, IPIVOT, DET, WORK, JOB)
      PRINT 1020
      PRINT 1010, ((A(IROW,ICOL), ICOL = 1, N), IROW = 1, N)
      PRINT 1030, DET(1) * (1.0D1 ** DET(2))
C
 1000 FORMAT (1X, 'A:')
 1010 FORMAT (4(3X, F5.1))
 1020 FORMAT (/1X, 'A**(-1):')
 1030 FORMAT (/1X, 'det(A) =', F6.1)
C
      END
 

Sample Output

 
 A:
    -3.0     1.0     0.0     0.0
     1.0    -2.0     1.0     0.0
     0.0     1.0    -2.0     1.0
     0.0     0.0     1.0    -1.0



 A**(-1):
    -0.5    -0.5    -0.5    -0.5
    -0.5    -1.5    -1.5    -1.5
    -0.5    -1.5    -2.5    -2.5
    -0.5    -1.5    -2.5    -3.5



 det(A) =   2.0






Previous Next Contents Generated Index Doc Set Home