2 SUBROUTINE DGESL
(A
, LDA
, N
, IPVT
, B
, JOB
)
3 C***BEGIN PROLOGUE DGESL
4 C***PURPOSE Solve the real system A*X=B or TRANS(A)*X=B using the
5 C factors computed by DGECO or DGEFA.
7 C***TYPE DOUBLE PRECISION (SGESL-S, DGESL-D, CGESL-C)
8 C***KEYWORDS LINEAR ALGEBRA, LINPACK, MATRIX, SOLVE
9 C***AUTHOR Moler, C. B., (U. of New Mexico)
12 C DGESL solves the double precision system
13 C A * X = B or TRANS(A) * X = B
14 C using the factors computed by DGECO or DGEFA.
18 C A DOUBLE PRECISION(LDA, N)
19 C the output from DGECO or DGEFA.
22 C the leading dimension of the array A .
25 C the order of the matrix A .
28 C the pivot vector from DGECO or DGEFA.
30 C B DOUBLE PRECISION(N)
31 C the right hand side vector.
34 C = 0 to solve A*X = B ,
35 C = nonzero to solve TRANS(A)*X = B where
36 C TRANS(A) is the transpose.
40 C B the solution vector X .
44 C A division by zero will occur if the input factor contains a
45 C zero on the diagonal. Technically this indicates singularity
46 C but it is often caused by improper arguments or improper
47 C setting of LDA . It will not occur if the subroutines are
48 C called correctly and if DGECO has set RCOND .GT. 0.0
49 C or DGEFA has set INFO .EQ. 0 .
51 C To compute INVERSE(A) * C where C is a matrix
53 C CALL DGECO(A,LDA,N,IPVT,RCOND,Z)
54 C IF (RCOND is too small) GO TO ...
56 C CALL DGESL(A,LDA,N,IPVT,C(1,J),0)
59 C***REFERENCES J. J. Dongarra, J. R. Bunch, C. B. Moler, and G. W.
60 C Stewart, LINPACK Users' Guide, SIAM, 1979.
61 C***ROUTINES CALLED DAXPY, DDOT
62 C***REVISION HISTORY (YYMMDD)
64 C 890831 Modified array declarations. (WRB)
65 C 890831 REVISION DATE from Version 3.2
66 C 891214 Prologue converted to Version 4.0 format. (BAB)
67 C 900326 Removed duplicate information from DESCRIPTION section.
69 C 920501 Reformatted the REFERENCES section. (WRB)
70 C***END PROLOGUE DGESL
71 INTEGER LDA
,N
,IPVT
(*),JOB
72 DOUBLE PRECISION A
(LDA
,*),B
(*)
74 DOUBLE PRECISION DDOT
,T
76 C***FIRST EXECUTABLE STATEMENT DGESL
78 IF (JOB
.NE
. 0) GO TO 50
80 C JOB = 0 , SOLVE A * X = B
83 IF (NM1
.LT
. 1) GO TO 30
87 IF (L
.EQ
. K
) GO TO 10
91 CALL DAXPY
(N
-K
,T
,A
(K
+1,K
),1,B
(K
+1),1)
101 CALL DAXPY
(K
-1,T
,A
(1,K
),1,B
(1),1)
106 C JOB = NONZERO, SOLVE TRANS(A) * X = B
107 C FIRST SOLVE TRANS(U)*Y = B
110 T
= DDOT
(K
-1,A
(1,K
),1,B
(1),1)
111 B
(K
) = (B
(K
) - T
)/A
(K
,K
)
114 C NOW SOLVE TRANS(L)*X = Y
116 IF (NM1
.LT
. 1) GO TO 90
119 B
(K
) = B
(K
) + DDOT
(N
-K
,A
(K
+1,K
),1,B
(K
+1),1)
121 IF (L
.EQ
. K
) GO TO 70