      SUBROUTINE LUDE(A,N,NP,INDX,D)
* 98  ----------------------------------------------------------*
      IMPLICIT    REAL*8 (A-H,O-Z)
      PARAMETER (NMAX=1500,TINY=1.0D-40)
      DIMENSION A(NP,NP),VV(NMAX),INDX(N)
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
      D=1.D 00
      DO 12 I=1,N
         AAMAX=0.D 00
         DO 11 J=1,N
            IF (ABS(A(I,J)).GT.AAMAX) AAMAX=ABS(A(I,J))
11          CONTINUE
         IF (AAMAX.EQ.0.D 00) PAUSE 'SINGULAR MATRIX IN LUDE'
         VV(I)=1.D 00/AAMAX
12       CONTINUE
      DO 19 J=1,N
         DO 14 I=1,J-1
            SUM=A(I,J)
            DO 13 K=1,I-1
               SUM=SUM-A(I,K)*A(K,J)
13             CONTINUE
            A(I,J)=SUM
14          CONTINUE
         AAMAX=0.D 00
         DO 16 I=J,N
            SUM=A(I,J)
            DO 15 K=1,J-1
               SUM=SUM-A(I,K)*A(K,J)
15             CONTINUE
            A(I,J)=SUM
            DUM=VV(I)*ABS(SUM)
            IF (DUM.GE.AAMAX) THEN
             IMAX=I
             AAMAX=DUM
             END IF
16          CONTINUE
         IF (J.NE.IMAX)THEN
          DO 17 K=1,N
             DUM=A(IMAX,K)
             A(IMAX,K)=A(J,K)
             A(J,K)=DUM
17           CONTINUE
          D=-D
          VV(IMAX)=VV(J)
          END IF
         INDX(J)=IMAX
         IF(A(J,J).EQ.0.D 00) A(J,J)=TINY
         IF(J.NE.N)THEN
          DUM=1.D 00/A(J,J)
          DO 18 I=J+1,N
             A(I,J)=A(I,J)*DUM
18           CONTINUE
          END IF
19    CONTINUE
      RETURN
      END