      SUBROUTINE EIGDET(N,M,B,LAMBDA)
C
C      PURPOSE : COMPUTE DETERMINANT OF B-LAMBDA*I COMPLEX MATRIX 
C
C      INPUT :  B - THE COMPLEX*16 MATRIX 
C               LAMBDA - EIGENVALUES
C               N - THE NUMBER OF COLUMNS ( NUMBER OF ROWS) USED
C               M - DIMENSION OF B
C
C      OUTPUT : DET - THE DETERMINANT OF THE ORIGIONAL MATRIX
C               SING - DEGREE OF SINGULARITY ( NOT IN DET )
C
C      METHOD : GAUSS / JORDAN  ELIMINATION USING MAXIMUM
C               PIVOTAL ELEMENT. USE OF DIVIDE IS MINIMIZED.
C               UNSCRAMBLING IS EFFICIENT AT THE EXPENSE OF
C               EXTRA STORAGE. DETERMINANT MAY HAVE WRONG SIGN.
C
C
      IMPLICIT NONE
      INTEGER I,J,K,M,N,ILAMBDA
      INTEGER IL
      COMPLEX*16 B(M,M)
      COMPLEX*16 LAMBDA(M)
      COMPLEX*16 A(20,20)
      COMPLEX*16 DET,LARGE
      INTEGER ROW(20)
      COMPLEX*16 TEMP(20)
      INTEGER MTEMP
      INTEGER SING
C
C            COPY B INTO A   SUBTRACTING LAMBDA FROM DIAGONAL
      DO 1 ILAMBDA=1,N
C
      DO 2 I=1,N
        DO 2 J=1,N
          A(I,J)=B(I,J)
          IF(I.EQ.J)THEN
              A(I,J) = A(I,J) - LAMBDA(ILAMBDA)
          END IF
2     CONTINUE
C
      SING = 0
      DET=(1.0D0,0.0D0)
      DO 6 K=1,N
        ROW(K)=K
6     CONTINUE
C
C                BEGIN MAIN REDUCTION LOOP ON  K
C
      DO 10 K=1,N
C
C          FIND LARGEST
C
        LARGE=A(ROW(K),K)
        IL=K
        DO 7 I=K+1,N
          IF(ABS(A(ROW(I),K)).GT.ABS(LARGE)) THEN
            IL=I
            LARGE=A(ROW(I),K)
          END IF
7       CONTINUE
        IF(IL.NE.K) THEN
          MTEMP=ROW(K)
          ROW(K)=ROW(IL)
          ROW(IL)=MTEMP
        END IF
C                        END MAX INTERCHANGE
C                     LARGE IS NOW THE  A(K,K) PIVOT
        IF(ABS(LARGE).GT.1.0E-4)THEN
          DET=DET*LARGE
        ELSE
          SING=SING+1
          GO TO 10
        END IF
        DO 11 J=K+1,N
            A(ROW(K),J)=A(ROW(K),J)/A(ROW(K),K)
11      CONTINUE
        DO 12 I=1,N
          IF( I.EQ.K ) GO TO 12
          DO 13 J=K+1,N
            A(ROW(I),J)=A(ROW(I),J)-A(ROW(I),K) * A(ROW(K),J)
13        CONTINUE
12      CONTINUE
10    CONTINUE
C
C                    END OF MAIN REDUCTION LOOP ON K
C
C        SHOULD BE SINGULAR IF EIGENVALUE CORRECT
      IF(SING.GT.0) THEN
         PRINT *, 'ILAMBDA=', ILAMBDA, LAMBDA(ILAMBDA),
     X            ' SINGULARITY=', SING
      ELSE
         PRINT *, 'ILAMBDA=', ILAMBDA, LAMBDA(ILAMBDA),
     X            ' SING   FAIL=', SING
         PRINT *, ' DETERMINANT = ',DET
      END IF
1     CONTINUE
      RETURN
      END
