-
Notifications
You must be signed in to change notification settings - Fork 0
/
E3TOG6.FOR
265 lines (238 loc) · 6.82 KB
/
E3TOG6.FOR
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
C program e3g6
C real*8 minp(3,3),m(3,3)
C real*8 m6(6,6)
C read (*,*) minp
C call m3tom6 (minp,m6)
C do 1000 i=1,3
C write (*,*) (minp(j,i),j=1,3)
C 1000 continue
C write (*,*)
C do 2000 i=1,6
C write (*,*) (m6(j,i),j=1,6)
C 2000 continue
C write (*,*)
C write (*,*)
C
C
C call g6toe3 (m6,m)
C
C do 3000 i=1,3
C write (*,*) (m(j,i),j=1,3)
C 3000 continue
C end
C**********************************************************************C
real*8 function m3det(m)
implicit none
real*8 m(3,3)
C----------------------------------------------------------------------C
m3det = m(1,1)*m(2,2)*m(3,3)
* +m(1,2)*m(2,3)*m(3,1)
* +m(1,3)*m(2,1)*m(3,2)
* -m(1,1)*m(2,3)*m(3,2)
* -m(1,2)*m(2,1)*m(3,3)
* -m(1,3)*m(2,2)*m(3,1)
return
end
C**********************************************************************C
subroutine btos (n,bits,s)
implicit none
integer n
integer s(n)
integer bits,twotoi
integer i
C----------------------------------------------------------------------C
twotoi = 1
do 1000 i=1,n
if (mod(bits/twotoi,2) .eq. 1) then
s(i) = -1
else
s(i) = 1
endif
twotoi = 2*twotoi
1000 continue
end
C**********************************************************************C
subroutine g6toe3 (m6IN,m)
implicit none
real*8 m6(6,6), m6t(6,6)
INTEGER M6IN(6,6)
real*8 m3(3,3), m(3,3)
real*8 mdif
external mdif
integer bits,bitmin
integer signs(9)
integer i,j,l
real*8 t1, t1min
real*8 m3det
C----------------------------------------------------------------------C
DO 900 I=1,6
DO 900 J=1,6
900 M6(I,J) = DBLE(M6IN(I,J))
do 1000 i=1,3
do 1000 j=1,3
m3(i,j) = dsqrt(m6(i,j))
1000 continue
do 5000 bits = 511,0,-1
call btos(9,bits,signs)
C write (*,*) ' bits,signs ',bits,signs
do 2000 l=1,9
i = (l-1)/3 + 1
j = l -3*(i-1)
m(i,j) = signs(l)*m3(i,j)
2000 continue
call m3tom6 (m,m6t)
t1 = mdif(6,m6,m6t)
C write (*,*) ' m6t in g6toe3 '
C do 3000 i=1,6
C 3000 write (*,'(1x,6f8.2)') (m6t(j,i),j=1,6)
C write (*,*) ' bits,t1 ',bits,t1
if (bits.eq.511) t1min = t1
if (t1 .le. t1min) then
t1min = t1
bitmin = bits
endif
if (t1 .eq. 0.0) go to 5500
5000 continue
5500 continue
C write (*,*) ' t1 ',t1,t1min,bitmin
if (t1 .ne. 0.0) then
call btos (9,bitmin,signs)
do 6000 l=1,9
i = (l-1)/3 + 1
j = l -3*(i-1)
m(i,j) = signs(l)*m3(i,j)
6000 continue
endif
if (m3det(m).lt.0) then
do 7000 l=1,9
i = (l-1)/3 + 1
j = l -3*(i-1)
m(i,j) = -m(i,j)
7000 continue
endif
do 8000 l=1,9
i = (l-1)/3 + 1
j = l -3*(i-1)
if (dabs(m(i,j)).lt.1.d-8) m(i,j) = 0.D0
8000 continue
end
C**********************************************************************C
subroutine dg6toe3 (m6,m)
implicit none
real*8 m6(6,6), m6t(6,6)
real*8 m3(3,3), m(3,3)
real*8 mdif
external mdif
integer bits,bitmin
integer signs(9)
integer i,j,l
real*8 t1, t1min
real*8 m3det
C----------------------------------------------------------------------C
do 1000 i=1,3
do 1000 j=1,3
m3(i,j) = sqrt(m6(i,j))
1000 continue
do 5000 bits = 511,0,-1
call btos(9,bits,signs)
C write (*,*) ' bits,signs ',bits,signs
do 2000 l=1,9
i = (l-1)/3 + 1
j = l -3*(i-1)
m(i,j) = signs(l)*m3(i,j)
2000 continue
call m3tom6 (m,m6t)
t1 = mdif(6,m6,m6t)
if (bits.eq.511) t1min = t1
if (t1 .le. t1min) then
t1min = t1
bitmin = bits
endif
if (t1 .eq. 0.0) go to 5500
5000 continue
5500 continue
C write (*,*) ' t1 ',t1,t1min,bitmin
if (t1 .ne. 0.0) then
call btos (9,bitmin,signs)
do 6000 l=1,9
i = (l-1)/3 + 1
j = l -3*(i-1)
m(i,j) = signs(l)*m3(i,j)
6000 continue
endif
if (m3det(m).lt.0) then
do 7000 l=1,9
i = (l-1)/3 + 1
j = l -3*(i-1)
m(i,j) = -m(i,j)
7000 continue
endif
do 8000 l=1,9
i = (l-1)/3 + 1
j = l -3*(i-1)
if (dabs(m(i,j)).lt.1.D-8) m(i,j) = 0.D0
8000 continue
end
C**********************************************************************C
SUBROUTINE VVTOG6 (M,N1,N2,V1,V2,N3,G)
implicit none
integer n1,n2,n3
real*8 M, V1(3,3),V2(3,3), G(6,6)
C----------------------------------------------------------------------C
g(n3,1) = m*v1(n1,1)*v2(n2,1)
g(n3,2) = m*v1(n1,2)*v2(n2,2)
g(n3,3) = m*v1(n1,3)*v2(n2,3)
g(n3,4) = (m*v1(n1,2)*v2(n2,3) + m*v1(n1,3)*v2(n2,2)) / 2.0
g(n3,5) = (m*v1(n1,1)*v2(n2,3) + m*v1(n1,3)*v2(n2,1)) / 2.0
g(n3,6) = (m*v1(n1,1)*v2(n2,2) + m*v1(n1,2)*v2(n2,1)) / 2.0
END
C**********************************************************************C
SUBROUTINE M3TOM6 (M3,M6)
implicit none
real*8 M3(3,3), M6(6,6)
C----------------------------------------------------------------------C
call vvtog6 (1.0D0,1,1,M3,M3,1,m6)
call vvtog6 (1.0D0,2,2,M3,M3,2,m6)
call vvtog6 (1.0D0,3,3,M3,M3,3,m6)
call vvtog6 (2.0D0,2,3,M3,M3,4,m6)
call vvtog6 (2.0D0,1,3,M3,M3,5,m6)
call vvtog6 (2.0D0,1,2,M3,M3,6,m6)
end
C**********************************************************************C
SUBROUTINE MM(N,M1,M2,M3)
implicit none
integer i,j,k,n
real*8 M1(N,N), M2(N,N), M3(N,N)
real*8 temp
C----------------------------------------------------------------------C
DO 3000 I=1,N
DO 2000 J=1,N
TEMP = 0.0
DO 1000 K=1,N
TEMP = TEMP + M1(K,I)*M2(J,K)
1000 CONTINUE
M3(I,J) = TEMP
2000 CONTINUE
3000 CONTINUE
END
C**********************************************************************C
real*8 FUNCTION MDIF (N,M1,M2)
implicit none
real*8 M1(*), M2(*)
real*8 temp
integer i, n
C----------------------------------------------------------------------C
TEMP = 0
DO 1000 I=1,N*N
1000 TEMP = TEMP + (M1(I)-M2(I))**2
MDIF = sqrt(TEMP)
END
C**********************************************************************C
SUBROUTINE CPYMAT (N,M1,M2)
implicit none
real*8 M1(*),M2(*)
integer i, n
C----------------------------------------------------------------------C
DO 1000 I=1,N*N
1000 M2(I) = M1(I)
END