2
SUBROUTINE SGEDI (A, LDA, N, IPVT, DET, WORK, JOB)
3
C***BEGIN PROLOGUE SGEDI
4
C***PURPOSE Compute the determinant and inverse of a matrix using the
5
C factors computed by SGECO or SGEFA.
6
C***LIBRARY SLATEC (LINPACK)
7
C***CATEGORY D2A1, D3A1
8
C***TYPE SINGLE PRECISION (SGEDI-S, DGEDI-D, CGEDI-C)
9
C***KEYWORDS DETERMINANT, INVERSE, LINEAR ALGEBRA, LINPACK, MATRIX
10
C***AUTHOR Moler, C. B., (U. of New Mexico)
13
C SGEDI computes the determinant and inverse of a matrix
14
C using the factors computed by SGECO or SGEFA.
19
C the output from SGECO or SGEFA.
22
C the leading dimension of the array A .
25
C the order of the matrix A .
28
C the pivot vector from SGECO or SGEFA.
31
C work vector. Contents destroyed.
34
C = 11 both determinant and inverse.
36
C = 10 determinant only.
40
C A inverse of original matrix if requested.
41
C Otherwise unchanged.
44
C determinant of original matrix if requested.
45
C Otherwise not referenced.
46
C Determinant = DET(1) * 10.0**DET(2)
47
C with 1.0 .LE. ABS(DET(1)) .LT. 10.0
48
C or DET(1) .EQ. 0.0 .
52
C A division by zero will occur if the input factor contains
53
C a zero on the diagonal and the inverse is requested.
54
C It will not occur if the subroutines are called correctly
55
C and if SGECO has set RCOND .GT. 0.0 or SGEFA has set
58
C***REFERENCES J. J. Dongarra, J. R. Bunch, C. B. Moler, and G. W.
59
C Stewart, LINPACK Users' Guide, SIAM, 1979.
60
C***ROUTINES CALLED SAXPY, SSCAL, SSWAP
61
C***REVISION HISTORY (YYMMDD)
63
C 890831 Modified array declarations. (WRB)
64
C 890831 REVISION DATE from Version 3.2
65
C 891214 Prologue converted to Version 4.0 format. (BAB)
66
C 900326 Removed duplicate information from DESCRIPTION section.
68
C 920501 Reformatted the REFERENCES section. (WRB)
69
C***END PROLOGUE SGEDI
70
INTEGER LDA,N,IPVT(*),JOB
71
REAL A(LDA,*),DET(2),WORK(*)
75
INTEGER I,J,K,KB,KP1,L,NM1
76
C***FIRST EXECUTABLE STATEMENT SGEDI
80
IF (JOB/10 .EQ. 0) GO TO 70
85
IF (IPVT(I) .NE. I) DET(1) = -DET(1)
86
DET(1) = A(I,I)*DET(1)
87
IF (DET(1) .EQ. 0.0E0) GO TO 60
88
10 IF (ABS(DET(1)) .GE. 1.0E0) GO TO 20
90
DET(2) = DET(2) - 1.0E0
93
30 IF (ABS(DET(1)) .LT. TEN) GO TO 40
95
DET(2) = DET(2) + 1.0E0
104
IF (MOD(JOB,10) .EQ. 0) GO TO 150
106
A(K,K) = 1.0E0/A(K,K)
108
CALL SSCAL(K-1,T,A(1,K),1)
110
IF (N .LT. KP1) GO TO 90
114
CALL SAXPY(K,T,A(1,K),1,A(1,J),1)
119
C FORM INVERSE(U)*INVERSE(L)
122
IF (NM1 .LT. 1) GO TO 140
132
CALL SAXPY(N,T,A(1,J),1,A(1,K),1)
135
IF (L .NE. K) CALL SSWAP(N,A(1,K),1,A(1,L),1)