forked from SLICOT/SLICOT-Reference
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDG01MD.f
More file actions
217 lines (217 loc) · 5.91 KB
/
Copy pathDG01MD.f
File metadata and controls
217 lines (217 loc) · 5.91 KB
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
SUBROUTINE DG01MD( INDI, N, XR, XI, INFO )
C
C PURPOSE
C
C To compute the discrete Fourier transform, or inverse transform,
C of a complex signal.
C
C ARGUMENTS
C
C Mode Parameters
C
C INDI CHARACTER*1
C Indicates whether a Fourier transform or inverse Fourier
C transform is to be performed as follows:
C = 'D': (Direct) Fourier transform;
C = 'I': Inverse Fourier transform.
C
C Input/Output Parameters
C
C N (input) INTEGER
C The number of complex samples. N must be a power of 2.
C N >= 2.
C
C XR (input/output) DOUBLE PRECISION array, dimension (N)
C On entry, this array must contain the real part of either
C the complex signal z if INDI = 'D', or f(z) if INDI = 'I'.
C On exit, this array contains either the real part of the
C computed Fourier transform f(z) if INDI = 'D', or the
C inverse Fourier transform z of f(z) if INDI = 'I'.
C
C XI (input/output) DOUBLE PRECISION array, dimension (N)
C On entry, this array must contain the imaginary part of
C either z if INDI = 'D', or f(z) if INDI = 'I'.
C On exit, this array contains either the imaginary part of
C f(z) if INDI = 'D', or z if INDI = 'I'.
C
C Error Indicator
C
C INFO INTEGER
C = 0: successful exit;
C < 0: if INFO = -i, the i-th argument had an illegal
C value.
C
C METHOD
C
C If INDI = 'D', then the routine performs a discrete Fourier
C transform on the complex signal Z(i), i = 1,2,...,N. If the result
C is denoted by FZ(k), k = 1,2,...,N, then the relationship between
C Z and FZ is given by the formula:
C
C N ((k-1)*(i-1))
C FZ(k) = SUM ( Z(i) * V ),
C i=1
C 2
C where V = exp( -2*pi*j/N ) and j = -1.
C
C If INDI = 'I', then the routine performs an inverse discrete
C Fourier transform on the complex signal FZ(k), k = 1,2,...,N. If
C the result is denoted by Z(i), i = 1,2,...,N, then the
C relationship between Z and FZ is given by the formula:
C
C N ((k-1)*(i-1))
C Z(i) = SUM ( FZ(k) * W ),
C k=1
C
C where W = exp( 2*pi*j/N ).
C
C Note that a discrete Fourier transform, followed by an inverse
C discrete Fourier transform, will result in a signal which is a
C factor N larger than the original input signal.
C
C REFERENCES
C
C [1] Rabiner, L.R. and Rader, C.M.
C Digital Signal Processing.
C IEEE Press, 1972.
C
C NUMERICAL ASPECTS
C
C The algorithm requires 0( N*log(N) ) operations.
C
C CONTRIBUTOR
C
C Release 3.0: V. Sima, Katholieke Univ. Leuven, Belgium, Feb. 1997.
C Supersedes Release 2.0 routine DG01AD by R. Dekeyser, State
C University of Gent, Belgium.
C
C REVISIONS
C
C -
C
C KEYWORDS
C
C Complex signals, digital signal processing, fast Fourier
C transform.
C
C ******************************************************************
C
C .. Parameters ..
DOUBLE PRECISION ZERO, HALF, ONE, TWO, EIGHT
PARAMETER ( ZERO = 0.0D0, HALF = 0.5D0, ONE = 1.0D0,
$ TWO = 2.0D0, EIGHT = 8.0D0 )
C .. Scalar Arguments ..
CHARACTER INDI
INTEGER INFO, N
C .. Array Arguments ..
DOUBLE PRECISION XI(*), XR(*)
C .. Local Scalars ..
LOGICAL LINDI
INTEGER I, J, K, L, M
DOUBLE PRECISION PI2, TI, TR, WHELP, WI, WR, WSTPI, WSTPR
C .. External Functions ..
LOGICAL LSAME
EXTERNAL LSAME
C .. External Subroutines ..
EXTERNAL XERBLA
C .. Intrinsic Functions ..
INTRINSIC ATAN, DBLE, MOD, SIN
C .. Executable Statements ..
C
INFO = 0
LINDI = LSAME( INDI, 'D' )
C
C Test the input scalar arguments.
C
IF( .NOT.LINDI .AND. .NOT.LSAME( INDI, 'I' ) ) THEN
INFO = -1
ELSE
J = 0
IF( N.GE.2 ) THEN
J = N
C WHILE ( MOD( J, 2 ).EQ.0 ) DO
10 CONTINUE
IF ( MOD( J, 2 ).EQ.0 ) THEN
J = J/2
GO TO 10
END IF
C END WHILE 10
END IF
IF ( J.NE.1 ) INFO = -2
END IF
C
IF ( INFO.NE.0 ) THEN
C
C Error return.
C
CALL XERBLA( 'DG01MD', -INFO )
RETURN
END IF
C
C Inplace shuffling of data.
C
J = 1
C
DO 30 I = 1, N
IF ( J.GT.I ) THEN
TR = XR(I)
TI = XI(I)
XR(I) = XR(J)
XI(I) = XI(J)
XR(J) = TR
XI(J) = TI
END IF
K = N/2
C REPEAT
20 IF ( J.GT.K ) THEN
J = J - K
K = K/2
IF ( K.GE.2 ) GO TO 20
END IF
C UNTIL ( K.LT.2 )
J = J + K
30 CONTINUE
C
C Transform by decimation in time.
C
PI2 = EIGHT*ATAN( ONE )
IF ( LINDI ) PI2 = -PI2
C
I = 1
C
C WHILE ( I.LT.N ) DO
C
40 IF ( I.LT.N ) THEN
L = 2*I
WHELP = PI2/DBLE( L )
WSTPI = SIN( WHELP )
WHELP = SIN( HALF*WHELP )
WSTPR = -TWO*WHELP*WHELP
WR = ONE
WI = ZERO
C
DO 60 J = 1, I
C
DO 50 K = J, N, L
M = K + I
TR = WR*XR(M) - WI*XI(M)
TI = WR*XI(M) + WI*XR(M)
XR(M) = XR(K) - TR
XI(M) = XI(K) - TI
XR(K) = XR(K) + TR
XI(K) = XI(K) + TI
50 CONTINUE
C
WHELP = WR
WR = WR + WR*WSTPR - WI*WSTPI
WI = WI + WHELP*WSTPI + WI*WSTPR
60 CONTINUE
C
I = L
GO TO 40
C END WHILE 40
END IF
C
RETURN
C *** Last line of DG01MD ***
END