line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
/* |
2
|
|
|
|
|
|
|
Fast Fourier/Cosine/Sine Transform |
3
|
|
|
|
|
|
|
dimension :one |
4
|
|
|
|
|
|
|
data length :power of 2 |
5
|
|
|
|
|
|
|
decimation :frequency |
6
|
|
|
|
|
|
|
radix :4, 2 |
7
|
|
|
|
|
|
|
data :inplace |
8
|
|
|
|
|
|
|
table :use |
9
|
|
|
|
|
|
|
functions |
10
|
|
|
|
|
|
|
cdft: Complex Discrete Fourier Transform |
11
|
|
|
|
|
|
|
rdft: Real Discrete Fourier Transform |
12
|
|
|
|
|
|
|
ddct: Discrete Cosine Transform |
13
|
|
|
|
|
|
|
ddst: Discrete Sine Transform |
14
|
|
|
|
|
|
|
dfct: Cosine Transform of RDFT (Real Symmetric DFT) |
15
|
|
|
|
|
|
|
dfst: Sine Transform of RDFT (Real Anti-symmetric DFT) |
16
|
|
|
|
|
|
|
function prototypes |
17
|
|
|
|
|
|
|
void _cdft(int, int, double *, int *, double *); |
18
|
|
|
|
|
|
|
void _rdft(int, int, double *, int *, double *); |
19
|
|
|
|
|
|
|
void _ddct(int, int, double *, int *, double *); |
20
|
|
|
|
|
|
|
void _ddst(int, int, double *, int *, double *); |
21
|
|
|
|
|
|
|
void _dfct(int, double *, double *, int *, double *); |
22
|
|
|
|
|
|
|
void _dfst(int, double *, double *, int *, double *); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
-------- Complex DFT (Discrete Fourier Transform) -------- |
26
|
|
|
|
|
|
|
[definition] |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
X[k] = sum_j=0^n-1 x[j]*exp(2*pi*i*j*k/n), 0<=k
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
X[k] = sum_j=0^n-1 x[j]*exp(-2*pi*i*j*k/n), 0<=k
|
31
|
|
|
|
|
|
|
(notes: sum_j=0^n-1 is a summation from j=0 to n-1) |
32
|
|
|
|
|
|
|
[usage] |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
ip[0] = 0; // first time only |
35
|
|
|
|
|
|
|
_cdft(2*n, 1, a, ip, w); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
ip[0] = 0; // first time only |
38
|
|
|
|
|
|
|
_cdft(2*n, -1, a, ip, w); |
39
|
|
|
|
|
|
|
[parameters] |
40
|
|
|
|
|
|
|
2*n :data length (int) |
41
|
|
|
|
|
|
|
n >= 1, n = power of 2 |
42
|
|
|
|
|
|
|
a[0...2*n-1] :input/output data (double *) |
43
|
|
|
|
|
|
|
input data |
44
|
|
|
|
|
|
|
a[2*j] = Re(x[j]), |
45
|
|
|
|
|
|
|
a[2*j+1] = Im(x[j]), 0<=j
|
46
|
|
|
|
|
|
|
output data |
47
|
|
|
|
|
|
|
a[2*k] = Re(X[k]), |
48
|
|
|
|
|
|
|
a[2*k+1] = Im(X[k]), 0<=k
|
49
|
|
|
|
|
|
|
ip[0...*] :work area for bit reversal (int *) |
50
|
|
|
|
|
|
|
length of ip >= 2+sqrt(n) |
51
|
|
|
|
|
|
|
strictly, |
52
|
|
|
|
|
|
|
length of ip >= |
53
|
|
|
|
|
|
|
2+(1<<(int)(log(n+0.5)/log(2))/2). |
54
|
|
|
|
|
|
|
ip[0],ip[1] are pointers of the cos/sin table. |
55
|
|
|
|
|
|
|
w[0...n/2-1] :cos/sin table (double *) |
56
|
|
|
|
|
|
|
w[],ip[] are initialized if ip[0] == 0. |
57
|
|
|
|
|
|
|
[remark] |
58
|
|
|
|
|
|
|
Inverse of |
59
|
|
|
|
|
|
|
_cdft(2*n, -1, a, ip, w); |
60
|
|
|
|
|
|
|
is |
61
|
|
|
|
|
|
|
_cdft(2*n, 1, a, ip, w); |
62
|
|
|
|
|
|
|
for (j = 0; j <= 2 * n - 1; j++) { |
63
|
|
|
|
|
|
|
a[j] *= 1.0 / n; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
-------- Real DFT / Inverse of Real DFT -------- |
69
|
|
|
|
|
|
|
[definition] |
70
|
|
|
|
|
|
|
RDFT |
71
|
|
|
|
|
|
|
R[k] = sum_j=0^n-1 a[j]*cos(2*pi*j*k/n), 0<=k<=n/2 |
72
|
|
|
|
|
|
|
I[k] = sum_j=0^n-1 a[j]*sin(2*pi*j*k/n), 0
|
73
|
|
|
|
|
|
|
IRDFT (excluding scale) |
74
|
|
|
|
|
|
|
a[k] = (R[0] + R[n/2]*cos(pi*k))/2 + |
75
|
|
|
|
|
|
|
sum_j=1^n/2-1 R[j]*cos(2*pi*j*k/n) + |
76
|
|
|
|
|
|
|
sum_j=1^n/2-1 I[j]*sin(2*pi*j*k/n), 0<=k
|
77
|
|
|
|
|
|
|
[usage] |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
ip[0] = 0; // first time only |
80
|
|
|
|
|
|
|
_rdft(n, 1, a, ip, w); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
ip[0] = 0; // first time only |
83
|
|
|
|
|
|
|
_rdft(n, -1, a, ip, w); |
84
|
|
|
|
|
|
|
[parameters] |
85
|
|
|
|
|
|
|
n :data length (int) |
86
|
|
|
|
|
|
|
n >= 2, n = power of 2 |
87
|
|
|
|
|
|
|
a[0...n-1] :input/output data (double *) |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
output data |
90
|
|
|
|
|
|
|
a[2*k] = R[k], 0<=k
|
91
|
|
|
|
|
|
|
a[2*k+1] = I[k], 0
|
92
|
|
|
|
|
|
|
a[1] = R[n/2] |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
input data |
95
|
|
|
|
|
|
|
a[2*j] = R[j], 0<=j
|
96
|
|
|
|
|
|
|
a[2*j+1] = I[j], 0
|
97
|
|
|
|
|
|
|
a[1] = R[n/2] |
98
|
|
|
|
|
|
|
ip[0...*] :work area for bit reversal (int *) |
99
|
|
|
|
|
|
|
length of ip >= 2+sqrt(n/2) |
100
|
|
|
|
|
|
|
strictly, |
101
|
|
|
|
|
|
|
length of ip >= |
102
|
|
|
|
|
|
|
2+(1<<(int)(log(n/2+0.5)/log(2))/2). |
103
|
|
|
|
|
|
|
ip[0],ip[1] are pointers of the cos/sin table. |
104
|
|
|
|
|
|
|
w[0...n/2-1] :cos/sin table (double *) |
105
|
|
|
|
|
|
|
w[],ip[] are initialized if ip[0] == 0. |
106
|
|
|
|
|
|
|
[remark] |
107
|
|
|
|
|
|
|
Inverse of |
108
|
|
|
|
|
|
|
_rdft(n, 1, a, ip, w); |
109
|
|
|
|
|
|
|
is |
110
|
|
|
|
|
|
|
_rdft(n, -1, a, ip, w); |
111
|
|
|
|
|
|
|
for (j = 0; j <= n - 1; j++) { |
112
|
|
|
|
|
|
|
a[j] *= 2.0 / n; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
-------- DCT (Discrete Cosine Transform) / Inverse of DCT -------- |
118
|
|
|
|
|
|
|
[definition] |
119
|
|
|
|
|
|
|
IDCT (excluding scale) |
120
|
|
|
|
|
|
|
C[k] = sum_j=0^n-1 a[j]*cos(pi*j*(k+1/2)/n), 0<=k
|
121
|
|
|
|
|
|
|
DCT |
122
|
|
|
|
|
|
|
C[k] = sum_j=0^n-1 a[j]*cos(pi*(j+1/2)*k/n), 0<=k
|
123
|
|
|
|
|
|
|
[usage] |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
ip[0] = 0; // first time only |
126
|
|
|
|
|
|
|
_ddct(n, 1, a, ip, w); |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
ip[0] = 0; // first time only |
129
|
|
|
|
|
|
|
_ddct(n, -1, a, ip, w); |
130
|
|
|
|
|
|
|
[parameters] |
131
|
|
|
|
|
|
|
n :data length (int) |
132
|
|
|
|
|
|
|
n >= 2, n = power of 2 |
133
|
|
|
|
|
|
|
a[0...n-1] :input/output data (double *) |
134
|
|
|
|
|
|
|
output data |
135
|
|
|
|
|
|
|
a[k] = C[k], 0<=k
|
136
|
|
|
|
|
|
|
ip[0...*] :work area for bit reversal (int *) |
137
|
|
|
|
|
|
|
length of ip >= 2+sqrt(n/2) |
138
|
|
|
|
|
|
|
strictly, |
139
|
|
|
|
|
|
|
length of ip >= |
140
|
|
|
|
|
|
|
2+(1<<(int)(log(n/2+0.5)/log(2))/2). |
141
|
|
|
|
|
|
|
ip[0],ip[1] are pointers of the cos/sin table. |
142
|
|
|
|
|
|
|
w[0...n*5/4-1] :cos/sin table (double *) |
143
|
|
|
|
|
|
|
w[],ip[] are initialized if ip[0] == 0. |
144
|
|
|
|
|
|
|
[remark] |
145
|
|
|
|
|
|
|
Inverse of |
146
|
|
|
|
|
|
|
_ddct(n, -1, a, ip, w); |
147
|
|
|
|
|
|
|
is |
148
|
|
|
|
|
|
|
a[0] *= 0.5; |
149
|
|
|
|
|
|
|
_ddct(n, 1, a, ip, w); |
150
|
|
|
|
|
|
|
for (j = 0; j <= n - 1; j++) { |
151
|
|
|
|
|
|
|
a[j] *= 2.0 / n; |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
-------- DST (Discrete Sine Transform) / Inverse of DST -------- |
157
|
|
|
|
|
|
|
[definition] |
158
|
|
|
|
|
|
|
IDST (excluding scale) |
159
|
|
|
|
|
|
|
S[k] = sum_j=1^n A[j]*sin(pi*j*(k+1/2)/n), 0<=k
|
160
|
|
|
|
|
|
|
DST |
161
|
|
|
|
|
|
|
S[k] = sum_j=0^n-1 a[j]*sin(pi*(j+1/2)*k/n), 0
|
162
|
|
|
|
|
|
|
[usage] |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
ip[0] = 0; // first time only |
165
|
|
|
|
|
|
|
_ddst(n, 1, a, ip, w); |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
ip[0] = 0; // first time only |
168
|
|
|
|
|
|
|
_ddst(n, -1, a, ip, w); |
169
|
|
|
|
|
|
|
[parameters] |
170
|
|
|
|
|
|
|
n :data length (int) |
171
|
|
|
|
|
|
|
n >= 2, n = power of 2 |
172
|
|
|
|
|
|
|
a[0...n-1] :input/output data (double *) |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
input data |
175
|
|
|
|
|
|
|
a[j] = A[j], 0
|
176
|
|
|
|
|
|
|
a[0] = A[n] |
177
|
|
|
|
|
|
|
output data |
178
|
|
|
|
|
|
|
a[k] = S[k], 0<=k
|
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
output data |
181
|
|
|
|
|
|
|
a[k] = S[k], 0
|
182
|
|
|
|
|
|
|
a[0] = S[n] |
183
|
|
|
|
|
|
|
ip[0...*] :work area for bit reversal (int *) |
184
|
|
|
|
|
|
|
length of ip >= 2+sqrt(n/2) |
185
|
|
|
|
|
|
|
strictly, |
186
|
|
|
|
|
|
|
length of ip >= |
187
|
|
|
|
|
|
|
2+(1<<(int)(log(n/2+0.5)/log(2))/2). |
188
|
|
|
|
|
|
|
ip[0],ip[1] are pointers of the cos/sin table. |
189
|
|
|
|
|
|
|
w[0...n*5/4-1] :cos/sin table (double *) |
190
|
|
|
|
|
|
|
w[],ip[] are initialized if ip[0] == 0. |
191
|
|
|
|
|
|
|
[remark] |
192
|
|
|
|
|
|
|
Inverse of |
193
|
|
|
|
|
|
|
_ddst(n, -1, a, ip, w); |
194
|
|
|
|
|
|
|
is |
195
|
|
|
|
|
|
|
a[0] *= 0.5; |
196
|
|
|
|
|
|
|
_ddst(n, 1, a, ip, w); |
197
|
|
|
|
|
|
|
for (j = 0; j <= n - 1; j++) { |
198
|
|
|
|
|
|
|
a[j] *= 2.0 / n; |
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
. |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
-------- Cosine Transform of RDFT (Real Symmetric DFT) -------- |
204
|
|
|
|
|
|
|
[definition] |
205
|
|
|
|
|
|
|
C[k] = sum_j=0^n a[j]*cos(pi*j*k/n), 0<=k<=n |
206
|
|
|
|
|
|
|
[usage] |
207
|
|
|
|
|
|
|
ip[0] = 0; // first time only |
208
|
|
|
|
|
|
|
_dfct(n, a, t, ip, w); |
209
|
|
|
|
|
|
|
[parameters] |
210
|
|
|
|
|
|
|
n :data length - 1 (int) |
211
|
|
|
|
|
|
|
n >= 2, n = power of 2 |
212
|
|
|
|
|
|
|
a[0...n] :input/output data (double *) |
213
|
|
|
|
|
|
|
output data |
214
|
|
|
|
|
|
|
a[k] = C[k], 0<=k<=n |
215
|
|
|
|
|
|
|
t[0...n/2] :work area (double *) |
216
|
|
|
|
|
|
|
ip[0...*] :work area for bit reversal (int *) |
217
|
|
|
|
|
|
|
length of ip >= 2+sqrt(n/4) |
218
|
|
|
|
|
|
|
strictly, |
219
|
|
|
|
|
|
|
length of ip >= |
220
|
|
|
|
|
|
|
2+(1<<(int)(log(n/4+0.5)/log(2))/2). |
221
|
|
|
|
|
|
|
ip[0],ip[1] are pointers of the cos/sin table. |
222
|
|
|
|
|
|
|
w[0...n*5/8-1] :cos/sin table (double *) |
223
|
|
|
|
|
|
|
w[],ip[] are initialized if ip[0] == 0. |
224
|
|
|
|
|
|
|
[remark] |
225
|
|
|
|
|
|
|
Inverse of |
226
|
|
|
|
|
|
|
a[0] *= 0.5; |
227
|
|
|
|
|
|
|
a[n] *= 0.5; |
228
|
|
|
|
|
|
|
_dfct(n, a, t, ip, w); |
229
|
|
|
|
|
|
|
is |
230
|
|
|
|
|
|
|
a[0] *= 0.5; |
231
|
|
|
|
|
|
|
a[n] *= 0.5; |
232
|
|
|
|
|
|
|
_dfct(n, a, t, ip, w); |
233
|
|
|
|
|
|
|
for (j = 0; j <= n; j++) { |
234
|
|
|
|
|
|
|
a[j] *= 2.0 / n; |
235
|
|
|
|
|
|
|
} |
236
|
|
|
|
|
|
|
. |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
-------- Sine Transform of RDFT (Real Anti-symmetric DFT) -------- |
240
|
|
|
|
|
|
|
[definition] |
241
|
|
|
|
|
|
|
S[k] = sum_j=1^n-1 a[j]*sin(pi*j*k/n), 0
|
242
|
|
|
|
|
|
|
[usage] |
243
|
|
|
|
|
|
|
ip[0] = 0; // first time only |
244
|
|
|
|
|
|
|
_dfst(n, a, t, ip, w); |
245
|
|
|
|
|
|
|
[parameters] |
246
|
|
|
|
|
|
|
n :data length + 1 (int) |
247
|
|
|
|
|
|
|
n >= 2, n = power of 2 |
248
|
|
|
|
|
|
|
a[0...n-1] :input/output data (double *) |
249
|
|
|
|
|
|
|
output data |
250
|
|
|
|
|
|
|
a[k] = S[k], 0
|
251
|
|
|
|
|
|
|
(a[0] is used for work area) |
252
|
|
|
|
|
|
|
t[0...n/2-1] :work area (double *) |
253
|
|
|
|
|
|
|
ip[0...*] :work area for bit reversal (int *) |
254
|
|
|
|
|
|
|
length of ip >= 2+sqrt(n/4) |
255
|
|
|
|
|
|
|
strictly, |
256
|
|
|
|
|
|
|
length of ip >= |
257
|
|
|
|
|
|
|
2+(1<<(int)(log(n/4+0.5)/log(2))/2). |
258
|
|
|
|
|
|
|
ip[0],ip[1] are pointers of the cos/sin table. |
259
|
|
|
|
|
|
|
w[0...n*5/8-1] :cos/sin table (double *) |
260
|
|
|
|
|
|
|
w[],ip[] are initialized if ip[0] == 0. |
261
|
|
|
|
|
|
|
[remark] |
262
|
|
|
|
|
|
|
Inverse of |
263
|
|
|
|
|
|
|
_dfst(n, a, t, ip, w); |
264
|
|
|
|
|
|
|
is |
265
|
|
|
|
|
|
|
_dfst(n, a, t, ip, w); |
266
|
|
|
|
|
|
|
for (j = 1; j <= n - 1; j++) { |
267
|
|
|
|
|
|
|
a[j] *= 2.0 / n; |
268
|
|
|
|
|
|
|
} |
269
|
|
|
|
|
|
|
. |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
Appendix : |
273
|
|
|
|
|
|
|
The cos/sin table is recalculated when the larger table required. |
274
|
|
|
|
|
|
|
w[] and ip[] are compatible with all routines. |
275
|
|
|
|
|
|
|
*/ |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
|
278
|
8
|
|
|
|
|
|
void _cdft(int n, int isgn, double *a, int *ip, double *w) |
279
|
|
|
|
|
|
|
{ |
280
|
|
|
|
|
|
|
void makewt(int nw, int *ip, double *w); |
281
|
|
|
|
|
|
|
void bitrv2(int n, int *ip, double *a); |
282
|
|
|
|
|
|
|
void bitrv2conj(int n, int *ip, double *a); |
283
|
|
|
|
|
|
|
void cftfsub(int n, double *a, double *w); |
284
|
|
|
|
|
|
|
void cftbsub(int n, double *a, double *w); |
285
|
|
|
|
|
|
|
|
286
|
8
|
100
|
|
|
|
|
if (n > (ip[0] << 2)) { |
287
|
3
|
|
|
|
|
|
makewt(n >> 2, ip, w); |
288
|
|
|
|
|
|
|
} |
289
|
8
|
50
|
|
|
|
|
if (n > 4) { |
290
|
8
|
100
|
|
|
|
|
if (isgn >= 0) { |
291
|
4
|
|
|
|
|
|
bitrv2(n, ip + 2, a); |
292
|
4
|
|
|
|
|
|
cftfsub(n, a, w); |
293
|
|
|
|
|
|
|
} else { |
294
|
4
|
|
|
|
|
|
bitrv2conj(n, ip + 2, a); |
295
|
8
|
|
|
|
|
|
cftbsub(n, a, w); |
296
|
|
|
|
|
|
|
} |
297
|
0
|
0
|
|
|
|
|
} else if (n == 4) { |
298
|
0
|
|
|
|
|
|
cftfsub(n, a, w); |
299
|
|
|
|
|
|
|
} |
300
|
8
|
|
|
|
|
|
} |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
|
303
|
263
|
|
|
|
|
|
void _rdft(int n, int isgn, double *a, int *ip, double *w) |
304
|
|
|
|
|
|
|
{ |
305
|
|
|
|
|
|
|
void makewt(int nw, int *ip, double *w); |
306
|
|
|
|
|
|
|
void makect(int nc, int *ip, double *c); |
307
|
|
|
|
|
|
|
void bitrv2(int n, int *ip, double *a); |
308
|
|
|
|
|
|
|
void cftfsub(int n, double *a, double *w); |
309
|
|
|
|
|
|
|
void cftbsub(int n, double *a, double *w); |
310
|
|
|
|
|
|
|
void rftfsub(int n, double *a, int nc, double *c); |
311
|
|
|
|
|
|
|
void rftbsub(int n, double *a, int nc, double *c); |
312
|
|
|
|
|
|
|
int nw, nc; |
313
|
|
|
|
|
|
|
double xi; |
314
|
|
|
|
|
|
|
|
315
|
263
|
|
|
|
|
|
nw = ip[0]; |
316
|
263
|
100
|
|
|
|
|
if (n > (nw << 2)) { |
317
|
17
|
|
|
|
|
|
nw = n >> 2; |
318
|
17
|
|
|
|
|
|
makewt(nw, ip, w); |
319
|
|
|
|
|
|
|
} |
320
|
263
|
|
|
|
|
|
nc = ip[1]; |
321
|
263
|
100
|
|
|
|
|
if (n > (nc << 2)) { |
322
|
17
|
|
|
|
|
|
nc = n >> 2; |
323
|
17
|
|
|
|
|
|
makect(nc, ip, w + nw); |
324
|
|
|
|
|
|
|
} |
325
|
263
|
100
|
|
|
|
|
if (isgn >= 0) { |
326
|
253
|
50
|
|
|
|
|
if (n > 4) { |
327
|
253
|
|
|
|
|
|
bitrv2(n, ip + 2, a); |
328
|
253
|
|
|
|
|
|
cftfsub(n, a, w); |
329
|
253
|
|
|
|
|
|
rftfsub(n, a, nc, w + nw); |
330
|
0
|
0
|
|
|
|
|
} else if (n == 4) { |
331
|
0
|
|
|
|
|
|
cftfsub(n, a, w); |
332
|
|
|
|
|
|
|
} |
333
|
253
|
|
|
|
|
|
xi = a[0] - a[1]; |
334
|
253
|
|
|
|
|
|
a[0] += a[1]; |
335
|
253
|
|
|
|
|
|
a[1] = xi; |
336
|
|
|
|
|
|
|
} else { |
337
|
10
|
|
|
|
|
|
a[1] = 0.5 * (a[0] - a[1]); |
338
|
10
|
|
|
|
|
|
a[0] -= a[1]; |
339
|
10
|
50
|
|
|
|
|
if (n > 4) { |
340
|
10
|
|
|
|
|
|
rftbsub(n, a, nc, w + nw); |
341
|
10
|
|
|
|
|
|
bitrv2(n, ip + 2, a); |
342
|
10
|
|
|
|
|
|
cftbsub(n, a, w); |
343
|
0
|
0
|
|
|
|
|
} else if (n == 4) { |
344
|
0
|
|
|
|
|
|
cftfsub(n, a, w); |
345
|
|
|
|
|
|
|
} |
346
|
|
|
|
|
|
|
} |
347
|
263
|
|
|
|
|
|
} |
348
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
|
350
|
4
|
|
|
|
|
|
void _ddct(int n, int isgn, double *a, int *ip, double *w) |
351
|
|
|
|
|
|
|
{ |
352
|
|
|
|
|
|
|
void makewt(int nw, int *ip, double *w); |
353
|
|
|
|
|
|
|
void makect(int nc, int *ip, double *c); |
354
|
|
|
|
|
|
|
void bitrv2(int n, int *ip, double *a); |
355
|
|
|
|
|
|
|
void cftfsub(int n, double *a, double *w); |
356
|
|
|
|
|
|
|
void cftbsub(int n, double *a, double *w); |
357
|
|
|
|
|
|
|
void rftfsub(int n, double *a, int nc, double *c); |
358
|
|
|
|
|
|
|
void rftbsub(int n, double *a, int nc, double *c); |
359
|
|
|
|
|
|
|
void dctsub(int n, double *a, int nc, double *c); |
360
|
|
|
|
|
|
|
int j, nw, nc; |
361
|
|
|
|
|
|
|
double xr; |
362
|
|
|
|
|
|
|
|
363
|
4
|
|
|
|
|
|
nw = ip[0]; |
364
|
4
|
100
|
|
|
|
|
if (n > (nw << 2)) { |
365
|
2
|
|
|
|
|
|
nw = n >> 2; |
366
|
2
|
|
|
|
|
|
makewt(nw, ip, w); |
367
|
|
|
|
|
|
|
} |
368
|
4
|
|
|
|
|
|
nc = ip[1]; |
369
|
4
|
100
|
|
|
|
|
if (n > nc) { |
370
|
2
|
|
|
|
|
|
nc = n; |
371
|
2
|
|
|
|
|
|
makect(nc, ip, w + nw); |
372
|
|
|
|
|
|
|
} |
373
|
4
|
100
|
|
|
|
|
if (isgn < 0) { |
374
|
2
|
|
|
|
|
|
xr = a[n - 1]; |
375
|
16392
|
100
|
|
|
|
|
for (j = n - 2; j >= 2; j -= 2) { |
376
|
16390
|
|
|
|
|
|
a[j + 1] = a[j] - a[j - 1]; |
377
|
16390
|
|
|
|
|
|
a[j] += a[j - 1]; |
378
|
|
|
|
|
|
|
} |
379
|
2
|
|
|
|
|
|
a[1] = a[0] - xr; |
380
|
2
|
|
|
|
|
|
a[0] += xr; |
381
|
2
|
50
|
|
|
|
|
if (n > 4) { |
382
|
2
|
|
|
|
|
|
rftbsub(n, a, nc, w + nw); |
383
|
2
|
|
|
|
|
|
bitrv2(n, ip + 2, a); |
384
|
2
|
|
|
|
|
|
cftbsub(n, a, w); |
385
|
0
|
0
|
|
|
|
|
} else if (n == 4) { |
386
|
0
|
|
|
|
|
|
cftfsub(n, a, w); |
387
|
|
|
|
|
|
|
} |
388
|
|
|
|
|
|
|
} |
389
|
4
|
|
|
|
|
|
dctsub(n, a, nc, w + nw); |
390
|
4
|
100
|
|
|
|
|
if (isgn >= 0) { |
391
|
2
|
50
|
|
|
|
|
if (n > 4) { |
392
|
2
|
|
|
|
|
|
bitrv2(n, ip + 2, a); |
393
|
2
|
|
|
|
|
|
cftfsub(n, a, w); |
394
|
2
|
|
|
|
|
|
rftfsub(n, a, nc, w + nw); |
395
|
0
|
0
|
|
|
|
|
} else if (n == 4) { |
396
|
0
|
|
|
|
|
|
cftfsub(n, a, w); |
397
|
|
|
|
|
|
|
} |
398
|
2
|
|
|
|
|
|
xr = a[0] - a[1]; |
399
|
2
|
|
|
|
|
|
a[0] += a[1]; |
400
|
16392
|
100
|
|
|
|
|
for (j = 2; j < n; j += 2) { |
401
|
16390
|
|
|
|
|
|
a[j - 1] = a[j] - a[j + 1]; |
402
|
16390
|
|
|
|
|
|
a[j] += a[j + 1]; |
403
|
|
|
|
|
|
|
} |
404
|
2
|
|
|
|
|
|
a[n - 1] = xr; |
405
|
|
|
|
|
|
|
} |
406
|
4
|
|
|
|
|
|
} |
407
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
|
409
|
4
|
|
|
|
|
|
void _ddst(int n, int isgn, double *a, int *ip, double *w) |
410
|
|
|
|
|
|
|
{ |
411
|
|
|
|
|
|
|
void makewt(int nw, int *ip, double *w); |
412
|
|
|
|
|
|
|
void makect(int nc, int *ip, double *c); |
413
|
|
|
|
|
|
|
void bitrv2(int n, int *ip, double *a); |
414
|
|
|
|
|
|
|
void cftfsub(int n, double *a, double *w); |
415
|
|
|
|
|
|
|
void cftbsub(int n, double *a, double *w); |
416
|
|
|
|
|
|
|
void rftfsub(int n, double *a, int nc, double *c); |
417
|
|
|
|
|
|
|
void rftbsub(int n, double *a, int nc, double *c); |
418
|
|
|
|
|
|
|
void dstsub(int n, double *a, int nc, double *c); |
419
|
|
|
|
|
|
|
int j, nw, nc; |
420
|
|
|
|
|
|
|
double xr; |
421
|
|
|
|
|
|
|
|
422
|
4
|
|
|
|
|
|
nw = ip[0]; |
423
|
4
|
100
|
|
|
|
|
if (n > (nw << 2)) { |
424
|
2
|
|
|
|
|
|
nw = n >> 2; |
425
|
2
|
|
|
|
|
|
makewt(nw, ip, w); |
426
|
|
|
|
|
|
|
} |
427
|
4
|
|
|
|
|
|
nc = ip[1]; |
428
|
4
|
100
|
|
|
|
|
if (n > nc) { |
429
|
2
|
|
|
|
|
|
nc = n; |
430
|
2
|
|
|
|
|
|
makect(nc, ip, w + nw); |
431
|
|
|
|
|
|
|
} |
432
|
4
|
100
|
|
|
|
|
if (isgn < 0) { |
433
|
2
|
|
|
|
|
|
xr = a[n - 1]; |
434
|
16392
|
100
|
|
|
|
|
for (j = n - 2; j >= 2; j -= 2) { |
435
|
16390
|
|
|
|
|
|
a[j + 1] = -a[j] - a[j - 1]; |
436
|
16390
|
|
|
|
|
|
a[j] -= a[j - 1]; |
437
|
|
|
|
|
|
|
} |
438
|
2
|
|
|
|
|
|
a[1] = a[0] + xr; |
439
|
2
|
|
|
|
|
|
a[0] -= xr; |
440
|
2
|
50
|
|
|
|
|
if (n > 4) { |
441
|
2
|
|
|
|
|
|
rftbsub(n, a, nc, w + nw); |
442
|
2
|
|
|
|
|
|
bitrv2(n, ip + 2, a); |
443
|
2
|
|
|
|
|
|
cftbsub(n, a, w); |
444
|
0
|
0
|
|
|
|
|
} else if (n == 4) { |
445
|
0
|
|
|
|
|
|
cftfsub(n, a, w); |
446
|
|
|
|
|
|
|
} |
447
|
|
|
|
|
|
|
} |
448
|
4
|
|
|
|
|
|
dstsub(n, a, nc, w + nw); |
449
|
4
|
100
|
|
|
|
|
if (isgn >= 0) { |
450
|
2
|
50
|
|
|
|
|
if (n > 4) { |
451
|
2
|
|
|
|
|
|
bitrv2(n, ip + 2, a); |
452
|
2
|
|
|
|
|
|
cftfsub(n, a, w); |
453
|
2
|
|
|
|
|
|
rftfsub(n, a, nc, w + nw); |
454
|
0
|
0
|
|
|
|
|
} else if (n == 4) { |
455
|
0
|
|
|
|
|
|
cftfsub(n, a, w); |
456
|
|
|
|
|
|
|
} |
457
|
2
|
|
|
|
|
|
xr = a[0] - a[1]; |
458
|
2
|
|
|
|
|
|
a[0] += a[1]; |
459
|
16392
|
100
|
|
|
|
|
for (j = 2; j < n; j += 2) { |
460
|
16390
|
|
|
|
|
|
a[j - 1] = -a[j] - a[j + 1]; |
461
|
16390
|
|
|
|
|
|
a[j] -= a[j + 1]; |
462
|
|
|
|
|
|
|
} |
463
|
2
|
|
|
|
|
|
a[n - 1] = -xr; |
464
|
|
|
|
|
|
|
} |
465
|
4
|
|
|
|
|
|
} |
466
|
|
|
|
|
|
|
|
467
|
|
|
|
|
|
|
|
468
|
4
|
|
|
|
|
|
void _dfct(int n, double *a, double *t, int *ip, double *w) |
469
|
|
|
|
|
|
|
{ |
470
|
|
|
|
|
|
|
void makewt(int nw, int *ip, double *w); |
471
|
|
|
|
|
|
|
void makect(int nc, int *ip, double *c); |
472
|
|
|
|
|
|
|
void bitrv2(int n, int *ip, double *a); |
473
|
|
|
|
|
|
|
void cftfsub(int n, double *a, double *w); |
474
|
|
|
|
|
|
|
void rftfsub(int n, double *a, int nc, double *c); |
475
|
|
|
|
|
|
|
void dctsub(int n, double *a, int nc, double *c); |
476
|
|
|
|
|
|
|
int j, k, l, m, mh, nw, nc; |
477
|
|
|
|
|
|
|
double xr, xi, yr, yi; |
478
|
|
|
|
|
|
|
|
479
|
4
|
|
|
|
|
|
nw = ip[0]; |
480
|
4
|
100
|
|
|
|
|
if (n > (nw << 3)) { |
481
|
2
|
|
|
|
|
|
nw = n >> 3; |
482
|
2
|
|
|
|
|
|
makewt(nw, ip, w); |
483
|
|
|
|
|
|
|
} |
484
|
4
|
|
|
|
|
|
nc = ip[1]; |
485
|
4
|
100
|
|
|
|
|
if (n > (nc << 1)) { |
486
|
2
|
|
|
|
|
|
nc = n >> 1; |
487
|
2
|
|
|
|
|
|
makect(nc, ip, w + nw); |
488
|
|
|
|
|
|
|
} |
489
|
4
|
|
|
|
|
|
m = n >> 1; |
490
|
4
|
|
|
|
|
|
yi = a[m]; |
491
|
4
|
|
|
|
|
|
xi = a[0] + a[n]; |
492
|
4
|
|
|
|
|
|
a[0] -= a[n]; |
493
|
4
|
|
|
|
|
|
t[0] = xi - yi; |
494
|
4
|
|
|
|
|
|
t[m] = xi + yi; |
495
|
4
|
50
|
|
|
|
|
if (n > 2) { |
496
|
4
|
|
|
|
|
|
mh = m >> 1; |
497
|
16392
|
100
|
|
|
|
|
for (j = 1; j < mh; j++) { |
498
|
16388
|
|
|
|
|
|
k = m - j; |
499
|
16388
|
|
|
|
|
|
xr = a[j] - a[n - j]; |
500
|
16388
|
|
|
|
|
|
xi = a[j] + a[n - j]; |
501
|
16388
|
|
|
|
|
|
yr = a[k] - a[n - k]; |
502
|
16388
|
|
|
|
|
|
yi = a[k] + a[n - k]; |
503
|
16388
|
|
|
|
|
|
a[j] = xr; |
504
|
16388
|
|
|
|
|
|
a[k] = yr; |
505
|
16388
|
|
|
|
|
|
t[j] = xi - yi; |
506
|
16388
|
|
|
|
|
|
t[k] = xi + yi; |
507
|
|
|
|
|
|
|
} |
508
|
4
|
|
|
|
|
|
t[mh] = a[mh] + a[n - mh]; |
509
|
4
|
|
|
|
|
|
a[mh] -= a[n - mh]; |
510
|
4
|
|
|
|
|
|
dctsub(m, a, nc, w + nw); |
511
|
4
|
50
|
|
|
|
|
if (m > 4) { |
512
|
4
|
|
|
|
|
|
bitrv2(m, ip + 2, a); |
513
|
4
|
|
|
|
|
|
cftfsub(m, a, w); |
514
|
4
|
|
|
|
|
|
rftfsub(m, a, nc, w + nw); |
515
|
0
|
0
|
|
|
|
|
} else if (m == 4) { |
516
|
0
|
|
|
|
|
|
cftfsub(m, a, w); |
517
|
|
|
|
|
|
|
} |
518
|
4
|
|
|
|
|
|
a[n - 1] = a[0] - a[1]; |
519
|
4
|
|
|
|
|
|
a[1] = a[0] + a[1]; |
520
|
16392
|
100
|
|
|
|
|
for (j = m - 2; j >= 2; j -= 2) { |
521
|
16388
|
|
|
|
|
|
a[2 * j + 1] = a[j] + a[j + 1]; |
522
|
16388
|
|
|
|
|
|
a[2 * j - 1] = a[j] - a[j + 1]; |
523
|
|
|
|
|
|
|
} |
524
|
4
|
|
|
|
|
|
l = 2; |
525
|
4
|
|
|
|
|
|
m = mh; |
526
|
34
|
100
|
|
|
|
|
while (m >= 2) { |
527
|
30
|
|
|
|
|
|
dctsub(m, t, nc, w + nw); |
528
|
30
|
100
|
|
|
|
|
if (m > 4) { |
529
|
22
|
|
|
|
|
|
bitrv2(m, ip + 2, t); |
530
|
22
|
|
|
|
|
|
cftfsub(m, t, w); |
531
|
22
|
|
|
|
|
|
rftfsub(m, t, nc, w + nw); |
532
|
8
|
100
|
|
|
|
|
} else if (m == 4) { |
533
|
4
|
|
|
|
|
|
cftfsub(m, t, w); |
534
|
|
|
|
|
|
|
} |
535
|
30
|
|
|
|
|
|
a[n - l] = t[0] - t[1]; |
536
|
30
|
|
|
|
|
|
a[l] = t[0] + t[1]; |
537
|
30
|
|
|
|
|
|
k = 0; |
538
|
16388
|
100
|
|
|
|
|
for (j = 2; j < m; j += 2) { |
539
|
16358
|
|
|
|
|
|
k += l << 2; |
540
|
16358
|
|
|
|
|
|
a[k - l] = t[j] - t[j + 1]; |
541
|
16358
|
|
|
|
|
|
a[k + l] = t[j] + t[j + 1]; |
542
|
|
|
|
|
|
|
} |
543
|
30
|
|
|
|
|
|
l <<= 1; |
544
|
30
|
|
|
|
|
|
mh = m >> 1; |
545
|
16418
|
100
|
|
|
|
|
for (j = 0; j < mh; j++) { |
546
|
16388
|
|
|
|
|
|
k = m - j; |
547
|
16388
|
|
|
|
|
|
t[j] = t[m + k] - t[m + j]; |
548
|
16388
|
|
|
|
|
|
t[k] = t[m + k] + t[m + j]; |
549
|
|
|
|
|
|
|
} |
550
|
30
|
|
|
|
|
|
t[mh] = t[m + mh]; |
551
|
30
|
|
|
|
|
|
m = mh; |
552
|
|
|
|
|
|
|
} |
553
|
4
|
|
|
|
|
|
a[l] = t[0]; |
554
|
4
|
|
|
|
|
|
a[n] = t[2] - t[1]; |
555
|
4
|
|
|
|
|
|
a[0] = t[2] + t[1]; |
556
|
|
|
|
|
|
|
} else { |
557
|
0
|
|
|
|
|
|
a[1] = a[0]; |
558
|
0
|
|
|
|
|
|
a[2] = t[0]; |
559
|
0
|
|
|
|
|
|
a[0] = t[1]; |
560
|
|
|
|
|
|
|
} |
561
|
4
|
|
|
|
|
|
} |
562
|
|
|
|
|
|
|
|
563
|
|
|
|
|
|
|
|
564
|
4
|
|
|
|
|
|
void _dfst(int n, double *a, double *t, int *ip, double *w) |
565
|
|
|
|
|
|
|
{ |
566
|
|
|
|
|
|
|
void makewt(int nw, int *ip, double *w); |
567
|
|
|
|
|
|
|
void makect(int nc, int *ip, double *c); |
568
|
|
|
|
|
|
|
void bitrv2(int n, int *ip, double *a); |
569
|
|
|
|
|
|
|
void cftfsub(int n, double *a, double *w); |
570
|
|
|
|
|
|
|
void rftfsub(int n, double *a, int nc, double *c); |
571
|
|
|
|
|
|
|
void dstsub(int n, double *a, int nc, double *c); |
572
|
|
|
|
|
|
|
int j, k, l, m, mh, nw, nc; |
573
|
|
|
|
|
|
|
double xr, xi, yr, yi; |
574
|
|
|
|
|
|
|
|
575
|
4
|
|
|
|
|
|
nw = ip[0]; |
576
|
4
|
100
|
|
|
|
|
if (n > (nw << 3)) { |
577
|
2
|
|
|
|
|
|
nw = n >> 3; |
578
|
2
|
|
|
|
|
|
makewt(nw, ip, w); |
579
|
|
|
|
|
|
|
} |
580
|
4
|
|
|
|
|
|
nc = ip[1]; |
581
|
4
|
100
|
|
|
|
|
if (n > (nc << 1)) { |
582
|
2
|
|
|
|
|
|
nc = n >> 1; |
583
|
2
|
|
|
|
|
|
makect(nc, ip, w + nw); |
584
|
|
|
|
|
|
|
} |
585
|
4
|
50
|
|
|
|
|
if (n > 2) { |
586
|
4
|
|
|
|
|
|
m = n >> 1; |
587
|
4
|
|
|
|
|
|
mh = m >> 1; |
588
|
16392
|
100
|
|
|
|
|
for (j = 1; j < mh; j++) { |
589
|
16388
|
|
|
|
|
|
k = m - j; |
590
|
16388
|
|
|
|
|
|
xr = a[j] + a[n - j]; |
591
|
16388
|
|
|
|
|
|
xi = a[j] - a[n - j]; |
592
|
16388
|
|
|
|
|
|
yr = a[k] + a[n - k]; |
593
|
16388
|
|
|
|
|
|
yi = a[k] - a[n - k]; |
594
|
16388
|
|
|
|
|
|
a[j] = xr; |
595
|
16388
|
|
|
|
|
|
a[k] = yr; |
596
|
16388
|
|
|
|
|
|
t[j] = xi + yi; |
597
|
16388
|
|
|
|
|
|
t[k] = xi - yi; |
598
|
|
|
|
|
|
|
} |
599
|
4
|
|
|
|
|
|
t[0] = a[mh] - a[n - mh]; |
600
|
4
|
|
|
|
|
|
a[mh] += a[n - mh]; |
601
|
4
|
|
|
|
|
|
a[0] = a[m]; |
602
|
4
|
|
|
|
|
|
dstsub(m, a, nc, w + nw); |
603
|
4
|
50
|
|
|
|
|
if (m > 4) { |
604
|
4
|
|
|
|
|
|
bitrv2(m, ip + 2, a); |
605
|
4
|
|
|
|
|
|
cftfsub(m, a, w); |
606
|
4
|
|
|
|
|
|
rftfsub(m, a, nc, w + nw); |
607
|
0
|
0
|
|
|
|
|
} else if (m == 4) { |
608
|
0
|
|
|
|
|
|
cftfsub(m, a, w); |
609
|
|
|
|
|
|
|
} |
610
|
4
|
|
|
|
|
|
a[n - 1] = a[1] - a[0]; |
611
|
4
|
|
|
|
|
|
a[1] = a[0] + a[1]; |
612
|
16392
|
100
|
|
|
|
|
for (j = m - 2; j >= 2; j -= 2) { |
613
|
16388
|
|
|
|
|
|
a[2 * j + 1] = a[j] - a[j + 1]; |
614
|
16388
|
|
|
|
|
|
a[2 * j - 1] = -a[j] - a[j + 1]; |
615
|
|
|
|
|
|
|
} |
616
|
4
|
|
|
|
|
|
l = 2; |
617
|
4
|
|
|
|
|
|
m = mh; |
618
|
34
|
100
|
|
|
|
|
while (m >= 2) { |
619
|
30
|
|
|
|
|
|
dstsub(m, t, nc, w + nw); |
620
|
30
|
100
|
|
|
|
|
if (m > 4) { |
621
|
22
|
|
|
|
|
|
bitrv2(m, ip + 2, t); |
622
|
22
|
|
|
|
|
|
cftfsub(m, t, w); |
623
|
22
|
|
|
|
|
|
rftfsub(m, t, nc, w + nw); |
624
|
8
|
100
|
|
|
|
|
} else if (m == 4) { |
625
|
4
|
|
|
|
|
|
cftfsub(m, t, w); |
626
|
|
|
|
|
|
|
} |
627
|
30
|
|
|
|
|
|
a[n - l] = t[1] - t[0]; |
628
|
30
|
|
|
|
|
|
a[l] = t[0] + t[1]; |
629
|
30
|
|
|
|
|
|
k = 0; |
630
|
16388
|
100
|
|
|
|
|
for (j = 2; j < m; j += 2) { |
631
|
16358
|
|
|
|
|
|
k += l << 2; |
632
|
16358
|
|
|
|
|
|
a[k - l] = -t[j] - t[j + 1]; |
633
|
16358
|
|
|
|
|
|
a[k + l] = t[j] - t[j + 1]; |
634
|
|
|
|
|
|
|
} |
635
|
30
|
|
|
|
|
|
l <<= 1; |
636
|
30
|
|
|
|
|
|
mh = m >> 1; |
637
|
16388
|
100
|
|
|
|
|
for (j = 1; j < mh; j++) { |
638
|
16358
|
|
|
|
|
|
k = m - j; |
639
|
16358
|
|
|
|
|
|
t[j] = t[m + k] + t[m + j]; |
640
|
16358
|
|
|
|
|
|
t[k] = t[m + k] - t[m + j]; |
641
|
|
|
|
|
|
|
} |
642
|
30
|
|
|
|
|
|
t[0] = t[m + mh]; |
643
|
30
|
|
|
|
|
|
m = mh; |
644
|
|
|
|
|
|
|
} |
645
|
4
|
|
|
|
|
|
a[l] = t[0]; |
646
|
|
|
|
|
|
|
} |
647
|
4
|
|
|
|
|
|
a[0] = 0; |
648
|
4
|
|
|
|
|
|
} |
649
|
|
|
|
|
|
|
|
650
|
|
|
|
|
|
|
|
651
|
|
|
|
|
|
|
/* -------- initializing routines -------- */ |
652
|
|
|
|
|
|
|
|
653
|
|
|
|
|
|
|
|
654
|
|
|
|
|
|
|
#include |
655
|
|
|
|
|
|
|
|
656
|
28
|
|
|
|
|
|
void makewt(int nw, int *ip, double *w) |
657
|
|
|
|
|
|
|
{ |
658
|
|
|
|
|
|
|
void bitrv2(int n, int *ip, double *a); |
659
|
|
|
|
|
|
|
int j, nwh; |
660
|
|
|
|
|
|
|
double delta, x, y; |
661
|
|
|
|
|
|
|
|
662
|
28
|
|
|
|
|
|
ip[0] = nw; |
663
|
28
|
|
|
|
|
|
ip[1] = 1; |
664
|
28
|
100
|
|
|
|
|
if (nw > 2) { |
665
|
26
|
|
|
|
|
|
nwh = nw >> 1; |
666
|
26
|
|
|
|
|
|
delta = atan(1.0) / nwh; |
667
|
26
|
|
|
|
|
|
w[0] = 1; |
668
|
26
|
|
|
|
|
|
w[1] = 0; |
669
|
26
|
|
|
|
|
|
w[nwh] = cos(delta * nwh); |
670
|
26
|
|
|
|
|
|
w[nwh + 1] = w[nwh]; |
671
|
26
|
100
|
|
|
|
|
if (nwh > 2) { |
672
|
12308
|
100
|
|
|
|
|
for (j = 2; j < nwh; j += 2) { |
673
|
12291
|
|
|
|
|
|
x = cos(delta * j); |
674
|
12291
|
|
|
|
|
|
y = sin(delta * j); |
675
|
12291
|
|
|
|
|
|
w[j] = x; |
676
|
12291
|
|
|
|
|
|
w[j + 1] = y; |
677
|
12291
|
|
|
|
|
|
w[nw - j] = y; |
678
|
12291
|
|
|
|
|
|
w[nw - j + 1] = x; |
679
|
|
|
|
|
|
|
} |
680
|
17
|
|
|
|
|
|
bitrv2(nw, ip + 2, w); |
681
|
|
|
|
|
|
|
} |
682
|
|
|
|
|
|
|
} |
683
|
28
|
|
|
|
|
|
} |
684
|
|
|
|
|
|
|
|
685
|
|
|
|
|
|
|
|
686
|
25
|
|
|
|
|
|
void makect(int nc, int *ip, double *c) |
687
|
|
|
|
|
|
|
{ |
688
|
|
|
|
|
|
|
int j, nch; |
689
|
|
|
|
|
|
|
double delta; |
690
|
|
|
|
|
|
|
|
691
|
25
|
|
|
|
|
|
ip[1] = nc; |
692
|
25
|
50
|
|
|
|
|
if (nc > 1) { |
693
|
25
|
|
|
|
|
|
nch = nc >> 1; |
694
|
25
|
|
|
|
|
|
delta = atan(1.0) / nch; |
695
|
25
|
|
|
|
|
|
c[0] = cos(delta * nch); |
696
|
25
|
|
|
|
|
|
c[nch] = 0.5 * c[0]; |
697
|
53324
|
100
|
|
|
|
|
for (j = 1; j < nch; j++) { |
698
|
53299
|
|
|
|
|
|
c[j] = 0.5 * cos(delta * j); |
699
|
53299
|
|
|
|
|
|
c[nc - j] = 0.5 * sin(delta * j); |
700
|
|
|
|
|
|
|
} |
701
|
|
|
|
|
|
|
} |
702
|
25
|
|
|
|
|
|
} |
703
|
|
|
|
|
|
|
|
704
|
|
|
|
|
|
|
|
705
|
|
|
|
|
|
|
/* -------- child routines -------- */ |
706
|
|
|
|
|
|
|
|
707
|
|
|
|
|
|
|
|
708
|
344
|
|
|
|
|
|
void bitrv2(int n, int *ip, double *a) |
709
|
|
|
|
|
|
|
{ |
710
|
|
|
|
|
|
|
int j, j1, k, k1, l, m, m2; |
711
|
|
|
|
|
|
|
double xr, xi, yr, yi; |
712
|
|
|
|
|
|
|
|
713
|
344
|
|
|
|
|
|
ip[0] = 0; |
714
|
344
|
|
|
|
|
|
l = n; |
715
|
344
|
|
|
|
|
|
m = 1; |
716
|
843
|
100
|
|
|
|
|
while ((m << 3) < l) { |
717
|
499
|
|
|
|
|
|
l >>= 1; |
718
|
2257
|
100
|
|
|
|
|
for (j = 0; j < m; j++) { |
719
|
1758
|
|
|
|
|
|
ip[m + j] = ip[j] + l; |
720
|
|
|
|
|
|
|
} |
721
|
499
|
|
|
|
|
|
m <<= 1; |
722
|
|
|
|
|
|
|
} |
723
|
344
|
|
|
|
|
|
m2 = 2 * m; |
724
|
344
|
100
|
|
|
|
|
if ((m << 3) == l) { |
725
|
1774
|
100
|
|
|
|
|
for (k = 0; k < m; k++) { |
726
|
24950
|
100
|
|
|
|
|
for (j = 0; j < k; j++) { |
727
|
23468
|
|
|
|
|
|
j1 = 2 * j + ip[k]; |
728
|
23468
|
|
|
|
|
|
k1 = 2 * k + ip[j]; |
729
|
23468
|
|
|
|
|
|
xr = a[j1]; |
730
|
23468
|
|
|
|
|
|
xi = a[j1 + 1]; |
731
|
23468
|
|
|
|
|
|
yr = a[k1]; |
732
|
23468
|
|
|
|
|
|
yi = a[k1 + 1]; |
733
|
23468
|
|
|
|
|
|
a[j1] = yr; |
734
|
23468
|
|
|
|
|
|
a[j1 + 1] = yi; |
735
|
23468
|
|
|
|
|
|
a[k1] = xr; |
736
|
23468
|
|
|
|
|
|
a[k1 + 1] = xi; |
737
|
23468
|
|
|
|
|
|
j1 += m2; |
738
|
23468
|
|
|
|
|
|
k1 += 2 * m2; |
739
|
23468
|
|
|
|
|
|
xr = a[j1]; |
740
|
23468
|
|
|
|
|
|
xi = a[j1 + 1]; |
741
|
23468
|
|
|
|
|
|
yr = a[k1]; |
742
|
23468
|
|
|
|
|
|
yi = a[k1 + 1]; |
743
|
23468
|
|
|
|
|
|
a[j1] = yr; |
744
|
23468
|
|
|
|
|
|
a[j1 + 1] = yi; |
745
|
23468
|
|
|
|
|
|
a[k1] = xr; |
746
|
23468
|
|
|
|
|
|
a[k1 + 1] = xi; |
747
|
23468
|
|
|
|
|
|
j1 += m2; |
748
|
23468
|
|
|
|
|
|
k1 -= m2; |
749
|
23468
|
|
|
|
|
|
xr = a[j1]; |
750
|
23468
|
|
|
|
|
|
xi = a[j1 + 1]; |
751
|
23468
|
|
|
|
|
|
yr = a[k1]; |
752
|
23468
|
|
|
|
|
|
yi = a[k1 + 1]; |
753
|
23468
|
|
|
|
|
|
a[j1] = yr; |
754
|
23468
|
|
|
|
|
|
a[j1 + 1] = yi; |
755
|
23468
|
|
|
|
|
|
a[k1] = xr; |
756
|
23468
|
|
|
|
|
|
a[k1 + 1] = xi; |
757
|
23468
|
|
|
|
|
|
j1 += m2; |
758
|
23468
|
|
|
|
|
|
k1 += 2 * m2; |
759
|
23468
|
|
|
|
|
|
xr = a[j1]; |
760
|
23468
|
|
|
|
|
|
xi = a[j1 + 1]; |
761
|
23468
|
|
|
|
|
|
yr = a[k1]; |
762
|
23468
|
|
|
|
|
|
yi = a[k1 + 1]; |
763
|
23468
|
|
|
|
|
|
a[j1] = yr; |
764
|
23468
|
|
|
|
|
|
a[j1 + 1] = yi; |
765
|
23468
|
|
|
|
|
|
a[k1] = xr; |
766
|
23468
|
|
|
|
|
|
a[k1 + 1] = xi; |
767
|
|
|
|
|
|
|
} |
768
|
1482
|
|
|
|
|
|
j1 = 2 * k + m2 + ip[k]; |
769
|
1482
|
|
|
|
|
|
k1 = j1 + m2; |
770
|
1482
|
|
|
|
|
|
xr = a[j1]; |
771
|
1482
|
|
|
|
|
|
xi = a[j1 + 1]; |
772
|
1482
|
|
|
|
|
|
yr = a[k1]; |
773
|
1482
|
|
|
|
|
|
yi = a[k1 + 1]; |
774
|
1482
|
|
|
|
|
|
a[j1] = yr; |
775
|
1482
|
|
|
|
|
|
a[j1 + 1] = yi; |
776
|
1482
|
|
|
|
|
|
a[k1] = xr; |
777
|
1482
|
|
|
|
|
|
a[k1 + 1] = xi; |
778
|
|
|
|
|
|
|
} |
779
|
|
|
|
|
|
|
} else { |
780
|
620
|
100
|
|
|
|
|
for (k = 1; k < m; k++) { |
781
|
12254
|
100
|
|
|
|
|
for (j = 0; j < k; j++) { |
782
|
11686
|
|
|
|
|
|
j1 = 2 * j + ip[k]; |
783
|
11686
|
|
|
|
|
|
k1 = 2 * k + ip[j]; |
784
|
11686
|
|
|
|
|
|
xr = a[j1]; |
785
|
11686
|
|
|
|
|
|
xi = a[j1 + 1]; |
786
|
11686
|
|
|
|
|
|
yr = a[k1]; |
787
|
11686
|
|
|
|
|
|
yi = a[k1 + 1]; |
788
|
11686
|
|
|
|
|
|
a[j1] = yr; |
789
|
11686
|
|
|
|
|
|
a[j1 + 1] = yi; |
790
|
11686
|
|
|
|
|
|
a[k1] = xr; |
791
|
11686
|
|
|
|
|
|
a[k1 + 1] = xi; |
792
|
11686
|
|
|
|
|
|
j1 += m2; |
793
|
11686
|
|
|
|
|
|
k1 += m2; |
794
|
11686
|
|
|
|
|
|
xr = a[j1]; |
795
|
11686
|
|
|
|
|
|
xi = a[j1 + 1]; |
796
|
11686
|
|
|
|
|
|
yr = a[k1]; |
797
|
11686
|
|
|
|
|
|
yi = a[k1 + 1]; |
798
|
11686
|
|
|
|
|
|
a[j1] = yr; |
799
|
11686
|
|
|
|
|
|
a[j1 + 1] = yi; |
800
|
11686
|
|
|
|
|
|
a[k1] = xr; |
801
|
11686
|
|
|
|
|
|
a[k1 + 1] = xi; |
802
|
|
|
|
|
|
|
} |
803
|
|
|
|
|
|
|
} |
804
|
|
|
|
|
|
|
} |
805
|
344
|
|
|
|
|
|
} |
806
|
|
|
|
|
|
|
|
807
|
|
|
|
|
|
|
|
808
|
4
|
|
|
|
|
|
void bitrv2conj(int n, int *ip, double *a) |
809
|
|
|
|
|
|
|
{ |
810
|
|
|
|
|
|
|
int j, j1, k, k1, l, m, m2; |
811
|
|
|
|
|
|
|
double xr, xi, yr, yi; |
812
|
|
|
|
|
|
|
|
813
|
4
|
|
|
|
|
|
ip[0] = 0; |
814
|
4
|
|
|
|
|
|
l = n; |
815
|
4
|
|
|
|
|
|
m = 1; |
816
|
23
|
100
|
|
|
|
|
while ((m << 3) < l) { |
817
|
19
|
|
|
|
|
|
l >>= 1; |
818
|
209
|
100
|
|
|
|
|
for (j = 0; j < m; j++) { |
819
|
190
|
|
|
|
|
|
ip[m + j] = ip[j] + l; |
820
|
|
|
|
|
|
|
} |
821
|
19
|
|
|
|
|
|
m <<= 1; |
822
|
|
|
|
|
|
|
} |
823
|
4
|
|
|
|
|
|
m2 = 2 * m; |
824
|
4
|
100
|
|
|
|
|
if ((m << 3) == l) { |
825
|
195
|
100
|
|
|
|
|
for (k = 0; k < m; k++) { |
826
|
6240
|
100
|
|
|
|
|
for (j = 0; j < k; j++) { |
827
|
6048
|
|
|
|
|
|
j1 = 2 * j + ip[k]; |
828
|
6048
|
|
|
|
|
|
k1 = 2 * k + ip[j]; |
829
|
6048
|
|
|
|
|
|
xr = a[j1]; |
830
|
6048
|
|
|
|
|
|
xi = -a[j1 + 1]; |
831
|
6048
|
|
|
|
|
|
yr = a[k1]; |
832
|
6048
|
|
|
|
|
|
yi = -a[k1 + 1]; |
833
|
6048
|
|
|
|
|
|
a[j1] = yr; |
834
|
6048
|
|
|
|
|
|
a[j1 + 1] = yi; |
835
|
6048
|
|
|
|
|
|
a[k1] = xr; |
836
|
6048
|
|
|
|
|
|
a[k1 + 1] = xi; |
837
|
6048
|
|
|
|
|
|
j1 += m2; |
838
|
6048
|
|
|
|
|
|
k1 += 2 * m2; |
839
|
6048
|
|
|
|
|
|
xr = a[j1]; |
840
|
6048
|
|
|
|
|
|
xi = -a[j1 + 1]; |
841
|
6048
|
|
|
|
|
|
yr = a[k1]; |
842
|
6048
|
|
|
|
|
|
yi = -a[k1 + 1]; |
843
|
6048
|
|
|
|
|
|
a[j1] = yr; |
844
|
6048
|
|
|
|
|
|
a[j1 + 1] = yi; |
845
|
6048
|
|
|
|
|
|
a[k1] = xr; |
846
|
6048
|
|
|
|
|
|
a[k1 + 1] = xi; |
847
|
6048
|
|
|
|
|
|
j1 += m2; |
848
|
6048
|
|
|
|
|
|
k1 -= m2; |
849
|
6048
|
|
|
|
|
|
xr = a[j1]; |
850
|
6048
|
|
|
|
|
|
xi = -a[j1 + 1]; |
851
|
6048
|
|
|
|
|
|
yr = a[k1]; |
852
|
6048
|
|
|
|
|
|
yi = -a[k1 + 1]; |
853
|
6048
|
|
|
|
|
|
a[j1] = yr; |
854
|
6048
|
|
|
|
|
|
a[j1 + 1] = yi; |
855
|
6048
|
|
|
|
|
|
a[k1] = xr; |
856
|
6048
|
|
|
|
|
|
a[k1 + 1] = xi; |
857
|
6048
|
|
|
|
|
|
j1 += m2; |
858
|
6048
|
|
|
|
|
|
k1 += 2 * m2; |
859
|
6048
|
|
|
|
|
|
xr = a[j1]; |
860
|
6048
|
|
|
|
|
|
xi = -a[j1 + 1]; |
861
|
6048
|
|
|
|
|
|
yr = a[k1]; |
862
|
6048
|
|
|
|
|
|
yi = -a[k1 + 1]; |
863
|
6048
|
|
|
|
|
|
a[j1] = yr; |
864
|
6048
|
|
|
|
|
|
a[j1 + 1] = yi; |
865
|
6048
|
|
|
|
|
|
a[k1] = xr; |
866
|
6048
|
|
|
|
|
|
a[k1 + 1] = xi; |
867
|
|
|
|
|
|
|
} |
868
|
192
|
|
|
|
|
|
k1 = 2 * k + ip[k]; |
869
|
192
|
|
|
|
|
|
a[k1 + 1] = -a[k1 + 1]; |
870
|
192
|
|
|
|
|
|
j1 = k1 + m2; |
871
|
192
|
|
|
|
|
|
k1 = j1 + m2; |
872
|
192
|
|
|
|
|
|
xr = a[j1]; |
873
|
192
|
|
|
|
|
|
xi = -a[j1 + 1]; |
874
|
192
|
|
|
|
|
|
yr = a[k1]; |
875
|
192
|
|
|
|
|
|
yi = -a[k1 + 1]; |
876
|
192
|
|
|
|
|
|
a[j1] = yr; |
877
|
192
|
|
|
|
|
|
a[j1 + 1] = yi; |
878
|
192
|
|
|
|
|
|
a[k1] = xr; |
879
|
192
|
|
|
|
|
|
a[k1 + 1] = xi; |
880
|
192
|
|
|
|
|
|
k1 += m2; |
881
|
192
|
|
|
|
|
|
a[k1 + 1] = -a[k1 + 1]; |
882
|
|
|
|
|
|
|
} |
883
|
|
|
|
|
|
|
} else { |
884
|
1
|
|
|
|
|
|
a[1] = -a[1]; |
885
|
1
|
|
|
|
|
|
a[m2 + 1] = -a[m2 + 1]; |
886
|
2
|
100
|
|
|
|
|
for (k = 1; k < m; k++) { |
887
|
2
|
100
|
|
|
|
|
for (j = 0; j < k; j++) { |
888
|
1
|
|
|
|
|
|
j1 = 2 * j + ip[k]; |
889
|
1
|
|
|
|
|
|
k1 = 2 * k + ip[j]; |
890
|
1
|
|
|
|
|
|
xr = a[j1]; |
891
|
1
|
|
|
|
|
|
xi = -a[j1 + 1]; |
892
|
1
|
|
|
|
|
|
yr = a[k1]; |
893
|
1
|
|
|
|
|
|
yi = -a[k1 + 1]; |
894
|
1
|
|
|
|
|
|
a[j1] = yr; |
895
|
1
|
|
|
|
|
|
a[j1 + 1] = yi; |
896
|
1
|
|
|
|
|
|
a[k1] = xr; |
897
|
1
|
|
|
|
|
|
a[k1 + 1] = xi; |
898
|
1
|
|
|
|
|
|
j1 += m2; |
899
|
1
|
|
|
|
|
|
k1 += m2; |
900
|
1
|
|
|
|
|
|
xr = a[j1]; |
901
|
1
|
|
|
|
|
|
xi = -a[j1 + 1]; |
902
|
1
|
|
|
|
|
|
yr = a[k1]; |
903
|
1
|
|
|
|
|
|
yi = -a[k1 + 1]; |
904
|
1
|
|
|
|
|
|
a[j1] = yr; |
905
|
1
|
|
|
|
|
|
a[j1 + 1] = yi; |
906
|
1
|
|
|
|
|
|
a[k1] = xr; |
907
|
1
|
|
|
|
|
|
a[k1 + 1] = xi; |
908
|
|
|
|
|
|
|
} |
909
|
1
|
|
|
|
|
|
k1 = 2 * k + ip[k]; |
910
|
1
|
|
|
|
|
|
a[k1 + 1] = -a[k1 + 1]; |
911
|
1
|
|
|
|
|
|
a[k1 + m2 + 1] = -a[k1 + m2 + 1]; |
912
|
|
|
|
|
|
|
} |
913
|
|
|
|
|
|
|
} |
914
|
4
|
|
|
|
|
|
} |
915
|
|
|
|
|
|
|
|
916
|
|
|
|
|
|
|
|
917
|
321
|
|
|
|
|
|
void cftfsub(int n, double *a, double *w) |
918
|
|
|
|
|
|
|
{ |
919
|
|
|
|
|
|
|
void cft1st(int n, double *a, double *w); |
920
|
|
|
|
|
|
|
void cftmdl(int n, int l, double *a, double *w); |
921
|
|
|
|
|
|
|
int j, j1, j2, j3, l; |
922
|
|
|
|
|
|
|
double x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; |
923
|
|
|
|
|
|
|
|
924
|
321
|
|
|
|
|
|
l = 2; |
925
|
321
|
100
|
|
|
|
|
if (n > 8) { |
926
|
305
|
|
|
|
|
|
cft1st(n, a, w); |
927
|
305
|
|
|
|
|
|
l = 8; |
928
|
435
|
100
|
|
|
|
|
while ((l << 2) < n) { |
929
|
130
|
|
|
|
|
|
cftmdl(n, l, a, w); |
930
|
130
|
|
|
|
|
|
l <<= 2; |
931
|
|
|
|
|
|
|
} |
932
|
|
|
|
|
|
|
} |
933
|
321
|
100
|
|
|
|
|
if ((l << 2) == n) { |
934
|
31274
|
100
|
|
|
|
|
for (j = 0; j < l; j += 2) { |
935
|
31000
|
|
|
|
|
|
j1 = j + l; |
936
|
31000
|
|
|
|
|
|
j2 = j1 + l; |
937
|
31000
|
|
|
|
|
|
j3 = j2 + l; |
938
|
31000
|
|
|
|
|
|
x0r = a[j] + a[j1]; |
939
|
31000
|
|
|
|
|
|
x0i = a[j + 1] + a[j1 + 1]; |
940
|
31000
|
|
|
|
|
|
x1r = a[j] - a[j1]; |
941
|
31000
|
|
|
|
|
|
x1i = a[j + 1] - a[j1 + 1]; |
942
|
31000
|
|
|
|
|
|
x2r = a[j2] + a[j3]; |
943
|
31000
|
|
|
|
|
|
x2i = a[j2 + 1] + a[j3 + 1]; |
944
|
31000
|
|
|
|
|
|
x3r = a[j2] - a[j3]; |
945
|
31000
|
|
|
|
|
|
x3i = a[j2 + 1] - a[j3 + 1]; |
946
|
31000
|
|
|
|
|
|
a[j] = x0r + x2r; |
947
|
31000
|
|
|
|
|
|
a[j + 1] = x0i + x2i; |
948
|
31000
|
|
|
|
|
|
a[j2] = x0r - x2r; |
949
|
31000
|
|
|
|
|
|
a[j2 + 1] = x0i - x2i; |
950
|
31000
|
|
|
|
|
|
a[j1] = x1r - x3i; |
951
|
31000
|
|
|
|
|
|
a[j1 + 1] = x1i + x3r; |
952
|
31000
|
|
|
|
|
|
a[j3] = x1r + x3i; |
953
|
31000
|
|
|
|
|
|
a[j3 + 1] = x1i - x3r; |
954
|
|
|
|
|
|
|
} |
955
|
|
|
|
|
|
|
} else { |
956
|
21955
|
100
|
|
|
|
|
for (j = 0; j < l; j += 2) { |
957
|
21908
|
|
|
|
|
|
j1 = j + l; |
958
|
21908
|
|
|
|
|
|
x0r = a[j] - a[j1]; |
959
|
21908
|
|
|
|
|
|
x0i = a[j + 1] - a[j1 + 1]; |
960
|
21908
|
|
|
|
|
|
a[j] += a[j1]; |
961
|
21908
|
|
|
|
|
|
a[j + 1] += a[j1 + 1]; |
962
|
21908
|
|
|
|
|
|
a[j1] = x0r; |
963
|
21908
|
|
|
|
|
|
a[j1 + 1] = x0i; |
964
|
|
|
|
|
|
|
} |
965
|
|
|
|
|
|
|
} |
966
|
321
|
|
|
|
|
|
} |
967
|
|
|
|
|
|
|
|
968
|
|
|
|
|
|
|
|
969
|
18
|
|
|
|
|
|
void cftbsub(int n, double *a, double *w) |
970
|
|
|
|
|
|
|
{ |
971
|
|
|
|
|
|
|
void cft1st(int n, double *a, double *w); |
972
|
|
|
|
|
|
|
void cftmdl(int n, int l, double *a, double *w); |
973
|
|
|
|
|
|
|
int j, j1, j2, j3, l; |
974
|
|
|
|
|
|
|
double x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; |
975
|
|
|
|
|
|
|
|
976
|
18
|
|
|
|
|
|
l = 2; |
977
|
18
|
50
|
|
|
|
|
if (n > 8) { |
978
|
18
|
|
|
|
|
|
cft1st(n, a, w); |
979
|
18
|
|
|
|
|
|
l = 8; |
980
|
48
|
100
|
|
|
|
|
while ((l << 2) < n) { |
981
|
30
|
|
|
|
|
|
cftmdl(n, l, a, w); |
982
|
30
|
|
|
|
|
|
l <<= 2; |
983
|
|
|
|
|
|
|
} |
984
|
|
|
|
|
|
|
} |
985
|
18
|
100
|
|
|
|
|
if ((l << 2) == n) { |
986
|
24582
|
100
|
|
|
|
|
for (j = 0; j < l; j += 2) { |
987
|
24576
|
|
|
|
|
|
j1 = j + l; |
988
|
24576
|
|
|
|
|
|
j2 = j1 + l; |
989
|
24576
|
|
|
|
|
|
j3 = j2 + l; |
990
|
24576
|
|
|
|
|
|
x0r = a[j] + a[j1]; |
991
|
24576
|
|
|
|
|
|
x0i = -a[j + 1] - a[j1 + 1]; |
992
|
24576
|
|
|
|
|
|
x1r = a[j] - a[j1]; |
993
|
24576
|
|
|
|
|
|
x1i = -a[j + 1] + a[j1 + 1]; |
994
|
24576
|
|
|
|
|
|
x2r = a[j2] + a[j3]; |
995
|
24576
|
|
|
|
|
|
x2i = a[j2 + 1] + a[j3 + 1]; |
996
|
24576
|
|
|
|
|
|
x3r = a[j2] - a[j3]; |
997
|
24576
|
|
|
|
|
|
x3i = a[j2 + 1] - a[j3 + 1]; |
998
|
24576
|
|
|
|
|
|
a[j] = x0r + x2r; |
999
|
24576
|
|
|
|
|
|
a[j + 1] = x0i - x2i; |
1000
|
24576
|
|
|
|
|
|
a[j2] = x0r - x2r; |
1001
|
24576
|
|
|
|
|
|
a[j2 + 1] = x0i + x2i; |
1002
|
24576
|
|
|
|
|
|
a[j1] = x1r - x3i; |
1003
|
24576
|
|
|
|
|
|
a[j1 + 1] = x1i - x3r; |
1004
|
24576
|
|
|
|
|
|
a[j3] = x1r + x3i; |
1005
|
24576
|
|
|
|
|
|
a[j3 + 1] = x1i + x3r; |
1006
|
|
|
|
|
|
|
} |
1007
|
|
|
|
|
|
|
} else { |
1008
|
60
|
100
|
|
|
|
|
for (j = 0; j < l; j += 2) { |
1009
|
48
|
|
|
|
|
|
j1 = j + l; |
1010
|
48
|
|
|
|
|
|
x0r = a[j] - a[j1]; |
1011
|
48
|
|
|
|
|
|
x0i = -a[j + 1] + a[j1 + 1]; |
1012
|
48
|
|
|
|
|
|
a[j] += a[j1]; |
1013
|
48
|
|
|
|
|
|
a[j + 1] = -a[j + 1] - a[j1 + 1]; |
1014
|
48
|
|
|
|
|
|
a[j1] = x0r; |
1015
|
48
|
|
|
|
|
|
a[j1 + 1] = x0i; |
1016
|
|
|
|
|
|
|
} |
1017
|
|
|
|
|
|
|
} |
1018
|
18
|
|
|
|
|
|
} |
1019
|
|
|
|
|
|
|
|
1020
|
|
|
|
|
|
|
|
1021
|
323
|
|
|
|
|
|
void cft1st(int n, double *a, double *w) |
1022
|
|
|
|
|
|
|
{ |
1023
|
|
|
|
|
|
|
int j, k1, k2; |
1024
|
|
|
|
|
|
|
double wk1r, wk1i, wk2r, wk2i, wk3r, wk3i; |
1025
|
|
|
|
|
|
|
double x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; |
1026
|
|
|
|
|
|
|
|
1027
|
323
|
|
|
|
|
|
x0r = a[0] + a[2]; |
1028
|
323
|
|
|
|
|
|
x0i = a[1] + a[3]; |
1029
|
323
|
|
|
|
|
|
x1r = a[0] - a[2]; |
1030
|
323
|
|
|
|
|
|
x1i = a[1] - a[3]; |
1031
|
323
|
|
|
|
|
|
x2r = a[4] + a[6]; |
1032
|
323
|
|
|
|
|
|
x2i = a[5] + a[7]; |
1033
|
323
|
|
|
|
|
|
x3r = a[4] - a[6]; |
1034
|
323
|
|
|
|
|
|
x3i = a[5] - a[7]; |
1035
|
323
|
|
|
|
|
|
a[0] = x0r + x2r; |
1036
|
323
|
|
|
|
|
|
a[1] = x0i + x2i; |
1037
|
323
|
|
|
|
|
|
a[4] = x0r - x2r; |
1038
|
323
|
|
|
|
|
|
a[5] = x0i - x2i; |
1039
|
323
|
|
|
|
|
|
a[2] = x1r - x3i; |
1040
|
323
|
|
|
|
|
|
a[3] = x1i + x3r; |
1041
|
323
|
|
|
|
|
|
a[6] = x1r + x3i; |
1042
|
323
|
|
|
|
|
|
a[7] = x1i - x3r; |
1043
|
323
|
|
|
|
|
|
wk1r = w[2]; |
1044
|
323
|
|
|
|
|
|
x0r = a[8] + a[10]; |
1045
|
323
|
|
|
|
|
|
x0i = a[9] + a[11]; |
1046
|
323
|
|
|
|
|
|
x1r = a[8] - a[10]; |
1047
|
323
|
|
|
|
|
|
x1i = a[9] - a[11]; |
1048
|
323
|
|
|
|
|
|
x2r = a[12] + a[14]; |
1049
|
323
|
|
|
|
|
|
x2i = a[13] + a[15]; |
1050
|
323
|
|
|
|
|
|
x3r = a[12] - a[14]; |
1051
|
323
|
|
|
|
|
|
x3i = a[13] - a[15]; |
1052
|
323
|
|
|
|
|
|
a[8] = x0r + x2r; |
1053
|
323
|
|
|
|
|
|
a[9] = x0i + x2i; |
1054
|
323
|
|
|
|
|
|
a[12] = x2i - x0i; |
1055
|
323
|
|
|
|
|
|
a[13] = x0r - x2r; |
1056
|
323
|
|
|
|
|
|
x0r = x1r - x3i; |
1057
|
323
|
|
|
|
|
|
x0i = x1i + x3r; |
1058
|
323
|
|
|
|
|
|
a[10] = wk1r * (x0r - x0i); |
1059
|
323
|
|
|
|
|
|
a[11] = wk1r * (x0r + x0i); |
1060
|
323
|
|
|
|
|
|
x0r = x3i + x1r; |
1061
|
323
|
|
|
|
|
|
x0i = x3r - x1i; |
1062
|
323
|
|
|
|
|
|
a[14] = wk1r * (x0i - x0r); |
1063
|
323
|
|
|
|
|
|
a[15] = wk1r * (x0i + x0r); |
1064
|
323
|
|
|
|
|
|
k1 = 0; |
1065
|
33271
|
100
|
|
|
|
|
for (j = 16; j < n; j += 16) { |
1066
|
32948
|
|
|
|
|
|
k1 += 2; |
1067
|
32948
|
|
|
|
|
|
k2 = 2 * k1; |
1068
|
32948
|
|
|
|
|
|
wk2r = w[k1]; |
1069
|
32948
|
|
|
|
|
|
wk2i = w[k1 + 1]; |
1070
|
32948
|
|
|
|
|
|
wk1r = w[k2]; |
1071
|
32948
|
|
|
|
|
|
wk1i = w[k2 + 1]; |
1072
|
32948
|
|
|
|
|
|
wk3r = wk1r - 2 * wk2i * wk1i; |
1073
|
32948
|
|
|
|
|
|
wk3i = 2 * wk2i * wk1r - wk1i; |
1074
|
32948
|
|
|
|
|
|
x0r = a[j] + a[j + 2]; |
1075
|
32948
|
|
|
|
|
|
x0i = a[j + 1] + a[j + 3]; |
1076
|
32948
|
|
|
|
|
|
x1r = a[j] - a[j + 2]; |
1077
|
32948
|
|
|
|
|
|
x1i = a[j + 1] - a[j + 3]; |
1078
|
32948
|
|
|
|
|
|
x2r = a[j + 4] + a[j + 6]; |
1079
|
32948
|
|
|
|
|
|
x2i = a[j + 5] + a[j + 7]; |
1080
|
32948
|
|
|
|
|
|
x3r = a[j + 4] - a[j + 6]; |
1081
|
32948
|
|
|
|
|
|
x3i = a[j + 5] - a[j + 7]; |
1082
|
32948
|
|
|
|
|
|
a[j] = x0r + x2r; |
1083
|
32948
|
|
|
|
|
|
a[j + 1] = x0i + x2i; |
1084
|
32948
|
|
|
|
|
|
x0r -= x2r; |
1085
|
32948
|
|
|
|
|
|
x0i -= x2i; |
1086
|
32948
|
|
|
|
|
|
a[j + 4] = wk2r * x0r - wk2i * x0i; |
1087
|
32948
|
|
|
|
|
|
a[j + 5] = wk2r * x0i + wk2i * x0r; |
1088
|
32948
|
|
|
|
|
|
x0r = x1r - x3i; |
1089
|
32948
|
|
|
|
|
|
x0i = x1i + x3r; |
1090
|
32948
|
|
|
|
|
|
a[j + 2] = wk1r * x0r - wk1i * x0i; |
1091
|
32948
|
|
|
|
|
|
a[j + 3] = wk1r * x0i + wk1i * x0r; |
1092
|
32948
|
|
|
|
|
|
x0r = x1r + x3i; |
1093
|
32948
|
|
|
|
|
|
x0i = x1i - x3r; |
1094
|
32948
|
|
|
|
|
|
a[j + 6] = wk3r * x0r - wk3i * x0i; |
1095
|
32948
|
|
|
|
|
|
a[j + 7] = wk3r * x0i + wk3i * x0r; |
1096
|
32948
|
|
|
|
|
|
wk1r = w[k2 + 2]; |
1097
|
32948
|
|
|
|
|
|
wk1i = w[k2 + 3]; |
1098
|
32948
|
|
|
|
|
|
wk3r = wk1r - 2 * wk2r * wk1i; |
1099
|
32948
|
|
|
|
|
|
wk3i = 2 * wk2r * wk1r - wk1i; |
1100
|
32948
|
|
|
|
|
|
x0r = a[j + 8] + a[j + 10]; |
1101
|
32948
|
|
|
|
|
|
x0i = a[j + 9] + a[j + 11]; |
1102
|
32948
|
|
|
|
|
|
x1r = a[j + 8] - a[j + 10]; |
1103
|
32948
|
|
|
|
|
|
x1i = a[j + 9] - a[j + 11]; |
1104
|
32948
|
|
|
|
|
|
x2r = a[j + 12] + a[j + 14]; |
1105
|
32948
|
|
|
|
|
|
x2i = a[j + 13] + a[j + 15]; |
1106
|
32948
|
|
|
|
|
|
x3r = a[j + 12] - a[j + 14]; |
1107
|
32948
|
|
|
|
|
|
x3i = a[j + 13] - a[j + 15]; |
1108
|
32948
|
|
|
|
|
|
a[j + 8] = x0r + x2r; |
1109
|
32948
|
|
|
|
|
|
a[j + 9] = x0i + x2i; |
1110
|
32948
|
|
|
|
|
|
x0r -= x2r; |
1111
|
32948
|
|
|
|
|
|
x0i -= x2i; |
1112
|
32948
|
|
|
|
|
|
a[j + 12] = -wk2i * x0r - wk2r * x0i; |
1113
|
32948
|
|
|
|
|
|
a[j + 13] = -wk2i * x0i + wk2r * x0r; |
1114
|
32948
|
|
|
|
|
|
x0r = x1r - x3i; |
1115
|
32948
|
|
|
|
|
|
x0i = x1i + x3r; |
1116
|
32948
|
|
|
|
|
|
a[j + 10] = wk1r * x0r - wk1i * x0i; |
1117
|
32948
|
|
|
|
|
|
a[j + 11] = wk1r * x0i + wk1i * x0r; |
1118
|
32948
|
|
|
|
|
|
x0r = x1r + x3i; |
1119
|
32948
|
|
|
|
|
|
x0i = x1i - x3r; |
1120
|
32948
|
|
|
|
|
|
a[j + 14] = wk3r * x0r - wk3i * x0i; |
1121
|
32948
|
|
|
|
|
|
a[j + 15] = wk3r * x0i + wk3i * x0r; |
1122
|
|
|
|
|
|
|
} |
1123
|
323
|
|
|
|
|
|
} |
1124
|
|
|
|
|
|
|
|
1125
|
|
|
|
|
|
|
|
1126
|
160
|
|
|
|
|
|
void cftmdl(int n, int l, double *a, double *w) |
1127
|
|
|
|
|
|
|
{ |
1128
|
|
|
|
|
|
|
int j, j1, j2, j3, k, k1, k2, m, m2; |
1129
|
|
|
|
|
|
|
double wk1r, wk1i, wk2r, wk2i, wk3r, wk3i; |
1130
|
|
|
|
|
|
|
double x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; |
1131
|
|
|
|
|
|
|
|
1132
|
160
|
|
|
|
|
|
m = l << 2; |
1133
|
25568
|
100
|
|
|
|
|
for (j = 0; j < l; j += 2) { |
1134
|
25408
|
|
|
|
|
|
j1 = j + l; |
1135
|
25408
|
|
|
|
|
|
j2 = j1 + l; |
1136
|
25408
|
|
|
|
|
|
j3 = j2 + l; |
1137
|
25408
|
|
|
|
|
|
x0r = a[j] + a[j1]; |
1138
|
25408
|
|
|
|
|
|
x0i = a[j + 1] + a[j1 + 1]; |
1139
|
25408
|
|
|
|
|
|
x1r = a[j] - a[j1]; |
1140
|
25408
|
|
|
|
|
|
x1i = a[j + 1] - a[j1 + 1]; |
1141
|
25408
|
|
|
|
|
|
x2r = a[j2] + a[j3]; |
1142
|
25408
|
|
|
|
|
|
x2i = a[j2 + 1] + a[j3 + 1]; |
1143
|
25408
|
|
|
|
|
|
x3r = a[j2] - a[j3]; |
1144
|
25408
|
|
|
|
|
|
x3i = a[j2 + 1] - a[j3 + 1]; |
1145
|
25408
|
|
|
|
|
|
a[j] = x0r + x2r; |
1146
|
25408
|
|
|
|
|
|
a[j + 1] = x0i + x2i; |
1147
|
25408
|
|
|
|
|
|
a[j2] = x0r - x2r; |
1148
|
25408
|
|
|
|
|
|
a[j2 + 1] = x0i - x2i; |
1149
|
25408
|
|
|
|
|
|
a[j1] = x1r - x3i; |
1150
|
25408
|
|
|
|
|
|
a[j1 + 1] = x1i + x3r; |
1151
|
25408
|
|
|
|
|
|
a[j3] = x1r + x3i; |
1152
|
25408
|
|
|
|
|
|
a[j3 + 1] = x1i - x3r; |
1153
|
|
|
|
|
|
|
} |
1154
|
160
|
|
|
|
|
|
wk1r = w[2]; |
1155
|
25568
|
100
|
|
|
|
|
for (j = m; j < l + m; j += 2) { |
1156
|
25408
|
|
|
|
|
|
j1 = j + l; |
1157
|
25408
|
|
|
|
|
|
j2 = j1 + l; |
1158
|
25408
|
|
|
|
|
|
j3 = j2 + l; |
1159
|
25408
|
|
|
|
|
|
x0r = a[j] + a[j1]; |
1160
|
25408
|
|
|
|
|
|
x0i = a[j + 1] + a[j1 + 1]; |
1161
|
25408
|
|
|
|
|
|
x1r = a[j] - a[j1]; |
1162
|
25408
|
|
|
|
|
|
x1i = a[j + 1] - a[j1 + 1]; |
1163
|
25408
|
|
|
|
|
|
x2r = a[j2] + a[j3]; |
1164
|
25408
|
|
|
|
|
|
x2i = a[j2 + 1] + a[j3 + 1]; |
1165
|
25408
|
|
|
|
|
|
x3r = a[j2] - a[j3]; |
1166
|
25408
|
|
|
|
|
|
x3i = a[j2 + 1] - a[j3 + 1]; |
1167
|
25408
|
|
|
|
|
|
a[j] = x0r + x2r; |
1168
|
25408
|
|
|
|
|
|
a[j + 1] = x0i + x2i; |
1169
|
25408
|
|
|
|
|
|
a[j2] = x2i - x0i; |
1170
|
25408
|
|
|
|
|
|
a[j2 + 1] = x0r - x2r; |
1171
|
25408
|
|
|
|
|
|
x0r = x1r - x3i; |
1172
|
25408
|
|
|
|
|
|
x0i = x1i + x3r; |
1173
|
25408
|
|
|
|
|
|
a[j1] = wk1r * (x0r - x0i); |
1174
|
25408
|
|
|
|
|
|
a[j1 + 1] = wk1r * (x0r + x0i); |
1175
|
25408
|
|
|
|
|
|
x0r = x3i + x1r; |
1176
|
25408
|
|
|
|
|
|
x0i = x3r - x1i; |
1177
|
25408
|
|
|
|
|
|
a[j3] = wk1r * (x0i - x0r); |
1178
|
25408
|
|
|
|
|
|
a[j3 + 1] = wk1r * (x0i + x0r); |
1179
|
|
|
|
|
|
|
} |
1180
|
160
|
|
|
|
|
|
k1 = 0; |
1181
|
160
|
|
|
|
|
|
m2 = 2 * m; |
1182
|
10892
|
100
|
|
|
|
|
for (k = m2; k < n; k += m2) { |
1183
|
10732
|
|
|
|
|
|
k1 += 2; |
1184
|
10732
|
|
|
|
|
|
k2 = 2 * k1; |
1185
|
10732
|
|
|
|
|
|
wk2r = w[k1]; |
1186
|
10732
|
|
|
|
|
|
wk2i = w[k1 + 1]; |
1187
|
10732
|
|
|
|
|
|
wk1r = w[k2]; |
1188
|
10732
|
|
|
|
|
|
wk1i = w[k2 + 1]; |
1189
|
10732
|
|
|
|
|
|
wk3r = wk1r - 2 * wk2i * wk1i; |
1190
|
10732
|
|
|
|
|
|
wk3i = 2 * wk2i * wk1r - wk1i; |
1191
|
143708
|
100
|
|
|
|
|
for (j = k; j < l + k; j += 2) { |
1192
|
132976
|
|
|
|
|
|
j1 = j + l; |
1193
|
132976
|
|
|
|
|
|
j2 = j1 + l; |
1194
|
132976
|
|
|
|
|
|
j3 = j2 + l; |
1195
|
132976
|
|
|
|
|
|
x0r = a[j] + a[j1]; |
1196
|
132976
|
|
|
|
|
|
x0i = a[j + 1] + a[j1 + 1]; |
1197
|
132976
|
|
|
|
|
|
x1r = a[j] - a[j1]; |
1198
|
132976
|
|
|
|
|
|
x1i = a[j + 1] - a[j1 + 1]; |
1199
|
132976
|
|
|
|
|
|
x2r = a[j2] + a[j3]; |
1200
|
132976
|
|
|
|
|
|
x2i = a[j2 + 1] + a[j3 + 1]; |
1201
|
132976
|
|
|
|
|
|
x3r = a[j2] - a[j3]; |
1202
|
132976
|
|
|
|
|
|
x3i = a[j2 + 1] - a[j3 + 1]; |
1203
|
132976
|
|
|
|
|
|
a[j] = x0r + x2r; |
1204
|
132976
|
|
|
|
|
|
a[j + 1] = x0i + x2i; |
1205
|
132976
|
|
|
|
|
|
x0r -= x2r; |
1206
|
132976
|
|
|
|
|
|
x0i -= x2i; |
1207
|
132976
|
|
|
|
|
|
a[j2] = wk2r * x0r - wk2i * x0i; |
1208
|
132976
|
|
|
|
|
|
a[j2 + 1] = wk2r * x0i + wk2i * x0r; |
1209
|
132976
|
|
|
|
|
|
x0r = x1r - x3i; |
1210
|
132976
|
|
|
|
|
|
x0i = x1i + x3r; |
1211
|
132976
|
|
|
|
|
|
a[j1] = wk1r * x0r - wk1i * x0i; |
1212
|
132976
|
|
|
|
|
|
a[j1 + 1] = wk1r * x0i + wk1i * x0r; |
1213
|
132976
|
|
|
|
|
|
x0r = x1r + x3i; |
1214
|
132976
|
|
|
|
|
|
x0i = x1i - x3r; |
1215
|
132976
|
|
|
|
|
|
a[j3] = wk3r * x0r - wk3i * x0i; |
1216
|
132976
|
|
|
|
|
|
a[j3 + 1] = wk3r * x0i + wk3i * x0r; |
1217
|
|
|
|
|
|
|
} |
1218
|
10732
|
|
|
|
|
|
wk1r = w[k2 + 2]; |
1219
|
10732
|
|
|
|
|
|
wk1i = w[k2 + 3]; |
1220
|
10732
|
|
|
|
|
|
wk3r = wk1r - 2 * wk2r * wk1i; |
1221
|
10732
|
|
|
|
|
|
wk3i = 2 * wk2r * wk1r - wk1i; |
1222
|
143708
|
100
|
|
|
|
|
for (j = k + m; j < l + (k + m); j += 2) { |
1223
|
132976
|
|
|
|
|
|
j1 = j + l; |
1224
|
132976
|
|
|
|
|
|
j2 = j1 + l; |
1225
|
132976
|
|
|
|
|
|
j3 = j2 + l; |
1226
|
132976
|
|
|
|
|
|
x0r = a[j] + a[j1]; |
1227
|
132976
|
|
|
|
|
|
x0i = a[j + 1] + a[j1 + 1]; |
1228
|
132976
|
|
|
|
|
|
x1r = a[j] - a[j1]; |
1229
|
132976
|
|
|
|
|
|
x1i = a[j + 1] - a[j1 + 1]; |
1230
|
132976
|
|
|
|
|
|
x2r = a[j2] + a[j3]; |
1231
|
132976
|
|
|
|
|
|
x2i = a[j2 + 1] + a[j3 + 1]; |
1232
|
132976
|
|
|
|
|
|
x3r = a[j2] - a[j3]; |
1233
|
132976
|
|
|
|
|
|
x3i = a[j2 + 1] - a[j3 + 1]; |
1234
|
132976
|
|
|
|
|
|
a[j] = x0r + x2r; |
1235
|
132976
|
|
|
|
|
|
a[j + 1] = x0i + x2i; |
1236
|
132976
|
|
|
|
|
|
x0r -= x2r; |
1237
|
132976
|
|
|
|
|
|
x0i -= x2i; |
1238
|
132976
|
|
|
|
|
|
a[j2] = -wk2i * x0r - wk2r * x0i; |
1239
|
132976
|
|
|
|
|
|
a[j2 + 1] = -wk2i * x0i + wk2r * x0r; |
1240
|
132976
|
|
|
|
|
|
x0r = x1r - x3i; |
1241
|
132976
|
|
|
|
|
|
x0i = x1i + x3r; |
1242
|
132976
|
|
|
|
|
|
a[j1] = wk1r * x0r - wk1i * x0i; |
1243
|
132976
|
|
|
|
|
|
a[j1 + 1] = wk1r * x0i + wk1i * x0r; |
1244
|
132976
|
|
|
|
|
|
x0r = x1r + x3i; |
1245
|
132976
|
|
|
|
|
|
x0i = x1i - x3r; |
1246
|
132976
|
|
|
|
|
|
a[j3] = wk3r * x0r - wk3i * x0i; |
1247
|
132976
|
|
|
|
|
|
a[j3 + 1] = wk3r * x0i + wk3i * x0r; |
1248
|
|
|
|
|
|
|
} |
1249
|
|
|
|
|
|
|
} |
1250
|
160
|
|
|
|
|
|
} |
1251
|
|
|
|
|
|
|
|
1252
|
|
|
|
|
|
|
|
1253
|
309
|
|
|
|
|
|
void rftfsub(int n, double *a, int nc, double *c) |
1254
|
|
|
|
|
|
|
{ |
1255
|
|
|
|
|
|
|
int j, k, kk, ks, m; |
1256
|
|
|
|
|
|
|
double wkr, wki, xr, xi, yr, yi; |
1257
|
|
|
|
|
|
|
|
1258
|
309
|
|
|
|
|
|
m = n >> 1; |
1259
|
309
|
|
|
|
|
|
ks = 2 * nc / m; |
1260
|
309
|
|
|
|
|
|
kk = 0; |
1261
|
59320
|
100
|
|
|
|
|
for (j = 2; j < m; j += 2) { |
1262
|
59011
|
|
|
|
|
|
k = n - j; |
1263
|
59011
|
|
|
|
|
|
kk += ks; |
1264
|
59011
|
|
|
|
|
|
wkr = 0.5 - c[nc - kk]; |
1265
|
59011
|
|
|
|
|
|
wki = c[kk]; |
1266
|
59011
|
|
|
|
|
|
xr = a[j] - a[k]; |
1267
|
59011
|
|
|
|
|
|
xi = a[j + 1] + a[k + 1]; |
1268
|
59011
|
|
|
|
|
|
yr = wkr * xr - wki * xi; |
1269
|
59011
|
|
|
|
|
|
yi = wkr * xi + wki * xr; |
1270
|
59011
|
|
|
|
|
|
a[j] -= yr; |
1271
|
59011
|
|
|
|
|
|
a[j + 1] -= yi; |
1272
|
59011
|
|
|
|
|
|
a[k] += yr; |
1273
|
59011
|
|
|
|
|
|
a[k + 1] -= yi; |
1274
|
|
|
|
|
|
|
} |
1275
|
309
|
|
|
|
|
|
} |
1276
|
|
|
|
|
|
|
|
1277
|
|
|
|
|
|
|
|
1278
|
14
|
|
|
|
|
|
void rftbsub(int n, double *a, int nc, double *c) |
1279
|
|
|
|
|
|
|
{ |
1280
|
|
|
|
|
|
|
int j, k, kk, ks, m; |
1281
|
|
|
|
|
|
|
double wkr, wki, xr, xi, yr, yi; |
1282
|
|
|
|
|
|
|
|
1283
|
14
|
|
|
|
|
|
a[1] = -a[1]; |
1284
|
14
|
|
|
|
|
|
m = n >> 1; |
1285
|
14
|
|
|
|
|
|
ks = 2 * nc / m; |
1286
|
14
|
|
|
|
|
|
kk = 0; |
1287
|
24620
|
100
|
|
|
|
|
for (j = 2; j < m; j += 2) { |
1288
|
24606
|
|
|
|
|
|
k = n - j; |
1289
|
24606
|
|
|
|
|
|
kk += ks; |
1290
|
24606
|
|
|
|
|
|
wkr = 0.5 - c[nc - kk]; |
1291
|
24606
|
|
|
|
|
|
wki = c[kk]; |
1292
|
24606
|
|
|
|
|
|
xr = a[j] - a[k]; |
1293
|
24606
|
|
|
|
|
|
xi = a[j + 1] + a[k + 1]; |
1294
|
24606
|
|
|
|
|
|
yr = wkr * xr + wki * xi; |
1295
|
24606
|
|
|
|
|
|
yi = wkr * xi - wki * xr; |
1296
|
24606
|
|
|
|
|
|
a[j] -= yr; |
1297
|
24606
|
|
|
|
|
|
a[j + 1] = yi - a[j + 1]; |
1298
|
24606
|
|
|
|
|
|
a[k] += yr; |
1299
|
24606
|
|
|
|
|
|
a[k + 1] = yi - a[k + 1]; |
1300
|
|
|
|
|
|
|
} |
1301
|
14
|
|
|
|
|
|
a[m + 1] = -a[m + 1]; |
1302
|
14
|
|
|
|
|
|
} |
1303
|
|
|
|
|
|
|
|
1304
|
|
|
|
|
|
|
|
1305
|
38
|
|
|
|
|
|
void dctsub(int n, double *a, int nc, double *c) |
1306
|
|
|
|
|
|
|
{ |
1307
|
|
|
|
|
|
|
int j, k, kk, ks, m; |
1308
|
|
|
|
|
|
|
double wkr, wki, xr; |
1309
|
|
|
|
|
|
|
|
1310
|
38
|
|
|
|
|
|
m = n >> 1; |
1311
|
38
|
|
|
|
|
|
ks = nc / n; |
1312
|
38
|
|
|
|
|
|
kk = 0; |
1313
|
65564
|
100
|
|
|
|
|
for (j = 1; j < m; j++) { |
1314
|
65526
|
|
|
|
|
|
k = n - j; |
1315
|
65526
|
|
|
|
|
|
kk += ks; |
1316
|
65526
|
|
|
|
|
|
wkr = c[kk] - c[nc - kk]; |
1317
|
65526
|
|
|
|
|
|
wki = c[kk] + c[nc - kk]; |
1318
|
65526
|
|
|
|
|
|
xr = wki * a[j] - wkr * a[k]; |
1319
|
65526
|
|
|
|
|
|
a[j] = wkr * a[j] + wki * a[k]; |
1320
|
65526
|
|
|
|
|
|
a[k] = xr; |
1321
|
|
|
|
|
|
|
} |
1322
|
38
|
|
|
|
|
|
a[m] *= c[0]; |
1323
|
38
|
|
|
|
|
|
} |
1324
|
|
|
|
|
|
|
|
1325
|
|
|
|
|
|
|
|
1326
|
38
|
|
|
|
|
|
void dstsub(int n, double *a, int nc, double *c) |
1327
|
|
|
|
|
|
|
{ |
1328
|
|
|
|
|
|
|
int j, k, kk, ks, m; |
1329
|
|
|
|
|
|
|
double wkr, wki, xr; |
1330
|
|
|
|
|
|
|
|
1331
|
38
|
|
|
|
|
|
m = n >> 1; |
1332
|
38
|
|
|
|
|
|
ks = nc / n; |
1333
|
38
|
|
|
|
|
|
kk = 0; |
1334
|
65564
|
100
|
|
|
|
|
for (j = 1; j < m; j++) { |
1335
|
65526
|
|
|
|
|
|
k = n - j; |
1336
|
65526
|
|
|
|
|
|
kk += ks; |
1337
|
65526
|
|
|
|
|
|
wkr = c[kk] - c[nc - kk]; |
1338
|
65526
|
|
|
|
|
|
wki = c[kk] + c[nc - kk]; |
1339
|
65526
|
|
|
|
|
|
xr = wki * a[k] - wkr * a[j]; |
1340
|
65526
|
|
|
|
|
|
a[k] = wkr * a[k] + wki * a[j]; |
1341
|
65526
|
|
|
|
|
|
a[j] = xr; |
1342
|
|
|
|
|
|
|
} |
1343
|
38
|
|
|
|
|
|
a[m] *= c[0]; |
1344
|
38
|
|
|
|
|
|
} |
1345
|
|
|
|
|
|
|
|