C      ________________________________________________________
C     |                                                        |
C     |COMPUTE DETERMINANT OF A GENERAL COMPLEX FACTORED MATRIX|
C     |                                                        |
C     |    INPUT:                                              |
C     |                                                        |
C     |         A     -CFACT'S OUTPUT                          |
C     |                                                        |
C     |    OUTPUT:                                             |
C     |                                                        |
C     |         CDET,E --DETERMINANT IS CDET*10.**E (E INTEGER)|
C     |                                                        |
C     |    BUILTIN FUNCTIONS: ALOG10,CABS,DLOG10,INT           |
C     |________________________________________________________|
C
      COMPLEX FUNCTION CDET(E,A)
      COMPLEX A(1),D
      REAL F,G
      DOUBLE PRECISION C
      INTEGER E,H,I,J,K,L,M,N,O
      I = INT(A(1))
      IF ( IABS(I) .EQ. 1239 ) GOTO 10
      WRITE(6,*) 'ERROR: MUST FACTOR BEFORE COMPUTING DETERMINANT'
      STOP
10    E = 0
      IF ( I .LT. 0. ) GOTO 70
      N = INT(A(2))
      IF ( N .EQ. 1 ) GOTO 80
      D = 1.
      F = 2.**64
      G = 1./F
      H = 64
      M = N + 1
      J = 0
      K = 4
      L = 3 - M + M*N
      DO 40 I = K,L,M
           J = J + 1
           O = INT(A(I))
           IF ( O .GT. J ) D = -D
           D = D*A(I+J)
20         IF ( CABS(D) .LT. F ) GOTO 30
           E = E + H
           D = D*G
           GOTO 20
30         IF ( CABS(D) .GT. G ) GOTO 40
           E = E - H
           D = D*F
           GOTO 30
40    CONTINUE
      D = D*A(L+M)
      IF ( E .NE. 0 ) GOTO 50
      CDET = D
      RETURN
50    IF ( CABS(D) .EQ. 0. ) GOTO 90
      C = ALOG10(CABS(D)) + E*DLOG10(2.D0)
      E = C
      C = C - E
      IF ( C .LE. 0.D0 ) GOTO 60
      C = C - 1
      E = E + 1
60    F = 10.**C
      D = F*(D/CABS(D))
      CDET = D
      RETURN
70    CDET = 0.
      RETURN
80    CDET = A(5)
      RETURN
90    E = 0
      GOTO 70
      END