1
subroutine wgedi(ar,ai,lda,n,ipvt,detr,deti,workr,worki,job)
3
integer lda,n,ipvt(*),job
4
double precision ar(lda,*),ai(lda,*),detr(2),deti(2),workr(*),
8
c wgedi computes the determinant and inverse of a matrix
9
c using the factors computed by wgeco or wgefa.
13
c subroutine wgedi(ar,ai,lda,n,ipvt,detr,deti,workr,worki,job)
16
c a double-complex(lda, n)
17
c the output from wgeco or wgefa.
20
c the leading dimension of the array a .
23
c the order of the matrix a .
26
c the pivot vector from wgeco or wgefa.
28
c work double-complex(n)
29
c work vector. contents destroyed.
32
c = 11 both determinant and inverse.
34
c = 10 determinant only.
38
c a inverse of original matrix if requested.
39
c otherwise unchanged.
41
c det double-complex(2)
42
c determinant of original matrix if requested.
43
c otherwise not referenced.
44
c determinant = det(1) * 10.0**det(2)
45
c with 1.0 .le. cabs1(det(1) .lt. 10.0
46
c or det(1) .eq. 0.0 .
50
c a division by zero will occur if the input factor contains
51
c a zero on the diagonal and the inverse is requested.
52
c it will not occur if the subroutines are called correctly
53
c and if wgeco has set rcond .gt. 0.0 or wgefa has set
57
c linpack. this version dated 07/01/79 .
58
c cleve moler, university of new mexico, argonne national lab.
62
c blas waxpy,wscal,wswap
68
double precision tr,ti
70
integer i,j,k,kb,kp1,l,nm1
72
double precision zdumr,zdumi
73
double precision cabs1
74
cabs1(zdumr,zdumi) = abs(zdumr) + abs(zdumi)
78
if (job/10 .eq. 0) go to 80
85
if (ipvt(i) .eq. i) go to 10
89
call wmul(ar(i,i),ai(i,i),detr(1),deti(1),detr(1),deti(1))
92
if (cabs1(detr(1),deti(1)) .eq. 0.0d+0) go to 70
93
20 if (cabs1(detr(1),deti(1)) .ge. 1.0d+0) go to 30
96
detr(2) = detr(2) - 1.0d+0
97
deti(2) = deti(2) - 0.0d+0
100
40 if (cabs1(detr(1),deti(1)) .lt. ten) go to 50
101
detr(1) = detr(1)/ten
102
deti(1) = deti(1)/ten
103
detr(2) = detr(2) + 1.0d+0
104
deti(2) = deti(2) + 0.0d+0
113
if (mod(job,10) .eq. 0) go to 160
115
call wdiv(1.0d+0,0.0d+0,ar(k,k),ai(k,k),ar(k,k),ai(k,k))
118
call wscal(k-1,tr,ti,ar(1,k),ai(1,k),1)
120
if (n .lt. kp1) go to 100
126
call waxpy(k,tr,ti,ar(1,k),ai(1,k),1,ar(1,j),ai(1,j),1)
131
c form inverse(u)*inverse(l)
134
if (nm1 .lt. 1) go to 150
147
call waxpy(n,tr,ti,ar(1,j),ai(1,j),1,ar(1,k),ai(1,k),1)
151
* call wswap(n,ar(1,k),ai(1,k),1,ar(1,l),ai(1,l),1)