-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdial.f
69 lines (69 loc) · 1.7 KB
/
dial.f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
C SUBROUTINE THAT DIAGONALIZES SYMMETRIC MATRIX TO GIVE VALUES AS DIAGONAL
C ELEMENTS AND VECTORS IN U-MATRIX COLUMN-WISE
C SUBROUTINE DIAL(N,U,A)
SUBROUTINE DIAL(N,A)
IMPLICIT REAL*8(A-H,O-Z)
parameter(kk=300)
DIMENSION UTEST(kk),U(kk,kk),A(kk,kk)
EPS=1.0D-20
DO 8 J=1,N
DO 9 I=1,N
9 U(I,J)=0.0D0
8 U(J,J)=1.0D0
10 AMAX=0.0D0
DO 11 I=2,N
JUP=I-1
DO 11 J=1,JUP
AII=A(I,I)
AJJ=A(J,J)
AOD=A(I,J)
ASQ=AOD*AOD
28 IF(ASQ-AMAX)23,23,27
27 AMAX=ASQ
23 IF(ASQ-EPS)11,11,12
12 DIFFR=AII-AJJ
IF(DIFFR)13,15,15
13 SAGN=-2.0D0
DIFFR=-DIFFR
GO TO 16
15 SAGN=2.0D0
16 TDEN=DIFFR+DSQRT(DIFFR**2+4.0D0*ASQ)
TAM=SAGN*AOD/TDEN
CZ=1.0D0/(DSQRT(1.0D0+TAM**2))
SP=CZ*TAM
DO 24 L=1,N
XJ=CZ*U(L,J)-SP*U(L,I)
U(L,I)=SP*U(L,J)+CZ*U(L,I)
U(L,J)=XJ
IF(L-J)18,24,18
18 IF(L-I)21,24,21
21 XJ=CZ*A(L,J)-SP*A(L,I)
A(L,I)=SP*A(L,J)+CZ*A(L,I)
A(L,J)=XJ
A(I,L)=A(L,I)
A(J,L)=A(L,J)
24 CONTINUE
A(I,I)=CZ*CZ*AII+SP*SP*AJJ+2.0D0*SP*CZ*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