1      subroutine cgbdi(abd,lda,n,ml,mu,ipvt,det)
2      integer lda,n,ml,mu,ipvt(1)
3      complex abd(lda,1),det(2)
4c
5c     cgbdi computes the determinant of a band matrix
6c     using the factors computed by cgbco or cgbfa.
7c     if the inverse is needed, use cgbsl  n  times.
8c
9c     on entry
10c
11c        abd     complex(lda, n)
12c                the output from cgbco or cgbfa.
13c
14c        lda     integer
15c                the leading dimension of the array  abd .
16c
17c        n       integer
18c                the order of the original matrix.
19c
20c        ml      integer
21c                number of diagonals below the main diagonal.
22c
23c        mu      integer
24c                number of diagonals above the main diagonal.
25c
26c        ipvt    integer(n)
27c                the pivot vector from cgbco or cgbfa.
28c
29c     on return
30c
31c        det     complex(2)
32c                determinant of original matrix.
33c                determinant = det(1) * 10.0**det(2)
34c                with  1.0 .le. cabs1(det(1)) .lt. 10.0
35c                or  det(1) = 0.0 .
36c
37c     linpack. this version dated 08/14/78 .
38c     cleve moler, university of new mexico, argonne national lab.
39c
40c     subroutines and functions
41c
42c     fortran abs,aimag,cmplx,real
43c
44c     internal variables
45c
46      real ten
47      integer i,m
48c
49      complex zdum
50      real cabs1
51      cabs1(zdum) = abs(real(zdum)) + abs(aimag(zdum))
52c
53      m = ml + mu + 1
54      det(1) = (1.0e0,0.0e0)
55      det(2) = (0.0e0,0.0e0)
56      ten = 10.0e0
57      do 50 i = 1, n
58         if (ipvt(i) .ne. i) det(1) = -det(1)
59         det(1) = abd(m,i)*det(1)
60c     ...exit
61         if (cabs1(det(1)) .eq. 0.0e0) go to 60
62   10    if (cabs1(det(1)) .ge. 1.0e0) go to 20
63            det(1) = cmplx(ten,0.0e0)*det(1)
64            det(2) = det(2) - (1.0e0,0.0e0)
65         go to 10
66   20    continue
67   30    if (cabs1(det(1)) .lt. ten) go to 40
68            det(1) = det(1)/cmplx(ten,0.0e0)
69            det(2) = det(2) + (1.0e0,0.0e0)
70         go to 30
71   40    continue
72   50 continue
73   60 continue
74      return
75      end
76