-
Notifications
You must be signed in to change notification settings - Fork 5
/
fftpack.f
1336 lines (1296 loc) · 39.7 KB
/
fftpack.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
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
C --------------------------------------------------------------
C Source code obtained from FFTPACK version 4.1 , available at
C http://www.scd.ucar.edu/softlib/mathlib.html
C --------------------------------------------------------------
C SUBROUTINE RFFTI(N,WSAVE)
C
C SUBROUTINE RFFTI INITIALIZES THE ARRAY WSAVE WHICH IS USED IN
C BOTH RFFTF AND RFFTB. THE PRIME FACTORIZATION OF N TOGETHER WITH
C A TABULATION OF THE TRIGONOMETRIC FUNCTIONS ARE COMPUTED AND
C STORED IN WSAVE.
C
C INPUT PARAMETER
C
C N THE LENGTH OF THE SEQUENCE TO BE TRANSFORMED.
C
C OUTPUT PARAMETER
C
C WSAVE A WORK ARRAY WHICH MUST BE DIMENSIONED AT LEAST 2*N+15.
C THE SAME WORK ARRAY CAN BE USED FOR BOTH RFFTF AND RFFTB
C AS LONG AS N REMAINS UNCHANGED. DIFFERENT WSAVE ARRAYS
C ARE REQUIRED FOR DIFFERENT VALUES OF N. THE CONTENTS OF
C WSAVE MUST NOT BE CHANGED BETWEEN CALLS OF RFFTF OR RFFTB.
C
SUBROUTINE RFFTI (N,WSAVE)
DIMENSION WSAVE(*)
C
IF (N .EQ. 1) RETURN
CALL RFFTI1 (N,WSAVE(N+1),WSAVE(2*N+1))
RETURN
END
SUBROUTINE RFFTI1 (N,WA,IFAC)
!bjj START (fix for compatibility in double precision):
!bjj: perhaps we get read RFAC as a REAL(4), then
!declare IFAC as INTEGER(4) and EQUIVALENCE them
!rm DIMENSION WA(*) ,IFAC(*) ,NTRYH(4)
USE PRECISION
REAL(ReKi), DIMENSION(*) :: IFAC
DIMENSION WA(*) ,NTRYH(4)
!bjj END
DATA NTRYH(1),NTRYH(2),NTRYH(3),NTRYH(4)/4,2,3,5/
NL = N
NF = 0
J = 0
101 J = J+1
IF (J-4) 102,102,103
102 NTRY = NTRYH(J)
GO TO 104
103 NTRY = NTRY+2
104 NQ = NL/NTRY
NR = NL-NTRY*NQ
IF (NR) 101,105,101
105 NF = NF+1
IFAC(NF+2) = NTRY
NL = NQ
IF (NTRY .NE. 2) GO TO 107
IF (NF .EQ. 1) GO TO 107
DO 106 I=2,NF
IB = NF-I+2
IFAC(IB+2) = IFAC(IB+1)
106 CONTINUE
IFAC(3) = 2
107 IF (NL .NE. 1) GO TO 104
IFAC(1) = N
IFAC(2) = NF
TPI = 2.0*PIMACH(DUM)
ARGH = TPI/FLOAT(N)
IS = 0
NFM1 = NF-1
L1 = 1
IF (NFM1 .EQ. 0) RETURN
DO 110 K1=1,NFM1
IP = IFAC(K1+2)
LD = 0
L2 = L1*IP
IDO = N/L2
IPM = IP-1
DO 109 J=1,IPM
LD = LD+L1
I = IS
ARGLD = FLOAT(LD)*ARGH
FI = 0.
DO 108 II=3,IDO,2
I = I+2
FI = FI+1.
ARG = FI*ARGLD
WA(I-1) = COS(ARG)
WA(I) = SIN(ARG)
108 CONTINUE
IS = IS+IDO
109 CONTINUE
L1 = L2
110 CONTINUE
RETURN
END
C SUBROUTINE RFFTB(N,R,WSAVE)
C
C SUBROUTINE RFFTB COMPUTES THE REAL PERODIC SEQUENCE FROM ITS
C FOURIER COEFFICIENTS (FOURIER SYNTHESIS). THE TRANSFORM IS DEFINED
C BELOW AT OUTPUT PARAMETER R.
C
C INPUT PARAMETERS
C
C N THE LENGTH OF THE ARRAY R TO BE TRANSFORMED. THE METHOD
C IS MOST EFFICIENT WHEN N IS A PRODUCT OF SMALL PRIMES.
C N MAY CHANGE SO LONG AS DIFFERENT WORK ARRAYS ARE PROVIDED
C
C R A REAL ARRAY OF LENGTH N WHICH CONTAINS THE SEQUENCE
C TO BE TRANSFORMED
C
C WSAVE A WORK ARRAY WHICH MUST BE DIMENSIONED AT LEAST 2*N+15.
C IN THE PROGRAM THAT CALLS RFFTB. THE WSAVE ARRAY MUST BE
C INITIALIZED BY CALLING SUBROUTINE RFFTI(N,WSAVE) AND A
C DIFFERENT WSAVE ARRAY MUST BE USED FOR EACH DIFFERENT
C VALUE OF N. THIS INITIALIZATION DOES NOT HAVE TO BE
C REPEATED SO LONG AS N REMAINS UNCHANGED THUS SUBSEQUENT
C TRANSFORMS CAN BE OBTAINED FASTER THAN THE FIRST.
C THE SAME WSAVE ARRAY CAN BE USED BY RFFTF AND RFFTB.
C
C
C OUTPUT PARAMETERS
C
C R FOR N EVEN AND FOR I = 1,...,N
C
C R(I) = R(1)+(-1)**(I-1)*R(N)
C
C PLUS THE SUM FROM K=2 TO K=N/2 OF
C
C 2.*R(2*K-2)*COS((K-1)*(I-1)*2*PI/N)
C
C -2.*R(2*K-1)*SIN((K-1)*(I-1)*2*PI/N)
C
C FOR N ODD AND FOR I = 1,...,N
C
C R(I) = R(1) PLUS THE SUM FROM K=2 TO K=(N+1)/2 OF
C
C 2.*R(2*K-2)*COS((K-1)*(I-1)*2*PI/N)
C
C -2.*R(2*K-1)*SIN((K-1)*(I-1)*2*PI/N)
C
C ***** NOTE
C THIS TRANSFORM IS UNNORMALIZED SINCE A CALL OF RFFTF
C FOLLOWED BY A CALL OF RFFTB WILL MULTIPLY THE INPUT
C SEQUENCE BY N.
C
C WSAVE CONTAINS RESULTS WHICH MUST NOT BE DESTROYED BETWEEN
C CALLS OF RFFTB OR RFFTF.
C
C
SUBROUTINE RFFTB (N,R,WSAVE)
DIMENSION R(*) ,WSAVE(*)
C
IF (N .EQ. 1) RETURN
CALL RFFTB1 (N,R,WSAVE,WSAVE(N+1),WSAVE(2*N+1))
RETURN
END
SUBROUTINE RFFTB1 (N,C,CH,WA,IFAC)
!bjj START (fix for compatibility in double precision):
!rm DIMENSION CH(*) ,C(*) ,WA(*) ,IFAC(*)
USE PRECISION
REAL(ReKi), DIMENSION(*) :: IFAC
DIMENSION CH(*) ,C(*) ,WA(*)
!bjj End
NF = IFAC(2)
NA = 0
L1 = 1
IW = 1
DO 116 K1=1,NF
IP = IFAC(K1+2)
L2 = IP*L1
IDO = N/L2
IDL1 = IDO*L1
IF (IP .NE. 4) GO TO 103
IX2 = IW+IDO
IX3 = IX2+IDO
IF (NA .NE. 0) GO TO 101
CALL RADB4 (IDO,L1,C,CH,WA(IW),WA(IX2),WA(IX3))
GO TO 102
101 CALL RADB4 (IDO,L1,CH,C,WA(IW),WA(IX2),WA(IX3))
102 NA = 1-NA
GO TO 115
103 IF (IP .NE. 2) GO TO 106
IF (NA .NE. 0) GO TO 104
CALL RADB2 (IDO,L1,C,CH,WA(IW))
GO TO 105
104 CALL RADB2 (IDO,L1,CH,C,WA(IW))
105 NA = 1-NA
GO TO 115
106 IF (IP .NE. 3) GO TO 109
IX2 = IW+IDO
IF (NA .NE. 0) GO TO 107
CALL RADB3 (IDO,L1,C,CH,WA(IW),WA(IX2))
GO TO 108
107 CALL RADB3 (IDO,L1,CH,C,WA(IW),WA(IX2))
108 NA = 1-NA
GO TO 115
109 IF (IP .NE. 5) GO TO 112
IX2 = IW+IDO
IX3 = IX2+IDO
IX4 = IX3+IDO
IF (NA .NE. 0) GO TO 110
CALL RADB5 (IDO,L1,C,CH,WA(IW),WA(IX2),WA(IX3),WA(IX4))
GO TO 111
110 CALL RADB5 (IDO,L1,CH,C,WA(IW),WA(IX2),WA(IX3),WA(IX4))
111 NA = 1-NA
GO TO 115
112 IF (NA .NE. 0) GO TO 113
CALL RADBG (IDO,IP,L1,IDL1,C,C,C,CH,CH,WA(IW))
GO TO 114
113 CALL RADBG (IDO,IP,L1,IDL1,CH,CH,CH,C,C,WA(IW))
114 IF (IDO .EQ. 1) NA = 1-NA
115 L1 = L2
IW = IW+(IP-1)*IDO
116 CONTINUE
IF (NA .EQ. 0) RETURN
DO 117 I=1,N
C(I) = CH(I)
117 CONTINUE
RETURN
END
SUBROUTINE RADB2 (IDO,L1,CC,CH,WA1)
DIMENSION CC(IDO,2,L1) ,CH(IDO,L1,2) ,
1 WA1(*)
DO 101 K=1,L1
CH(1,K,1) = CC(1,1,K)+CC(IDO,2,K)
CH(1,K,2) = CC(1,1,K)-CC(IDO,2,K)
101 CONTINUE
IF (IDO-2) 107,105,102
102 IDP2 = IDO+2
DO 104 K=1,L1
DO 103 I=3,IDO,2
IC = IDP2-I
CH(I-1,K,1) = CC(I-1,1,K)+CC(IC-1,2,K)
TR2 = CC(I-1,1,K)-CC(IC-1,2,K)
CH(I,K,1) = CC(I,1,K)-CC(IC,2,K)
TI2 = CC(I,1,K)+CC(IC,2,K)
CH(I-1,K,2) = WA1(I-2)*TR2-WA1(I-1)*TI2
CH(I,K,2) = WA1(I-2)*TI2+WA1(I-1)*TR2
103 CONTINUE
104 CONTINUE
IF (MOD(IDO,2) .EQ. 1) RETURN
105 DO 106 K=1,L1
CH(IDO,K,1) = CC(IDO,1,K)+CC(IDO,1,K)
CH(IDO,K,2) = -(CC(1,2,K)+CC(1,2,K))
106 CONTINUE
107 RETURN
END
SUBROUTINE RADB3 (IDO,L1,CC,CH,WA1,WA2)
DIMENSION CC(IDO,3,L1) ,CH(IDO,L1,3) ,
1 WA1(*) ,WA2(*)
DATA TAUR,TAUI /-.5,.866025403784439/
DO 101 K=1,L1
TR2 = CC(IDO,2,K)+CC(IDO,2,K)
CR2 = CC(1,1,K)+TAUR*TR2
CH(1,K,1) = CC(1,1,K)+TR2
CI3 = TAUI*(CC(1,3,K)+CC(1,3,K))
CH(1,K,2) = CR2-CI3
CH(1,K,3) = CR2+CI3
101 CONTINUE
IF (IDO .EQ. 1) RETURN
IDP2 = IDO+2
DO 103 K=1,L1
DO 102 I=3,IDO,2
IC = IDP2-I
TR2 = CC(I-1,3,K)+CC(IC-1,2,K)
CR2 = CC(I-1,1,K)+TAUR*TR2
CH(I-1,K,1) = CC(I-1,1,K)+TR2
TI2 = CC(I,3,K)-CC(IC,2,K)
CI2 = CC(I,1,K)+TAUR*TI2
CH(I,K,1) = CC(I,1,K)+TI2
CR3 = TAUI*(CC(I-1,3,K)-CC(IC-1,2,K))
CI3 = TAUI*(CC(I,3,K)+CC(IC,2,K))
DR2 = CR2-CI3
DR3 = CR2+CI3
DI2 = CI2+CR3
DI3 = CI2-CR3
CH(I-1,K,2) = WA1(I-2)*DR2-WA1(I-1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,4) = WA3(I-2)*CR4-WA3(I-1)*CI4
CH(I,K,4) = WA3(I-2)*CI4+WA3(I-1)*CR4
103 CONTINUE
104 CONTINUE
IF (MOD(IDO,2) .EQ. 1) RETURN
105 CONTINUE
DO 106 K=1,L1
TI1 = CC(1,2,K)+CC(1,4,K)
TI2 = CC(1,4,K)-CC(1,2,K)
TR1 = CC(IDO,1,K)-CC(IDO,3,K)
TR2 = CC(IDO,1,K)+CC(IDO,3,K)
CH(IDO,K,1) = TR2+TR2
CH(IDO,K,2) = SQRT2*(TR1-TI1)
CH(IDO,K,3) = TI2+TI2
CH(IDO,K,4) = -SQRT2*(TR1+TI1)
106 CONTINUE
107 RETURN
END
SUBROUTINE RADB5 (IDO,L1,CC,CH,WA1,WA2,WA3,WA4)
DIMENSION CC(IDO,5,L1) ,CH(IDO,L1,5) ,
1 WA1(*) ,WA2(*) ,WA3(*) ,WA4(*)
DATA TR11,TI11,TR12,TI12 /.309016994374947,.951056516295154,
1-.809016994374947,.587785252292473/
DO 101 K=1,L1
TI5 = CC(1,3,K)+CC(1,3,K)
TI4 = CC(1,5,K)+CC(1,5,K)
TR2 = CC(IDO,2,K)+CC(IDO,2,K)
TR3 = CC(IDO,4,K)+CC(IDO,4,K)
CH(1,K,1) = CC(1,1,K)+TR2+TR3
CR2 = CC(1,1,K)+TR11*TR2+TR12*TR3
CR3 = CC(1,1,K)+TR12*TR2+TR11*TR3
CI5 = TI11*TI5+TI12*TI4
CI4 = TI12*TI5-TI11*TI4
CH(1,K,2) = CR2-CI5
CH(1,K,3) = CR3-CI4
CH(1,K,4) = CR3+CI4
CH(1,K,5) = CR2+CI5
101 CONTINUE
IF (IDO .EQ. 1) RETURN
IDP2 = IDO+2
DO 103 K=1,L1
DO 102 I=3,IDO,2
IC = IDP2-I
TI5 = CC(I,3,K)+CC(IC,2,K)
TI2 = CC(I,3,K)-CC(IC,2,K)
TI4 = CC(I,5,K)+CC(IC,4,K)
TI3 = CC(I,5,K)-CC(IC,4,K)
T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+2
NBD = (IDO-1)/2
IPP2 = IP+2
IPPH = (IP+1)/2
IF (IDO .LT. L1) GO TO 103
DO 102 K=1,L1
DO 101 I=1,IDO
CH(I,K,1) = CC(I,1,K)
101 CONTINUE
102 CONTINUE
GO TO 106
103 DO 105 I=1,IDO
DO 104 K=1,L1
CH(I,K,1) = CC(I,1,K)
104 CONTINUE
105 CONTINUE
106 DO 108 J=2,IPPH
JC = IPP2-J
J2 = J+J
DO 107 K=1,L1
CH(1,K,J) = CC(IDO,J2-2,K)+CC(IDO,J2-2,K)
CH(1,K,JC) = CC(1,J2-1,K)+CC(1,J2-1,K)
107 CONTINUE
108 CONTINUE
IF (IDO .EQ. 1) GO TO 116
IF (NBD .LT. L1) GO TO 112
DO 111 J=2,IPPH
JC = IPP2-J
DO 110 K=1,L1
DO 109 I=3,IDO,2
IC = IDP2-I
CH(I-1,K,J) = CC(I-1,2*J-1,K)+CC(IC-1,2*J-2,K)
CH(I-1,K,JC) = CC(I-1,2*J-1,K)-CC(IC-1,2*J-2,K)
CH(I,K,J) = CC(I,2*J-1,K)-CC(IC,2*J-2,K)
CH(I,K,JC) = CC(I,2*J-1,K)+CC(IC,2*J-2,K)
109 CONTINUE
110 CONTINUE
111 CONTINUE
GO TO 116
112 DO 115 J=2,IPPH
JC = IPP2-J
DO 114 I=3,IDO,2
IC = IDP2-I
DO 113 K=1,L1
CH(I-1,K,J) = CC(I-1,2*J-1,K)+CC(IC-1,2*J-2,K)
CH(I-1,K,JC) = CC(I-1,2*J-1,K)-CC(IC-1,2*J-2,K)
CH(I,K,J) = CC(I,2*J-1,K)-CC(IC,2*J-2,K)
CH(I,K,JC) = CC(I,2*J-1,K)+CC(IC,2*J-2,K)
113 CONTINUE
114 CONTINUE
115 CONTINUE
116 AR1 = 1.
AI1 = 0.
DO 120 L=2,IPPH
LC = IPP2-L
AR1H = DCP*AR1-DSP*AI1
AI1 = DCP*AI1+DSP*AR1
AR1 = AR1H
DO 117 IK=1,IDL1
C2(IK,L) = CH2(IK,1)+AR1*CH2(IK,2)
C2(IK,LC) = AI1*CH2(IK,IP)
117 CONTINUE
DC2 = AR1
DS2 = AI1
AR2 = AR1
AI2 = AI1
DO 119 J=3,IPPH
JC = IPP2-J
AR2H = DC2*AR2-DS2*AI2
AI2 = DC2*AI2+DS2*AR2
AR2 = AR2H
DO 118 IK=1,IDL1
C2(IK,L) = C2(IK,L)+AR2*CH2(IK,J)
C2(IK,LC) = C2(IK,LC)+AI2*CH2(IK,JC)
118 CONTINUE
119 CONTINUE
120 CONTINUE
DO 122 J=2,IPPH
DO 121 IK=1,IDL1
CH2(IK,1) = CH2(IK,1)+CH2(IK,J)
121 CONTINUE
122 CONTINUE
DO 124 J=2,IPPH
JC = IPP2-J
DO 123 K=1,L1
CH(1,K,J) = C1(1,K,J)-C1(1,K,JC)
CH(1,K,JC) = C1(1,K,J)+C1(1,K,JC)
123 CONTINUE
124 CONTINUE
IF (IDO .EQ. 1) GO TO 132
IF (NBD .LT. L1) GO TO 128
DO 127 J=2,IPPH
JC = IPP2-J
DO 126 K=1,L1
DO 125 I=3,IDO,2
CH(I-1,K,J) = C1(I-1,K,J)-C1(I,K,JC)
CH(I-1,K,JC) = C1(I-1,K,J)+C1(I,K,JC)
CH(I,K,J) = C1(I,K,J)+C1(I-1,K,JC)
CH(I,K,JC) = C1(I,K,J)-C1(I-1,K,JC)
125 CONTINUE
126 CONTINUE
127 CONTINUE
GO TO 132
128 DO 131 J=2,IPPH
JC = IPP2-J
DO 130 I=3,IDO,2
DO 129 K=1,L1
CH(I-1,K,J) = C1(I-1,K,J)-C1(I,K,JC)
CH(I-1,K,JC) = C1(I-1,K,J)+C1(I,K,JC)
CH(I,K,J) = C1(I,K,J)+C1(I-1,K,JC)
CH(I,K,JC) = C1(I,K,J)-C1(I-1,K,JC)
129 CONTINUE
130 CONTINUE
131 CONTINUE
132 CONTINUE
IF (IDO .EQ. 1) RETURN
DO 133 IK=1,IDL1
C2(IK,1) = CH2(IK,1)
133 CONTINUE
DO 135 J=2,IP
DO 134 K=1,L1
C1(1,K,J) = CH(1,K,J)
134 CONTINUE
135 CONTINUE
IF (NBD .GT. L1) GO TO 139
IS = -IDO
DO 138 J=2,IP
IS = IS+IDO
IDIJ = IS
DO 137 I=3,IDO,2
IDIJ = IDIJ+2
DO 136 K=1,L1
C1(I-1,K,J) = WA(IDIJ-1)*CH(I-1,K,J)-WA(IDIJ)*CH(I,K,J)
C1(I,K,J) = WA(IDIJ-1)*CH(I,K,J)+WA(IDIJ)*CH(I-1,K,J)
136 CONTINUE
137 CONTINUE
138 CONTINUE
GO TO 143
139 IS = -IDO
DO 142 J=2,IP
IS = IS+IDO
DO 141 K=1,L1
IDIJ = IS
DO 140 I=3,IDO,2
IDIJ = IDIJ+2
C1(I-1,K,J) = WA(IDIJ-1)*CH(I-1,K,J)-WA(IDIJ)*CH(I,K,J)
C1(I,K,J) = WA(IDIJ-1)*CH(I,K,J)+WA(IDIJ)*CH(I-1,K,J)
140 CONTINUE
141 CONTINUE
142 CONTINUE
143 RETURN
END
FUNCTION PIMACH (DUM)
C PI=3.1415926535897932384626433832795028841971693993751058209749446
C
PIMACH = 4.*ATAN(1.0)
RETURN
END
C SUBROUTINE COSTI(N,WSAVE)
C
C SUBROUTINE COSTI INITIALIZES THE ARRAY WSAVE WHICH IS USED IN
C SUBROUTINE COST. THE PRIME FACTORIZATION OF N TOGETHER WITH
C A TABULATION OF THE TRIGONOMETRIC FUNCTIONS ARE COMPUTED AND
C STORED IN WSAVE.
C
C INPUT PARAMETER
C
C N THE LENGTH OF THE SEQUENCE TO BE TRANSFORMED. THE METHOD
C IS MOST EFFICIENT WHEN N-1 IS A PRODUCT OF SMALL PRIMES.
C
C OUTPUT PARAMETER
C
C WSAVE A WORK ARRAY WHICH MUST BE DIMENSIONED AT LEAST 3*N+15.
C DIFFERENT WSAVE ARRAYS ARE REQUIRED FOR DIFFERENT VALUES
C OF N. THE CONTENTS OF WSAVE MUST NOT BE CHANGED BETWEEN
C CALLS OF COST.
C
SUBROUTINE COSTI (N,WSAVE)
DIMENSION WSAVE(*)
C
PI = PIMACH(DUM)
IF (N .LE. 3) RETURN
NM1 = N-1
NP1 = N+1
NS2 = N/2
DT = PI/FLOAT(NM1)
FK = 0.
DO 101 K=2,NS2
KC = NP1-K
FK = FK+1.
WSAVE(K) = 2.*SIN(FK*DT)
WSAVE(KC) = 2.*COS(FK*DT)
101 CONTINUE
CALL RFFTI (NM1,WSAVE(N+1))
RETURN
END
C SUBROUTINE COST(N,X,WSAVE)
C
C SUBROUTINE COST COMPUTES THE DISCRETE FOURIER COSINE TRANSFORM
C OF AN EVEN SEQUENCE X(I). THE TRANSFORM IS DEFINED BELOW AT OUTPUT
C PARAMETER X.
C
C COST IS THE UNNORMALIZED INVERSE OF ITSELF SINCE A CALL OF COST
C FOLLOWED BY ANOTHER CALL OF COST WILL MULTIPLY THE INPUT SEQUENCE
C X BY 2*(N-1). THE TRANSFORM IS DEFINED BELOW AT OUTPUT PARAMETER X
C
C THE ARRAY WSAVE WHICH IS USED BY SUBROUTINE COST MUST BE
C INITIALIZED BY CALLING SUBROUTINE COSTI(N,WSAVE).
C
C INPUT PARAMETERS
C
C N THE LENGTH OF THE SEQUENCE X. N MUST BE GREATER THAN 1.
C THE METHOD IS MOST EFFICIENT WHEN N-1 IS A PRODUCT OF
C SMALL PRIMES.
C
C X AN ARRAY WHICH CONTAINS THE SEQUENCE TO BE TRANSFORMED
C
C WSAVE A WORK ARRAY WHICH MUST BE DIMENSIONED AT LEAST 3*N+15
C IN THE PROGRAM THAT CALLS COST. THE WSAVE ARRAY MUST BE
C INITIALIZED BY CALLING SUBROUTINE COSTI(N,WSAVE) AND A
C DIFFERENT WSAVE ARRAY MUST BE USED FOR EACH DIFFERENT
C VALUE OF N. THIS INITIALIZATION DOES NOT HAVE TO BE
C REPEATED SO LONG AS N REMAINS UNCHANGED THUS SUBSEQUENT
C TRANSFORMS CAN BE OBTAINED FASTER THAN THE FIRST.
C
C OUTPUT PARAMETERS
C
C X FOR I=1,...,N
C
C X(I) = X(1)+(-1)**(I-1)*X(N)
C
C + THE SUM FROM K=2 TO K=N-1
C
C 2*X(K)*COS((K-1)*(I-1)*PI/(N-1))
C
C A CALL OF COST FOLLOWED BY ANOTHER CALL OF
C COST WILL MULTIPLY THE SEQUENCE X BY 2*(N-1)
C HENCE COST IS THE UNNORMALIZED INVERSE
C OF ITSELF.
C
C WSAVE CONTAINS INITIALIZATION CALCULATIONS WHICH MUST NOT BE
C DESTROYED BETWEEN CALLS OF COST.
C
SUBROUTINE COST (N,X,WSAVE)
DIMENSION X(*) ,WSAVE(*)
C
NM1 = N-1
NP1 = N+1
NS2 = N/2
IF (N-2) 106,101,102
101 X1H = X(1)+X(2)
X(2) = X(1)-X(2)
X(1) = X1H
RETURN
102 IF (N .GT. 3) GO TO 103
X1P3 = X(1)+X(3)
TX2 = X(2)+X(2)
X(2) = X(1)-X(3)
X(1) = X1P3+TX2
X(3) = X1P3-TX2
RETURN
103 C1 = X(1)-X(N)
X(1) = X(1)+X(N)
DO 104 K=2,NS2
KC = NP1-K
T1 = X(K)+X(KC)
T2 = X(K)-X(KC)
C1 = C1+WSAVE(KC)*T2
T2 = WSAVE(K)*T2
X(K) = T1-T2
X(KC) = T1+T2
104 CONTINUE
MODN = MOD(N,2)
IF (MODN .NE. 0) X(NS2+1) = X(NS2+1)+X(NS2+1)
CALL RFFTF (NM1,X,WSAVE(N+1))
XIM2 = X(2)
X(2) = C1
DO 105 I=4,N,2
XI = X(I)
X(I) = X(I-2)-X(I-1)
X(I-1) = XIM2
XIM2 = XI
105 CONTINUE
IF (MODN .NE. 0) X(N) = XIM2
106 RETURN
END
C SUBROUTINE RFFTF(N,R,WSAVE)
C
C SUBROUTINE RFFTF COMPUTES THE FOURIER COEFFICIENTS OF A REAL
C PERODIC SEQUENCE (FOURIER ANALYSIS). THE TRANSFORM IS DEFINED
C BELOW AT OUTPUT PARAMETER R.
C
C INPUT PARAMETERS
C
C N THE LENGTH OF THE ARRAY R TO BE TRANSFORMED. THE METHOD
C IS MOST EFFICIENT WHEN N IS A PRODUCT OF SMALL PRIMES.
C N MAY CHANGE SO LONG AS DIFFERENT WORK ARRAYS ARE PROVIDED
C
C R A REAL ARRAY OF LENGTH N WHICH CONTAINS THE SEQUENCE
C TO BE TRANSFORMED
C
C WSAVE A WORK ARRAY WHICH MUST BE DIMENSIONED AT LEAST 2*N+15.
C IN THE PROGRAM THAT CALLS RFFTF. THE WSAVE ARRAY MUST BE
C INITIALIZED BY CALLING SUBROUTINE RFFTI(N,WSAVE) AND A
C DIFFERENT WSAVE ARRAY MUST BE USED FOR EACH DIFFERENT
C VALUE OF N. THIS INITIALIZATION DOES NOT HAVE TO BE
C REPEATED SO LONG AS N REMAINS UNCHANGED THUS SUBSEQUENT
C TRANSFORMS CAN BE OBTAINED FASTER THAN THE FIRST.
C THE SAME WSAVE ARRAY CAN BE USED BY RFFTF AND RFFTB.
C
C
C OUTPUT PARAMETERS
C
C R R(1) = THE SUM FROM I=1 TO I=N OF R(I)
C
C IF N IS EVEN SET L =N/2 , IF N IS ODD SET L = (N+1)/2
C
C THEN FOR K = 2,...,L
C
C R(2*K-2) = THE SUM FROM I = 1 TO I = N OF
C
C R(I)*COS((K-1)*(I-1)*2*PI/N)
C
C R(2*K-1) = THE SUM FROM I = 1 TO I = N OF
C
C -R(I)*SIN((K-1)*(I-1)*2*PI/N)
C
C IF N IS EVEN
C
C R(N) = THE SUM FROM I = 1 TO I = N OF
C
C (-1)**(I-1)*R(I)
C
C ***** NOTE
C THIS TRANSFORM IS UNNORMALIZED SINCE A CALL OF RFFTF
C FOLLOWED BY A CALL OF RFFTB WILL MULTIPLY THE INPUT
C SEQUENCE BY N.
C
C WSAVE CONTAINS RESULTS WHICH MUST NOT BE DESTROYED BETWEEN
C CALLS OF RFFTF OR RFFTB.
C
SUBROUTINE RFFTF (N,R,WSAVE)
DIMENSION R(*) ,WSAVE(*)
C
IF (N .EQ. 1) RETURN
CALL RFFTF1 (N,R,WSAVE,WSAVE(N+1),WSAVE(2*N+1))
RETURN
END
SUBROUTINE RFFTF1 (N,C,CH,WA,IFAC)
!bjj START (fix for compatibility in double precision):
!rm DIMENSION CH(*) ,C(*) ,WA(*) ,IFAC(*)
USE PRECISION
REAL(ReKi), DIMENSION(*) :: IFAC
DIMENSION CH(*) ,C(*) ,WA(*)
!bjj End
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
IX2 = IW+IDO
IX3 = IX2+IDO
IF (NA .NE. 0) GO TO 101
CALL RADF4 (IDO,L1,C,CH,WA(IW),WA(IX2),WA(IX3))
GO TO 110
101 CALL RADF4 (IDO,L1,CH,C,WA(IW),WA(IX2),WA(IX3))
GO TO 110
102 IF (IP .NE. 2) GO TO 104
IF (NA .NE. 0) GO TO 103
CALL RADF2 (IDO,L1,C,CH,WA(IW))
GO TO 110
103 CALL RADF2 (IDO,L1,CH,C,WA(IW))
GO TO 110
104 IF (IP .NE. 3) GO TO 106
IX2 = IW+IDO
IF (NA .NE. 0) GO TO 105
CALL RADF3 (IDO,L1,C,CH,WA(IW),WA(IX2))
GO TO 110
105 CALL RADF3 (IDO,L1,CH,C,WA(IW),WA(IX2))
GO TO 110
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 RADF5 (IDO,L1,C,CH,WA(IW),WA(IX2),WA(IX3),WA(IX4))
GO TO 110
107 CALL RADF5 (IDO,L1,CH,C,WA(IW),WA(IX2),WA(IX3),WA(IX4))
GO TO 110
108 IF (IDO .EQ. 1) NA = 1-NA
IF (NA .NE. 0) GO TO 109
CALL RADFG (IDO,IP,L1,IDL1,C,C,C,CH,CH,WA(IW))
NA = 1
GO TO 110
109 CALL RADFG (IDO,IP,L1,IDL1,CH,CH,CH,C,C,WA(IW))
NA = 0
110 L2 = L1
111 CONTINUE
IF (NA .EQ. 1) RETURN
DO 112 I=1,N
C(I) = CH(I)
112 CONTINUE
RETURN
END
SUBROUTINE RADF2 (IDO,L1,CC,CH,WA1)
DIMENSION CH(IDO,2,L1) ,CC(IDO,L1,2) ,
1 WA1(*)
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
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
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
107 RETURN
END
SUBROUTINE RADF3 (IDO,L1,CC,CH,WA1,WA2)
DIMENSION CH(IDO,3,L1) ,CC(IDO,L1,3) ,
1 WA1(*) ,WA2(*)
DATA TAUR,TAUI /-.5,.866025403784439/
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
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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C(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
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
107 RETURN
END
SUBROUTINE RADF5 (IDO,L1,CC,CH,WA1,WA2,WA3,WA4)
DIMENSION CC(IDO,L1,5) ,CH(IDO,5,L1) ,
1 WA1(*) ,WA2(*) ,WA3(*) ,WA4(*)
DATA TR11,TI11,TR12,TI12 /.309016994374947,.951056516295154,
1-.809016994374947,.587785252292473/
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
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