-
Notifications
You must be signed in to change notification settings - Fork 0
/
drfftf.f
499 lines (499 loc) · 14 KB
/
drfftf.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
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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
c-----------------------------------------------------------------------
c http://www.netlib.org/bihar/
c-----------------------------------------------------------------------
subroutine drfftf (n,r,wsave)
integer n
c wsave is a work array which should be dimensioned at least 2*n+15
real*8 r(n), wsave(*)
c
if (n .eq. 1) return
c
call drftf1 (n,r,wsave,wsave(n+1),wsave(2*n+1))
c
return
end
c
c-----------------------------------------------------------------------
subroutine dradf2 (ido,l1,cc,ch,wa1)
integer ido, l1
real*8 cc(ido,l1,2), ch(ido,2,l1), wa1(*)
c
integer i, ic, idp2, k
real*8 ti2, tr2
c
do 101 k=1,l1
ch(1,1,k) = cc(1,k,1)+cc(1,k,2)
ch(ido,2,k) = cc(1,k,1)-cc(1,k,2)
101 continue
c
if (ido-2) 107,105,102
102 idp2 = ido+2
do 104 k=1,l1
do 103 i=3,ido,2
ic = idp2-i
tr2 = wa1(i-2)*cc(i-1,k,2)+wa1(i-1)*cc(i,k,2)
ti2 = wa1(i-2)*cc(i,k,2)-wa1(i-1)*cc(i-1,k,2)
ch(i,1,k) = cc(i,k,1)+ti2
ch(ic,2,k) = ti2-cc(i,k,1)
ch(i-1,1,k) = cc(i-1,k,1)+tr2
ch(ic-1,2,k) = cc(i-1,k,1)-tr2
103 continue
104 continue
c
if (mod(ido,2) .eq. 1) return
105 do 106 k=1,l1
ch(1,2,k) = -cc(ido,k,2)
ch(ido,1,k) = cc(ido,k,1)
106 continue
c
107 return
end
c
c-----------------------------------------------------------------------
subroutine dradf3 (ido,l1,cc,ch,wa1,wa2)
integer ido, l1
real*8 cc(ido,l1,3), ch(ido,3,l1), wa1(*), wa2(*)
c
real*8 TAUI, TAUR
c -1/2, sqrt(3)/2
parameter (TAUR = -0.5 d0,
& TAUI = 0.8660254037 8443864676 3723170752 93618d0)
c
integer i, ic, idp2, k
real*8 ci2, cr2, di2, di3, dr2, dr3, ti2, ti3, tr2, tr3
c
do 101 k=1,l1
cr2 = cc(1,k,2)+cc(1,k,3)
ch(1,1,k) = cc(1,k,1)+cr2
ch(1,3,k) = TAUI*(cc(1,k,3)-cc(1,k,2))
ch(ido,2,k) = cc(1,k,1)+TAUR*cr2
101 continue
c
if (ido .eq. 1) return
idp2 = ido+2
do 103 k=1,l1
do 102 i=3,ido,2
ic = idp2-i
dr2 = wa1(i-2)*cc(i-1,k,2)+wa1(i-1)*cc(i,k,2)
di2 = wa1(i-2)*cc(i,k,2)-wa1(i-1)*cc(i-1,k,2)
dr3 = wa2(i-2)*cc(i-1,k,3)+wa2(i-1)*cc(i,k,3)
di3 = wa2(i-2)*cc(i,k,3)-wa2(i-1)*cc(i-1,k,3)
cr2 = dr2+dr3
ci2 = di2+di3
ch(i-1,1,k) = cc(i-1,k,1)+cr2
ch(i,1,k) = cc(i,k,1)+ci2
tr2 = cc(i-1,k,1)+TAUR*cr2
ti2 = cc(i,k,1)+TAUR*ci2
tr3 = TAUI*(di2-di3)
ti3 = TAUI*(dr3-dr2)
ch(i-1,3,k) = tr2+tr3
ch(ic-1,2,k) = tr2-tr3
ch(i,3,k) = ti2+ti3
ch(ic,2,k) = ti3-ti2
102 continue
103 continue
c
return
end
c
c-----------------------------------------------------------------------
subroutine dradf4 (ido,l1,cc,ch,wa1,wa2,wa3)
integer ido, l1
real*8 cc(ido,l1,4), ch(ido,4,l1), wa1(*), wa2(*), wa3(*)
c
real*8 HSQT2
parameter (HSQT2 = .7071067811 8654752440 0844362104 85 d0)
c
integer i, ic, idp2, k
real*8 ci2, ci3, ci4, cr2, cr3, cr4,
& ti1, ti2, ti3, ti4, tr1, tr2, tr3, tr4
c
do 101 k=1,l1
tr1 = cc(1,k,2)+cc(1,k,4)
tr2 = cc(1,k,1)+cc(1,k,3)
ch(1,1,k) = tr1+tr2
ch(ido,4,k) = tr2-tr1
ch(ido,2,k) = cc(1,k,1)-cc(1,k,3)
ch(1,3,k) = cc(1,k,4)-cc(1,k,2)
101 continue
c
if (ido-2) 107,105,102
102 idp2 = ido+2
do 104 k=1,l1
do 103 i=3,ido,2
ic = idp2-i
cr2 = wa1(i-2)*cc(i-1,k,2)+wa1(i-1)*cc(i,k,2)
ci2 = wa1(i-2)*cc(i,k,2)-wa1(i-1)*cc(i-1,k,2)
cr3 = wa2(i-2)*cc(i-1,k,3)+wa2(i-1)*cc(i,k,3)
ci3 = wa2(i-2)*cc(i,k,3)-wa2(i-1)*cc(i-1,k,3)
cr4 = wa3(i-2)*cc(i-1,k,4)+wa3(i-1)*cc(i,k,4)
ci4 = wa3(i-2)*cc(i,k,4)-wa3(i-1)*cc(i-1,k,4)
tr1 = cr2+cr4
tr4 = cr4-cr2
ti1 = ci2+ci4
ti4 = ci2-ci4
ti2 = cc(i,k,1)+ci3
ti3 = cc(i,k,1)-ci3
tr2 = cc(i-1,k,1)+cr3
tr3 = cc(i-1,k,1)-cr3
ch(i-1,1,k) = tr1+tr2
ch(ic-1,4,k) = tr2-tr1
ch(i,1,k) = ti1+ti2
ch(ic,4,k) = ti1-ti2
ch(i-1,3,k) = ti4+tr3
ch(ic-1,2,k) = tr3-ti4
ch(i,3,k) = tr4+ti3
ch(ic,2,k) = tr4-ti3
103 continue
104 continue
if (mod(ido,2) .eq. 1) return
105 continue
c
do 106 k=1,l1
ti1 = -HSQT2*(cc(ido,k,2)+cc(ido,k,4))
tr1 = HSQT2*(cc(ido,k,2)-cc(ido,k,4))
ch(ido,1,k) = tr1+cc(ido,k,1)
ch(ido,3,k) = cc(ido,k,1)-tr1
ch(1,2,k) = ti1-cc(ido,k,3)
ch(1,4,k) = ti1+cc(ido,k,3)
106 continue
c
107 return
end
c
c-----------------------------------------------------------------------
subroutine dradf5 (ido,l1,cc,ch,wa1,wa2,wa3,wa4)
integer ido, l1
real*8 cc(ido,l1,5), ch(ido,5,l1), wa1(*), wa2(*), wa3(*), wa4(*)
c
real*8 TI11, TI12, TR11, TR12
c sin(pi/10), sin(2 pi/5), -sin(3 pi/10), sin(pi/5)
parameter (TR11 = 0.3090169943 7494742410 2293417182 81906d0,
& TI11 = 0.9510565162 9515357211 6439333379 38214d0,
& TR12 = -0.8090169943 7494742410 2293417182 81906d0,
& TI12 = 0.5877852522 9247312916 8705954639 07277d0)
c
integer i, ic, idp2, k
real*8 ci2, ci3, ci4, ci5, cr2, cr3, cr4, cr5,
& di2, di3, di4, di5, dr2, dr3, dr4, dr5,
3 ti2, ti3, ti4, ti5, tr2, tr3, tr4, tr5
c
do 101 k=1,l1
cr2 = cc(1,k,5)+cc(1,k,2)
ci5 = cc(1,k,5)-cc(1,k,2)
cr3 = cc(1,k,4)+cc(1,k,3)
ci4 = cc(1,k,4)-cc(1,k,3)
ch(1,1,k) = cc(1,k,1)+cr2+cr3
ch(ido,2,k) = cc(1,k,1)+TR11*cr2+TR12*cr3
ch(1,3,k) = TI11*ci5+TI12*ci4
ch(ido,4,k) = cc(1,k,1)+TR12*cr2+TR11*cr3
ch(1,5,k) = TI12*ci5-TI11*ci4
101 continue
c
if (ido .eq. 1) return
idp2 = ido+2
do 103 k=1,l1
do 102 i=3,ido,2
ic = idp2-i
dr2 = wa1(i-2)*cc(i-1,k,2)+wa1(i-1)*cc(i,k,2)
di2 = wa1(i-2)*cc(i,k,2)-wa1(i-1)*cc(i-1,k,2)
dr3 = wa2(i-2)*cc(i-1,k,3)+wa2(i-1)*cc(i,k,3)
di3 = wa2(i-2)*cc(i,k,3)-wa2(i-1)*cc(i-1,k,3)
dr4 = wa3(i-2)*cc(i-1,k,4)+wa3(i-1)*cc(i,k,4)
di4 = wa3(i-2)*cc(i,k,4)-wa3(i-1)*cc(i-1,k,4)
dr5 = wa4(i-2)*cc(i-1,k,5)+wa4(i-1)*cc(i,k,5)
di5 = wa4(i-2)*cc(i,k,5)-wa4(i-1)*cc(i-1,k,5)
cr2 = dr2+dr5
ci5 = dr5-dr2
cr5 = di2-di5
ci2 = di2+di5
cr3 = dr3+dr4
ci4 = dr4-dr3
cr4 = di3-di4
ci3 = di3+di4
ch(i-1,1,k) = cc(i-1,k,1)+cr2+cr3
ch(i,1,k) = cc(i,k,1)+ci2+ci3
tr2 = cc(i-1,k,1)+TR11*cr2+TR12*cr3
ti2 = cc(i,k,1)+TR11*ci2+TR12*ci3
tr3 = cc(i-1,k,1)+TR12*cr2+TR11*cr3
ti3 = cc(i,k,1)+TR12*ci2+TR11*ci3
tr5 = TI11*cr5+TI12*cr4
ti5 = TI11*ci5+TI12*ci4
tr4 = TI12*cr5-TI11*cr4
ti4 = TI12*ci5-TI11*ci4
ch(i-1,3,k) = tr2+tr5
ch(ic-1,2,k) = tr2-tr5
ch(i,3,k) = ti2+ti5
ch(ic,2,k) = ti5-ti2
ch(i-1,5,k) = tr3+tr4
ch(ic-1,4,k) = tr3-tr4
ch(i,5,k) = ti3+ti4
ch(ic,4,k) = ti4-ti3
102 continue
103 continue
c
return
end
c
c-----------------------------------------------------------------------
subroutine dradfg (ido,ip,l1,idl1,cc,c1,c2,ch,ch2,wa)
integer ido, ip, l1
real*8 cc(ido,ip,l1), c1(ido,l1,ip), c2(idl1,ip),
& ch(ido,l1,ip), ch2(idl1,ip), wa(*)
c
real*8 TPI
c 2 pi
parameter (TPI = 6.2831853071 7958647692 5286766559 00577d0)
c
integer i, ic, idij, idl1, idp2, ik, ipph, ipp2, is,
& j, jc, j2, k, l, lc, nbd
real*8 ai1, ai2, ar1, ar1h, ar2, ar2h, arg, dc2, dcp, ds2, dsp
c
arg = TPI/dble(ip)
dcp = dcos(arg)
dsp = dsin(arg)
ipph = (ip+1)/2
ipp2 = ip+2
idp2 = ido+2
nbd = (ido-1)/2
if (ido .eq. 1) go to 119
do 101 ik=1,idl1
ch2(ik,1) = c2(ik,1)
101 continue
do 103 j=2,ip
do 102 k=1,l1
ch(1,k,j) = c1(1,k,j)
102 continue
103 continue
c
if (nbd .gt. l1) go to 107
is = -ido
do 106 j=2,ip
is = is+ido
idij = is
do 105 i=3,ido,2
idij = idij+2
do 104 k=1,l1
ch(i-1,k,j) = wa(idij-1)*c1(i-1,k,j)+wa(idij)*c1(i,k,j)
ch(i,k,j) = wa(idij-1)*c1(i,k,j)-wa(idij)*c1(i-1,k,j)
104 continue
105 continue
106 continue
go to 111
c
107 is = -ido
do 110 j=2,ip
is = is+ido
do 109 k=1,l1
idij = is
do 108 i=3,ido,2
idij = idij+2
ch(i-1,k,j) = wa(idij-1)*c1(i-1,k,j)+wa(idij)*c1(i,k,j)
ch(i,k,j) = wa(idij-1)*c1(i,k,j)-wa(idij)*c1(i-1,k,j)
108 continue
109 continue
110 continue
c
111 if (nbd .lt. l1) go to 115
do 114 j=2,ipph
jc = ipp2-j
do 113 k=1,l1
do 112 i=3,ido,2
c1(i-1,k,j) = ch(i-1,k,j)+ch(i-1,k,jc)
c1(i-1,k,jc) = ch(i,k,j)-ch(i,k,jc)
c1(i,k,j) = ch(i,k,j)+ch(i,k,jc)
c1(i,k,jc) = ch(i-1,k,jc)-ch(i-1,k,j)
112 continue
113 continue
114 continue
go to 121
c
115 do 118 j=2,ipph
jc = ipp2-j
do 117 i=3,ido,2
do 116 k=1,l1
c1(i-1,k,j) = ch(i-1,k,j)+ch(i-1,k,jc)
c1(i-1,k,jc) = ch(i,k,j)-ch(i,k,jc)
c1(i,k,j) = ch(i,k,j)+ch(i,k,jc)
c1(i,k,jc) = ch(i-1,k,jc)-ch(i-1,k,j)
116 continue
117 continue
118 continue
go to 121
c
119 do 120 ik=1,idl1
c2(ik,1) = ch2(ik,1)
120 continue
c
121 do 123 j=2,ipph
jc = ipp2-j
do 122 k=1,l1
c1(1,k,j) = ch(1,k,j)+ch(1,k,jc)
c1(1,k,jc) = ch(1,k,jc)-ch(1,k,j)
122 continue
123 continue
c
ar1 = 1.d0
ai1 = 0.d0
do 127 l=2,ipph
lc = ipp2-l
ar1h = dcp*ar1-dsp*ai1
ai1 = dcp*ai1+dsp*ar1
ar1 = ar1h
do 124 ik=1,idl1
ch2(ik,l) = c2(ik,1)+ar1*c2(ik,2)
ch2(ik,lc) = ai1*c2(ik,ip)
124 continue
dc2 = ar1
ds2 = ai1
ar2 = ar1
ai2 = ai1
do 126 j=3,ipph
jc = ipp2-j
ar2h = dc2*ar2-ds2*ai2
ai2 = dc2*ai2+ds2*ar2
ar2 = ar2h
do 125 ik=1,idl1
ch2(ik,l) = ch2(ik,l)+ar2*c2(ik,j)
ch2(ik,lc) = ch2(ik,lc)+ai2*c2(ik,jc)
125 continue
126 continue
127 continue
c
do 129 j=2,ipph
do 128 ik=1,idl1
ch2(ik,1) = ch2(ik,1)+c2(ik,j)
128 continue
129 continue
c
if (ido .lt. l1) go to 132
do 131 k=1,l1
do 130 i=1,ido
cc(i,1,k) = ch(i,k,1)
130 continue
131 continue
go to 135
c
132 do 134 i=1,ido
do 133 k=1,l1
cc(i,1,k) = ch(i,k,1)
133 continue
134 continue
c
135 do 137 j=2,ipph
jc = ipp2-j
j2 = j+j
do 136 k=1,l1
cc(ido,j2-2,k) = ch(1,k,j)
cc(1,j2-1,k) = ch(1,k,jc)
136 continue
137 continue
c
if (ido .eq. 1) return
if (nbd .lt. l1) go to 141
do 140 j=2,ipph
jc = ipp2-j
j2 = j+j
do 139 k=1,l1
do 138 i=3,ido,2
ic = idp2-i
cc(i-1,j2-1,k) = ch(i-1,k,j)+ch(i-1,k,jc)
cc(ic-1,j2-2,k) = ch(i-1,k,j)-ch(i-1,k,jc)
cc(i,j2-1,k) = ch(i,k,j)+ch(i,k,jc)
cc(ic,j2-2,k) = ch(i,k,jc)-ch(i,k,j)
138 continue
139 continue
140 continue
return
c
141 do 144 j=2,ipph
jc = ipp2-j
j2 = j+j
do 143 i=3,ido,2
ic = idp2-i
do 142 k=1,l1
cc(i-1,j2-1,k) = ch(i-1,k,j)+ch(i-1,k,jc)
cc(ic-1,j2-2,k) = ch(i-1,k,j)-ch(i-1,k,jc)
cc(i,j2-1,k) = ch(i,k,j)+ch(i,k,jc)
cc(ic,j2-2,k) = ch(i,k,jc)-ch(i,k,j)
142 continue
143 continue
144 continue
c
return
end
c
c-----------------------------------------------------------------------
subroutine drftf1 (n,c,ch,wa,ifac)
integer n, ifac(15)
real*8 c(n), ch(n), wa(n)
c
integer i, idl1, ido, ip, iw, ix2, ix3, ix4,
& k1, kh, l1, l2, na, nf
c
nf = ifac(2)
na = 1
l2 = n
iw = n
do 111 k1=1,nf
kh = nf-k1
ip = ifac(kh+3)
l1 = l2/ip
ido = n/l2
idl1 = ido*l1
iw = iw-(ip-1)*ido
na = 1-na
if (ip .ne. 4) go to 102
c
ix2 = iw+ido
ix3 = ix2+ido
if (na .ne. 0) go to 101
call dradf4 (ido,l1,c,ch,wa(iw),wa(ix2),wa(ix3))
go to 110
101 call dradf4 (ido,l1,ch,c,wa(iw),wa(ix2),wa(ix3))
go to 110
c
102 if (ip .ne. 2) go to 104
if (na .ne. 0) go to 103
call dradf2 (ido,l1,c,ch,wa(iw))
go to 110
103 call dradf2 (ido,l1,ch,c,wa(iw))
go to 110
c
104 if (ip .ne. 3) go to 106
ix2 = iw+ido
if (na .ne. 0) go to 105
call dradf3 (ido,l1,c,ch,wa(iw),wa(ix2))
go to 110
105 call dradf3 (ido,l1,ch,c,wa(iw),wa(ix2))
go to 110
c
106 if (ip .ne. 5) go to 108
ix2 = iw+ido
ix3 = ix2+ido
ix4 = ix3+ido
if (na .ne. 0) go to 107
call dradf5 (ido,l1,c,ch,wa(iw),wa(ix2),wa(ix3),wa(ix4))
go to 110
107 call dradf5 (ido,l1,ch,c,wa(iw),wa(ix2),wa(ix3),wa(ix4))
go to 110
c
108 if (ido .eq. 1) na = 1-na
if (na .ne. 0) go to 109
call dradfg (ido,ip,l1,idl1,c,c,c,ch,ch,wa(iw))
na = 1
go to 110
109 call dradfg (ido,ip,l1,idl1,ch,ch,ch,c,c,wa(iw))
na = 0
c
110 l2 = l1
111 continue
c
if (na .eq. 1) return
do 112 i=1,n
c(i) = ch(i)
112 continue
c
return
end
c