ctest wham & cluster src-M
[unres.git] / source / unres / src_MD / banach.f
1 C
2 C**********************
3       SUBROUTINE BANACH(N,NMAX,A,X,osob)
4 C**********************
5 C     Banachiewicz
6       implicit real*8 (a-h,o-z)
7       include 'DIMENSIONS'
8       DIMENSION A(NMAX,NMAX),X(NMAX),D(MAXRES6)
9       COMMON /BANII/ D
10       logical osob
11       osob=.false.
12       if (dabs(a(1,1)).lt.1.0d-15) then
13         osob=.true.
14         return
15       endif
16       D(1)=1./A(1,1)
17       DO 80 I=2,N
18       A(I,1)=A(1,I)
19       DO 81 J=2,I-1
20       XX=A(J,I)
21       DO 82 K=1,J-1
22       XX=XX-A(I,K)*A(J,K)
23    82 CONTINUE
24       A(I,J)=XX
25    81 CONTINUE
26       XX=A(I,I)
27       JJJJ=I-1
28       DO 83 J=1,JJJJ
29       AIJ=A(I,J)
30       AIJD=AIJ*D(J)
31       A(I,J)=AIJD
32       XX=XX-AIJ*AIJD
33    83 CONTINUE 
34       if (dabs(xx).lt.1.0d-15) then
35         osob=.true.
36         return
37       endif
38       D(I)=1./XX
39    80 CONTINUE
40 C
41       CALL BANAII(N,NMAX,A,X)
42       RETURN
43       END
44 C************************
45       SUBROUTINE BANAII(N,NMAX,A,X)
46 C************************
47       implicit real*8 (a-h,o-z)
48       include 'DIMENSIONS'
49       DIMENSION A(NMAX,NMAX),X(NMAX),D(MAXRES6)
50       COMMON /BANII/ D
51       DO 90 I=1,N
52       Z=X(I)
53       JJJJ=I-1
54       DO 91 J=JJJJ,1,-1
55       Z=Z-A(I,J)*X(J)
56    91 CONTINUE
57       X(I)=Z
58    90 CONTINUE
59       DO 92 I=N,1,-1
60       Z=X(I)*D(I)
61       JJJJ=I+1
62       DO 93 J=JJJJ,N
63       Z=Z-A(J,I)*X(J)
64    93 CONTINUE
65       X(I)=Z
66    92 CONTINUE
67       RETURN
68       END
69 C
70       SUBROUTINE MATINVERT(N,NMAX,A,A1,osob)
71       implicit real*8 (a-h,o-z)
72       include 'DIMENSIONS' 
73       DIMENSION A(NMAX,NMAX),A1(NMAX,NMAX),D(MAXRES6)
74       COMMON /BANII/ D
75       DIMENSION X(NMAX)
76       logical osob
77       DO I=1,N
78         X(I)=0.0
79       ENDDO
80       X(1)=1.0
81       CALL BANACH(N,NMAX,A,X,osob)
82       if (osob) return
83       DO I=1,N
84         A1(I,1)=X(I)
85       ENDDO
86       DO I=2,N
87         DO J=1,N
88           X(J)=0.0
89         ENDDO
90         X(I)=1.0
91         CALL BANAII(N,NMAX,A,X)
92         DO J=1,N
93           A1(J,I)=X(J)
94         ENDDO
95       ENDDO
96       RETURN
97       END
98
99