1 // Shibatch Super Equalizer ver 0.03 for winamp
2 // written by Naoki Shibata shibatch@users.sourceforge.net
4 module mbandeq_j
/*is aliced*/;
10 //version = mbeq_debug_output;
12 version(mbeq_debug_output
) import iv
.cmdcon
;
15 // ////////////////////////////////////////////////////////////////////////// //
16 // Real Discrete Fourier Transform wrapper
17 void rfft (int n
, int isign
, REAL
* x
) {
18 import std
.math
: sqrt
;
19 __gshared
int ipsize
= 0, wsize
=0;
20 __gshared
int* ip
= null;
21 __gshared REAL
* w
= null;
22 int newipsize
, newwsize
;
25 import core
.stdc
.stdlib
: free
;
26 free(ip
); ip
= null; ipsize
= 0;
27 free(w
); w
= null; wsize
= 0;
31 newipsize
= 2+cast(int)sqrt(cast(REAL
)(n
/2));
32 if (newipsize
> ipsize
) {
33 import core
.stdc
.stdlib
: realloc
;
35 ip
= cast(int*)realloc(ip
, int.sizeof
*ipsize
);
40 if (newwsize
> wsize
) {
41 import core
.stdc
.stdlib
: realloc
;
43 w
= cast(REAL
*)realloc(w
, REAL
.sizeof
*wsize
);
46 rdft(n
, isign
, x
, ip
, w
);
50 // ////////////////////////////////////////////////////////////////////////// //
53 //#define RINT(x) ((x) >= 0 ? ((int)((x)+0.5)) : ((int)((x)-0.5)))
54 int RINT (REAL x
) pure nothrow @safe @nogc { pragma(inline
, true); return (x
>= 0 ?
cast(int)(x
+0.5f) : cast(int)(x
-0.5f)); }
56 enum DITHERLEN
= 65536;
58 __gshared REAL
[M
+1] fact
;
59 __gshared REAL aa
= 96;
61 __gshared REAL
* lires
, lires1
, lires2
;
62 __gshared REAL
* rires
, rires1
, rires2
;
63 __gshared REAL
* irest
;
64 __gshared REAL
* fsamples
;
65 __gshared
int chg_ires
, cur_ires
;
66 __gshared
int winlen
, winlenbit
, tabsize
, nbufsamples
;
67 __gshared
short* inbuf
;
68 __gshared REAL
* outbuf
;
71 __gshared REAL
* ditherbuf
;
72 __gshared
uint ditherptr
= 0;
73 __gshared REAL smphm1
= 0, smphm2
= 0;
79 static immutable REAL
[NBANDS
] bands
= [
80 65.406392, 92.498606, 130.81278, 184.99721, 261.62557, 369.99442, 523.25113,
81 739.9884 , 1046.5023, 1479.9768, 2093.0045, 2959.9536, 4186.0091, 5919.9072,
82 8372.0181, 11839.814, 16744.036,
86 REAL
alpha (REAL a
) nothrow @trusted @nogc {
87 import std
.math
: pow
;
88 if (a
<= 21) return 0;
89 if (a
<= 50) return 0.5842*pow(a
-21, 0.4)+0.07886*(a
-21);
90 return 0.1102*(a
-8.7);
94 REAL
izero (REAL x
) nothrow @trusted @nogc {
95 import std
.math
: pow
;
97 foreach (immutable m
; 1..M
+1) {
98 REAL t
= pow(x
/2, m
)/fact
[m
];
105 /// wb: window length, bits
106 public void mbeqInit (int wb
=14) {
107 import core
.stdc
.stdlib
: malloc
, calloc
, free
;
109 if (lires1
!is null) free(lires1
);
110 if (lires2
!is null) free(lires2
);
111 if (rires1
!is null) free(rires1
);
112 if (rires2
!is null) free(rires2
);
113 if (irest
!is null) free(irest
);
114 if (fsamples
!is null) free(fsamples
);
115 if (inbuf
!is null) free(inbuf
);
116 if (outbuf
!is null) free(outbuf
);
117 static if (dither
) { if (ditherbuf
!is null) free(ditherbuf
); }
119 winlen
= (1<<(wb
-1))-1;
123 //{ import core.stdc.stdio; printf("winlen=%u\n", winlen); }
125 lires1
= cast(REAL
*)malloc(REAL
.sizeof
*tabsize
);
126 lires2
= cast(REAL
*)malloc(REAL
.sizeof
*tabsize
);
127 rires1
= cast(REAL
*)malloc(REAL
.sizeof
*tabsize
);
128 rires2
= cast(REAL
*)malloc(REAL
.sizeof
*tabsize
);
129 irest
= cast(REAL
*)malloc(REAL
.sizeof
*tabsize
);
130 fsamples
= cast(REAL
*)malloc(REAL
.sizeof
*tabsize
);
131 inbuf
= cast(short*)calloc(winlen
*NCH
, int.sizeof
);
132 outbuf
= cast(REAL
*)calloc(tabsize
*NCH
, REAL
.sizeof
);
133 static if (dither
) { ditherbuf
= cast(REAL
*)malloc(REAL
.sizeof
*DITHERLEN
); }
141 foreach (immutable i
; 0..DITHERLEN
) {
143 //ditherbuf[i] = (REAL(rand())/RAND_MAX-0.5);
144 ditherbuf
[i
] = uniform
!"[]"(0, 32760)/32760.0f-0.5f;
148 foreach (immutable i
; 0..M
+1) {
150 foreach (immutable j
; 1..i
+1) fact
[i
] *= j
;
153 iza
= izero(alpha(aa
));
157 // -(N-1)/2 <= n <= (N-1)/2
158 REAL
win (REAL n
, int N
) nothrow @trusted @nogc {
159 pragma(inline
, true);
160 import std
.math
: sqrt
;
161 return izero(alpha(aa
)*sqrt(1-4*n
*n
/((N
-1)*(N
-1))))/iza
;
165 REAL
sinc (REAL x
) nothrow @trusted @nogc {
166 pragma(inline
, true);
167 import std
.math
: sin
;
168 return (x
== 0 ?
1 : sin(x
)/x
);
172 REAL
hn_lpf (int n
, REAL f
, REAL fs
) nothrow @trusted @nogc {
173 pragma(inline
, true);
174 import std
.math
: PI
;
175 immutable REAL t
= 1/fs
;
176 immutable REAL omega
= 2*PI
*f
;
177 return 2*f
*t
*sinc(n
*omega
*t
);
181 REAL
hn_imp (int n
) nothrow @trusted @nogc {
182 pragma(inline
, true);
183 return (n
== 0 ?
1.0 : 0.0);
187 REAL
getLower (int i
) nothrow @trusted @nogc {
188 pragma(inline
, true);
189 if (i
< 0) assert(0, "wtf?");
190 if (i
> NBANDS
+1) assert(0, "wtf?");
191 return (i
== 0 ?
0 : bands
[i
-1]);
195 REAL
getUpper (int i
) nothrow @trusted @nogc {
196 pragma(inline
, true);
197 if (i
< 0) assert(0, "wtf?");
198 if (i
> NBANDS
+1) assert(0, "wtf?");
199 return (i
== NBANDS ?
48000/2 : bands
[i
]);
203 REAL
hn (int n
, const(REAL
)[] gains
, REAL fs
) nothrow @trusted @nogc {
204 REAL lhn
= hn_lpf(n
, bands
[0], fs
);
205 REAL
ret = gains
[0]*lhn
;
206 foreach (immutable i
, REAL gv
; gains
) {
207 if (i
== 0) continue;
209 //immutable REAL lower = getLower(i);
210 immutable REAL upper
= getUpper(i
);
213 ret += gv
*(hn_imp(n
)-lhn
);
216 REAL lhn2
= hn_lpf(n
, upper
, fs
);
217 ret += gv
*(lhn2
-lhn
);
224 void processParam (REAL
[] gains
, const(REAL
)[] bc
, const(REAL
)[] gainmods
=null) {
225 import std
.math
: pow
;
226 foreach (immutable i
; 0..NBANDS
+1) {
228 immutable REAL gm
= (i
< gainmods
.length ? gainmods
[i
] : 1);
229 gains
[i
] *= pow(10, gm
/20);
230 //if (i < gainmods.length) gains[i] *= pow(10, gainmods[i]/20);
236 public void mbeqMakeTable (const(REAL
)[] lbc
, const(REAL
)[] rbc
, REAL fs
, const(REAL
)[] gainmods
=null) {
237 int i
, cires
= cur_ires
;
239 REAL
[NBANDS
+1] gains
;
244 processParam(gains
[], lbc
, gainmods
);
245 version(mbeq_debug_output
) foreach (immutable gi
, immutable REAL gv
; gains
[]) conwriteln("L: ", getLower(gi
, fs
), "Hz to ", getUpper(gi
, fs
), "Hz, ", gv
);
246 for (i
= 0; i
< winlen
; ++i
) irest
[i
] = hn(i
-winlen
/2, gains
[], fs
)*win(i
-winlen
/2, winlen
);
247 for (; i
< tabsize
; ++i
) irest
[i
] = 0;
248 rfft(tabsize
, 1, irest
);
249 nires
= (cires
== 1 ? lires2
: lires1
);
250 for (i
= 0; i
< tabsize
; ++i
) nires
[i
] = irest
[i
];
253 processParam(gains
[], rbc
, gainmods
);
254 version(mbeq_debug_output
) foreach (immutable gi
, immutable REAL gv
; gains
[]) conwriteln("R: ", getLower(gi
, fs
), "Hz to ", getUpper(gi
, fs
), "Hz, ", gv
);
255 for (i
= 0; i
< winlen
; ++i
) irest
[i
] = hn(i
-winlen
/2, gains
[], fs
)*win(i
-winlen
/2, winlen
);
256 for (; i
< tabsize
; ++i
) irest
[i
] = 0;
257 rfft(tabsize
, 1, irest
);
258 nires
= (cires
== 1 ? rires2
: rires1
);
259 for (i
= 0; i
< tabsize
; ++i
) nires
[i
] = irest
[i
];
262 chg_ires
= (cires
== 1 ?
2 : 1);
267 public void mbeqQuit () {
268 import core
.stdc
.stdlib
: free
;
270 if (lires1
!is null) free(lires1
);
271 if (lires2
!is null) free(lires2
);
272 if (rires1
!is null) free(rires1
);
273 if (rires2
!is null) free(rires2
);
274 if (irest
!is null) free(irest
);
275 if (fsamples
!is null) free(fsamples
);
276 if (inbuf
!is null) free(inbuf
);
277 if (outbuf
!is null) free(outbuf
);
293 public void mbeqClearbuf (int bps
, int srate
) {
295 //foreach (immutable i; 0..tabsize*NCH) outbuf[i] = 0;
296 outbuf
[0..tabsize
*NCH
] = 0;
301 public int mbeqModifySamples (void* buf
, int nsamples
, int nch
, int bps
) {
304 int amax
= (1<<(bps
-1))-1;
305 int amin
= -(1<<(bps
-1));
306 //static REAL smphm1 = 0, smphm2 = 0;
310 lires
= (cur_ires
== 1 ? lires1
: lires2
);
311 rires
= (cur_ires
== 1 ? rires1
: rires2
);
317 while (nbufsamples
+nsamples
>= winlen
) {
318 //version(mbeq_debug_output) conwriteln("nbufsamples+nsamples=", nbufsamples+nsamples, "; winlen=", winlen);
321 for (i
= 0; i
< (winlen
-nbufsamples
)*nch
; ++i
) {
322 inbuf
[nbufsamples
*nch
+i
] = (cast(ubyte*)buf
)[i
+p
*nch
]-0x80;
323 REAL s
= outbuf
[nbufsamples
*nch
+i
];
327 s
+= ditherbuf
[(ditherptr
++)&(DITHERLEN
-1)];
328 if (s
< amin
) s
= amin
;
329 if (amax
< s
) s
= amax
;
332 (cast(ubyte*)buf
)[i
+p
*nch
] = cast(ubyte)(s
+0x80);
334 if (s
< amin
) s
= amin
;
335 if (amax
< s
) s
= amax
;
336 (cast(ubyte*)buf
)[i
+p
*nch
] = cast(ubyte)(RINT(s
)+0x80);
339 for( i
= winlen
*nch
; i
< tabsize
*nch
; ++i
) outbuf
[i
-winlen
*nch
] = outbuf
[i
];
342 for (i
= 0; i
< (winlen
-nbufsamples
)*nch
; ++i
) {
343 inbuf
[nbufsamples
*nch
+i
] = (cast(short*)buf
)[i
+p
*nch
];
344 REAL s
= outbuf
[nbufsamples
*nch
+i
];
348 s
+= ditherbuf
[(ditherptr
++)&(DITHERLEN
-1)];
349 if (s
< amin
) s
= amin
;
350 if (amax
< s
) s
= amax
;
353 (cast(short*)buf
)[i
+p
*nch
] = cast(short)s
;
355 if (s
< amin
) s
= amin
;
356 if (amax
< s
) s
= amax
;
357 (cast(short*)buf
)[i
+p
*nch
] = cast(short)RINT(s
);
360 for (i
= winlen
*nch
; i
< tabsize
*nch
; ++i
) outbuf
[i
-winlen
*nch
] = outbuf
[i
];
364 for (i
= 0; i
< (winlen
-nbufsamples
)*nch
; ++i
) {
365 (cast(int*)inbuf
)[nbufsamples
*nch
+i
] =
366 ((cast(ubyte*)buf
)[(i
+p
*nch
)*3])|
367 ((cast(ubyte*)buf
)[(i
+p
*nch
)*3+1]<<8)|
368 ((cast(byte*)buf
)[(i
+p
*nch
)*3+2]<<16);
369 REAL s
= outbuf
[nbufsamples
*nch
+i
];
370 //static if (dither) s += ditherbuf[(ditherptr++)&(DITHERLEN-1)];
371 if (s
< amin
) s
= amin
;
372 if (amax
< s
) s
= amax
;
374 (cast(ubyte*)buf
)[(i
+p
*nch
)*3+0] = s2
&255; s2
>>= 8;
375 (cast(ubyte*)buf
)[(i
+p
*nch
)*3+1] = s2
&255; s2
>>= 8;
376 (cast(ubyte*)buf
)[(i
+p
*nch
)*3+2] = s2
&255;
378 for (i
= winlen
*nch
; i
< tabsize
*nch
; ++i
) outbuf
[i
-winlen
*nch
] = outbuf
[i
];
383 p
+= winlen
-nbufsamples
;
384 //{ import core.stdc.stdio; printf("old nsamples: %d\n", nsamples); }
385 nsamples
-= winlen
-nbufsamples
;
386 //{ import core.stdc.stdio; printf("new nsamples: %d\n", nsamples); }
389 for (ch
= 0; ch
< nch
; ++ch
) {
390 ires
= (ch
== 0 ? lires
: rires
);
393 for (i
= 0; i
< winlen
; ++i
) fsamples
[i
] = (cast(int*)inbuf
)[nch
*i
+ch
];
395 for (i
= 0; i
< winlen
; ++i
) fsamples
[i
] = inbuf
[nch
*i
+ch
];
398 //for (i = winlen; i < tabsize; ++i) fsamples[i] = 0;
399 fsamples
[winlen
..tabsize
] = 0;
401 rfft(tabsize
, 1, fsamples
);
402 fsamples
[0] = ires
[0]*fsamples
[0];
403 fsamples
[1] = ires
[1]*fsamples
[1];
404 for (i
= 1; i
< tabsize
/2; ++i
) {
405 REAL re
= ires
[i
*2 ]*fsamples
[i
*2]-ires
[i
*2+1]*fsamples
[i
*2+1];
406 REAL im
= ires
[i
*2+1]*fsamples
[i
*2]+ires
[i
*2 ]*fsamples
[i
*2+1];
408 fsamples
[i
*2+1] = im
;
410 rfft(tabsize
, -1, fsamples
);
413 for (i = winlen-1+winlen/2; i >= winlen/2; --i) fsamples[i] = fsamples[i-winlen/2]*tabsize/2;
414 for (; i >= 0; --i) fsamples[i] = 0;
418 for (i
= 0; i
< winlen
; ++i
) outbuf
[i
*nch
+ch
] += fsamples
[i
]/tabsize
*2;
419 for (i
= winlen
; i
< tabsize
; ++i
) outbuf
[i
*nch
+ch
] = fsamples
[i
]/tabsize
*2;
425 for (i
= 0; i
< nsamples
*nch
; ++i
) {
426 inbuf
[nbufsamples
*nch
+i
] = (cast(ubyte*)buf
)[i
+p
*nch
]-0x80;
427 REAL s
= outbuf
[nbufsamples
*nch
+i
];
431 s
+= ditherbuf
[(ditherptr
++)&(DITHERLEN
-1)];
432 if (s
< amin
) s
= amin
;
433 if (amax
< s
) s
= amax
;
436 (cast(ubyte*)buf
)[i
+p
*nch
] = cast(ubyte)(s
+0x80);
438 if (s
< amin
) s
= amin
;
439 if (amax
< s
) s
= amax
;
440 (cast(ubyte*)buf
)[i
+p
*nch
] = cast(ubyte)(RINT(s
)+0x80);
445 for (i
= 0; i
< nsamples
*nch
; ++i
) {
446 //{ import core.stdc.stdio; printf("i=%u; nsamples*nch=%u; nbufsamples*nch+i=%u; i+p*nch=%u\n", i, nsamples*nch, nbufsamples*nch+i, i+p*nch); }
447 inbuf
[nbufsamples
*nch
+i
] = (cast(short*)buf
)[i
+p
*nch
];
448 REAL s
= outbuf
[nbufsamples
*nch
+i
];
452 s
+= ditherbuf
[(ditherptr
++)&(DITHERLEN
-1)];
453 if (s
< amin
) s
= amin
;
454 if (amax
< s
) s
= amax
;
457 (cast(short*)buf
)[i
+p
*nch
] = cast(short)s
;
459 if (s
< amin
) s
= amin
;
460 if (amax
< s
) s
= amax
;
461 (cast(short*)buf
)[i
+p
*nch
] = cast(short)RINT(s
);
466 for (i
= 0; i
< nsamples
*nch
; ++i
) {
467 (cast(int*)inbuf
)[nbufsamples
*nch
+i
] =
468 ((cast(ubyte*)buf
)[(i
+p
*nch
)*3])|
469 ((cast(ubyte*)buf
)[(i
+p
*nch
)*3+1]<<8)|
470 ((cast(byte*)buf
)[(i
+p
*nch
)*3+2]<<16);
471 REAL s
= outbuf
[nbufsamples
*nch
+i
];
472 //static if (dither) s += ditherbuf[(ditherptr++)&(DITHERLEN-1)];
473 if (s
< amin
) s
= amin
;
474 if (amax
< s
) s
= amax
;
476 (cast(ubyte*)buf
)[(i
+p
*nch
)*3+0] = s2
&255; s2
>>= 8;
477 (cast(ubyte*)buf
)[(i
+p
*nch
)*3+1] = s2
&255; s2
>>= 8;
478 (cast(ubyte*)buf
)[(i
+p
*nch
)*3+2] = s2
&255;
485 nbufsamples
+= nsamples
;
491 // ////////////////////////////////////////////////////////////////////////// //
492 private static immutable int[NBANDS
+1] mbeqBandFreqs
= [55, 77, 110, 156, 220, 311, 440, 622, 880, 1244, 1760, 2489, 3520, 4978, 7040, 9956, 14080, 19912]; ///
493 public __gshared
int[NBANDS
+2] mbeqLSliders
; /// [0..96]; 0: preamp; 1..18: bands
494 public __gshared
int[NBANDS
+2] mbeqRSliders
; /// [0..96]; 0: preamp; 1..18: bands
495 public __gshared REAL mbeqSampleRate
= 48000; ///
498 public void mbeqSetBandsFromSliders () {
499 import std
.math
: pow
;
501 REAL
[NBANDS
+1] lbands
= 1.0;
502 REAL
[NBANDS
+1] rbands
= 1.0;
504 immutable REAL lpreamp
= (mbeqLSliders
[0] == 96 ?
0 : pow(10, mbeqLSliders
[0]/-20.0f));
505 immutable REAL rpreamp
= (mbeqRSliders
[0] == 96 ?
0 : pow(10, mbeqRSliders
[0]/-20.0f));
506 version(mbeq_debug_output
) conwriteln("lpreamp=", lpreamp
, "; rpreamp=", rpreamp
);
507 foreach (immutable i
; 0..NBANDS
+1) {
508 lbands
[i
] = (mbeqLSliders
[i
+1] == 96 ?
0 : lpreamp
*pow(10, mbeqLSliders
[i
+1]/-20.0f));
509 rbands
[i
] = (mbeqRSliders
[i
+1] == 96 ?
0 : rpreamp
*pow(10, mbeqRSliders
[i
+1]/-20.0f));
511 //mbeq_makeTable(lbands.ptr, rbands.ptr, paramroot, last_srate);
512 mbeqMakeTable(lbands
[], rbands
[], mbeqSampleRate
);
513 version(mbeq_debug_output
) conwriteln("lbands=", lbands
);
514 version(mbeq_debug_output
) conwriteln("rbands=", rbands
);
518 public int mbeqBandCount () { pragma(inline
, true); return NBANDS
+2; } ///
520 /// last band is equal to samling rate
521 public int mbeqBandFreq (int idx
) { pragma(inline
, true); return (idx
> 1 && idx
< NBANDS
+1 ? mbeqBandFreqs
[idx
-1] : (idx
== NBANDS
+1 ?
48000 : 0)); }
524 // ////////////////////////////////////////////////////////////////////////// //
527 * Copyright(C) 1996-2001 Takuya OOURA
528 * email: ooura@mmm.t.u-tokyo.ac.jp
529 * download: http://momonga.t.u-tokyo.ac.jp/~ooura/fft.html
530 * You may use, copy, modify this code for any purpose and
531 * without fee. You may distribute this ORIGINAL package.
533 //module fftsg /*is aliced*/;
534 private nothrow @trusted @nogc:
536 /*public*/ alias REAL
= float;
539 Fast Fourier/Cosine/Sine Transform
541 data length :power of 2
542 decimation :frequency
547 cdft: Complex Discrete Fourier Transform
548 rdft: Real Discrete Fourier Transform
549 ddct: Discrete Cosine Transform
550 ddst: Discrete Sine Transform
551 dfct: Cosine Transform of RDFT (Real Symmetric DFT)
552 dfst: Sine Transform of RDFT (Real Anti-symmetric DFT)
554 void cdft(int, int, REAL *, int *, REAL *);
555 void rdft(int, int, REAL *, int *, REAL *);
556 void ddct(int, int, REAL *, int *, REAL *);
557 void ddst(int, int, REAL *, int *, REAL *);
558 void dfct(int, REAL *, REAL *, int *, REAL *);
559 void dfst(int, REAL *, REAL *, int *, REAL *);
562 -------- Complex DFT (Discrete Fourier Transform) --------
565 X[k] = sum_j=0^n-1 x[j]*exp(2*pi*i*j*k/n), 0<=k<n
567 X[k] = sum_j=0^n-1 x[j]*exp(-2*pi*i*j*k/n), 0<=k<n
568 (notes: sum_j=0^n-1 is a summation from j=0 to n-1)
571 ip[0] = 0; // first time only
572 cdft(2*n, 1, a, ip, w);
574 ip[0] = 0; // first time only
575 cdft(2*n, -1, a, ip, w);
577 2*n :data length (int)
578 n >= 1, n = power of 2
579 a[0...2*n-1] :input/output data (REAL *)
582 a[2*j+1] = Im(x[j]), 0<=j<n
585 a[2*k+1] = Im(X[k]), 0<=k<n
586 ip[0...*] :work area for bit reversal (int *)
587 length of ip >= 2+sqrt(n)
590 2+(1<<(int)(log(n+0.5)/log(2))/2).
591 ip[0],ip[1] are pointers of the cos/sin table.
592 w[0...n/2-1] :cos/sin table (REAL *)
593 w[],ip[] are initialized if ip[0] == 0.
596 cdft(2*n, -1, a, ip, w);
598 cdft(2*n, 1, a, ip, w);
599 for (j = 0; j <= 2 * n - 1; j++) {
605 -------- Real DFT / Inverse of Real DFT --------
608 R[k] = sum_j=0^n-1 a[j]*cos(2*pi*j*k/n), 0<=k<=n/2
609 I[k] = sum_j=0^n-1 a[j]*sin(2*pi*j*k/n), 0<k<n/2
610 <case2> IRDFT (excluding scale)
611 a[k] = (R[0] + R[n/2]*cos(pi*k))/2 +
612 sum_j=1^n/2-1 R[j]*cos(2*pi*j*k/n) +
613 sum_j=1^n/2-1 I[j]*sin(2*pi*j*k/n), 0<=k<n
616 ip[0] = 0; // first time only
617 rdft(n, 1, a, ip, w);
619 ip[0] = 0; // first time only
620 rdft(n, -1, a, ip, w);
623 n >= 2, n = power of 2
624 a[0...n-1] :input/output data (REAL *)
627 a[2*k] = R[k], 0<=k<n/2
628 a[2*k+1] = I[k], 0<k<n/2
632 a[2*j] = R[j], 0<=j<n/2
633 a[2*j+1] = I[j], 0<j<n/2
635 ip[0...*] :work area for bit reversal (int *)
636 length of ip >= 2+sqrt(n/2)
639 2+(1<<(int)(log(n/2+0.5)/log(2))/2).
640 ip[0],ip[1] are pointers of the cos/sin table.
641 w[0...n/2-1] :cos/sin table (REAL *)
642 w[],ip[] are initialized if ip[0] == 0.
645 rdft(n, 1, a, ip, w);
647 rdft(n, -1, a, ip, w);
648 for (j = 0; j <= n - 1; j++) {
654 -------- DCT (Discrete Cosine Transform) / Inverse of DCT --------
656 <case1> IDCT (excluding scale)
657 C[k] = sum_j=0^n-1 a[j]*cos(pi*j*(k+1/2)/n), 0<=k<n
659 C[k] = sum_j=0^n-1 a[j]*cos(pi*(j+1/2)*k/n), 0<=k<n
662 ip[0] = 0; // first time only
663 ddct(n, 1, a, ip, w);
665 ip[0] = 0; // first time only
666 ddct(n, -1, a, ip, w);
669 n >= 2, n = power of 2
670 a[0...n-1] :input/output data (REAL *)
673 ip[0...*] :work area for bit reversal (int *)
674 length of ip >= 2+sqrt(n/2)
677 2+(1<<(int)(log(n/2+0.5)/log(2))/2).
678 ip[0],ip[1] are pointers of the cos/sin table.
679 w[0...n*5/4-1] :cos/sin table (REAL *)
680 w[],ip[] are initialized if ip[0] == 0.
683 ddct(n, -1, a, ip, w);
686 ddct(n, 1, a, ip, w);
687 for (j = 0; j <= n - 1; j++) {
693 -------- DST (Discrete Sine Transform) / Inverse of DST --------
695 <case1> IDST (excluding scale)
696 S[k] = sum_j=1^n A[j]*sin(pi*j*(k+1/2)/n), 0<=k<n
698 S[k] = sum_j=0^n-1 a[j]*sin(pi*(j+1/2)*k/n), 0<k<=n
701 ip[0] = 0; // first time only
702 ddst(n, 1, a, ip, w);
704 ip[0] = 0; // first time only
705 ddst(n, -1, a, ip, w);
708 n >= 2, n = power of 2
709 a[0...n-1] :input/output data (REAL *)
720 ip[0...*] :work area for bit reversal (int *)
721 length of ip >= 2+sqrt(n/2)
724 2+(1<<(int)(log(n/2+0.5)/log(2))/2).
725 ip[0],ip[1] are pointers of the cos/sin table.
726 w[0...n*5/4-1] :cos/sin table (REAL *)
727 w[],ip[] are initialized if ip[0] == 0.
730 ddst(n, -1, a, ip, w);
733 ddst(n, 1, a, ip, w);
734 for (j = 0; j <= n - 1; j++) {
740 -------- Cosine Transform of RDFT (Real Symmetric DFT) --------
742 C[k] = sum_j=0^n a[j]*cos(pi*j*k/n), 0<=k<=n
744 ip[0] = 0; // first time only
745 dfct(n, a, t, ip, w);
747 n :data length - 1 (int)
748 n >= 2, n = power of 2
749 a[0...n] :input/output data (REAL *)
752 t[0...n/2] :work area (REAL *)
753 ip[0...*] :work area for bit reversal (int *)
754 length of ip >= 2+sqrt(n/4)
757 2+(1<<(int)(log(n/4+0.5)/log(2))/2).
758 ip[0],ip[1] are pointers of the cos/sin table.
759 w[0...n*5/8-1] :cos/sin table (REAL *)
760 w[],ip[] are initialized if ip[0] == 0.
765 dfct(n, a, t, ip, w);
769 dfct(n, a, t, ip, w);
770 for (j = 0; j <= n; j++) {
776 -------- Sine Transform of RDFT (Real Anti-symmetric DFT) --------
778 S[k] = sum_j=1^n-1 a[j]*sin(pi*j*k/n), 0<k<n
780 ip[0] = 0; // first time only
781 dfst(n, a, t, ip, w);
783 n :data length + 1 (int)
784 n >= 2, n = power of 2
785 a[0...n-1] :input/output data (REAL *)
788 (a[0] is used for work area)
789 t[0...n/2-1] :work area (REAL *)
790 ip[0...*] :work area for bit reversal (int *)
791 length of ip >= 2+sqrt(n/4)
794 2+(1<<(int)(log(n/4+0.5)/log(2))/2).
795 ip[0],ip[1] are pointers of the cos/sin table.
796 w[0...n*5/8-1] :cos/sin table (REAL *)
797 w[],ip[] are initialized if ip[0] == 0.
800 dfst(n, a, t, ip, w);
802 dfst(n, a, t, ip, w);
803 for (j = 1; j <= n - 1; j++) {
810 The cos/sin table is recalculated when the larger table required.
811 w[] and ip[] are compatible with all routines.
815 // Complex Discrete Fourier Transform
816 /*public*/ void cdft (int n
, int isgn
, REAL
* a
, int* ip
, REAL
* w
) {
823 cftfsub(n
, a
, ip
, nw
, w
);
825 cftbsub(n
, a
, ip
, nw
, w
);
830 // Real Discrete Fourier Transform
831 /*public*/ void rdft (int n
, int isgn
, REAL
* a
, int* ip
, REAL
* w
) {
840 makect(nc
, ip
, w
+ nw
);
844 cftfsub(n
, a
, ip
, nw
, w
);
845 rftfsub(n
, a
, nc
, w
+ nw
);
847 cftfsub(n
, a
, ip
, nw
, w
);
849 REAL xi
= a
[0] - a
[1];
853 a
[1] = 0.5 * (a
[0] - a
[1]);
856 rftbsub(n
, a
, nc
, w
+ nw
);
857 cftbsub(n
, a
, ip
, nw
, w
);
859 cftbsub(n
, a
, ip
, nw
, w
);
865 // Discrete Cosine Transform
866 /*public*/ void ddct (int n
, int isgn
, REAL
* a
, int* ip
, REAL
* w
) {
875 makect(nc
, ip
, w
+ nw
);
879 for (int j
= n
- 2; j
>= 2; j
-= 2) {
880 a
[j
+ 1] = a
[j
] - a
[j
- 1];
886 rftbsub(n
, a
, nc
, w
+ nw
);
887 cftbsub(n
, a
, ip
, nw
, w
);
889 cftbsub(n
, a
, ip
, nw
, w
);
892 dctsub(n
, a
, nc
, w
+ nw
);
895 cftfsub(n
, a
, ip
, nw
, w
);
896 rftfsub(n
, a
, nc
, w
+ nw
);
898 cftfsub(n
, a
, ip
, nw
, w
);
900 REAL xr
= a
[0] - a
[1];
902 for (int j
= 2; j
< n
; j
+= 2) {
903 a
[j
- 1] = a
[j
] - a
[j
+ 1];
911 // Discrete Sine Transform
912 /*public*/ void ddst (int n
, int isgn
, REAL
* a
, int* ip
, REAL
* w
) {
921 makect(nc
, ip
, w
+ nw
);
925 for (int j
= n
- 2; j
>= 2; j
-= 2) {
926 a
[j
+ 1] = -a
[j
] - a
[j
- 1];
932 rftbsub(n
, a
, nc
, w
+ nw
);
933 cftbsub(n
, a
, ip
, nw
, w
);
935 cftbsub(n
, a
, ip
, nw
, w
);
938 dstsub(n
, a
, nc
, w
+ nw
);
941 cftfsub(n
, a
, ip
, nw
, w
);
942 rftfsub(n
, a
, nc
, w
+ nw
);
944 cftfsub(n
, a
, ip
, nw
, w
);
946 REAL xr
= a
[0] - a
[1];
948 for (int j
= 2; j
< n
; j
+= 2) {
949 a
[j
- 1] = -a
[j
] - a
[j
+ 1];
957 // Cosine Transform of RDFT (Real Symmetric DFT)
958 /*public*/ void dfct (int n
, REAL
* a
, REAL
* t
, int* ip
, REAL
* w
) {
959 int j
, k
, l
, m
, mh
, nw
, nc
;
960 //REAL xr, xi, yr, yi;
970 makect(nc
, ip
, w
+ nw
);
974 REAL xi
= a
[0] + a
[n
];
980 for (j
= 1; j
< mh
; j
++) {
982 REAL xr
= a
[j
] - a
[n
- j
];
983 xi
= a
[j
] + a
[n
- j
];
984 REAL yr
= a
[k
] - a
[n
- k
];
985 yi
= a
[k
] + a
[n
- k
];
991 t
[mh
] = a
[mh
] + a
[n
- mh
];
993 dctsub(m
, a
, nc
, w
+ nw
);
995 cftfsub(m
, a
, ip
, nw
, w
);
996 rftfsub(m
, a
, nc
, w
+ nw
);
998 cftfsub(m
, a
, ip
, nw
, w
);
1000 a
[n
- 1] = a
[0] - a
[1];
1002 for (j
= m
- 2; j
>= 2; j
-= 2) {
1003 a
[2 * j
+ 1] = a
[j
] + a
[j
+ 1];
1004 a
[2 * j
- 1] = a
[j
] - a
[j
+ 1];
1009 dctsub(m
, t
, nc
, w
+ nw
);
1011 cftfsub(m
, t
, ip
, nw
, w
);
1012 rftfsub(m
, t
, nc
, w
+ nw
);
1013 } else if (m
== 4) {
1014 cftfsub(m
, t
, ip
, nw
, w
);
1016 a
[n
- l
] = t
[0] - t
[1];
1019 for (j
= 2; j
< m
; j
+= 2) {
1021 a
[k
- l
] = t
[j
] - t
[j
+ 1];
1022 a
[k
+ l
] = t
[j
] + t
[j
+ 1];
1026 for (j
= 0; j
< mh
; j
++) {
1028 t
[j
] = t
[m
+ k
] - t
[m
+ j
];
1029 t
[k
] = t
[m
+ k
] + t
[m
+ j
];
1045 // Sine Transform of RDFT (Real Anti-symmetric DFT)
1046 /*public*/ void dfst (int n
, REAL
* a
, REAL
* t
, int* ip
, REAL
* w
) {
1047 int j
, k
, l
, m
, mh
, nw
, nc
;
1048 //REAL xr, xi, yr, yi;
1051 if (n
> (nw
<< 3)) {
1056 if (n
> (nc
<< 1)) {
1058 makect(nc
, ip
, w
+ nw
);
1063 for (j
= 1; j
< mh
; j
++) {
1065 REAL xr
= a
[j
] + a
[n
- j
];
1066 REAL xi
= a
[j
] - a
[n
- j
];
1067 REAL yr
= a
[k
] + a
[n
- k
];
1068 REAL yi
= a
[k
] - a
[n
- k
];
1074 t
[0] = a
[mh
] - a
[n
- mh
];
1077 dstsub(m
, a
, nc
, w
+ nw
);
1079 cftfsub(m
, a
, ip
, nw
, w
);
1080 rftfsub(m
, a
, nc
, w
+ nw
);
1081 } else if (m
== 4) {
1082 cftfsub(m
, a
, ip
, nw
, w
);
1084 a
[n
- 1] = a
[1] - a
[0];
1086 for (j
= m
- 2; j
>= 2; j
-= 2) {
1087 a
[2 * j
+ 1] = a
[j
] - a
[j
+ 1];
1088 a
[2 * j
- 1] = -a
[j
] - a
[j
+ 1];
1093 dstsub(m
, t
, nc
, w
+ nw
);
1095 cftfsub(m
, t
, ip
, nw
, w
);
1096 rftfsub(m
, t
, nc
, w
+ nw
);
1097 } else if (m
== 4) {
1098 cftfsub(m
, t
, ip
, nw
, w
);
1100 a
[n
- l
] = t
[1] - t
[0];
1103 for (j
= 2; j
< m
; j
+= 2) {
1105 a
[k
- l
] = -t
[j
] - t
[j
+ 1];
1106 a
[k
+ l
] = t
[j
] - t
[j
+ 1];
1110 for (j
= 1; j
< mh
; j
++) {
1112 t
[j
] = t
[m
+ k
] + t
[m
+ j
];
1113 t
[k
] = t
[m
+ k
] - t
[m
+ j
];
1124 // ////////////////////////////////////////////////////////////////////////// //
1126 /* -------- initializing routines -------- */
1128 void makewt(int nw
, int *ip
, REAL
*w
)
1130 import std
.math
: atan
, cos
, sin
;
1131 int j
, nwh
, nw0
, nw1
;
1132 //REAL delta, wn4r, wk1r, wk1i, wk3r, wk3i;
1138 REAL delta
= atan(1.0) / nwh
;
1139 REAL wn4r
= cos(delta
* nwh
);
1143 w
[2] = cos(delta
* 2);
1144 w
[3] = sin(delta
* 2);
1145 } else if (nwh
> 4) {
1147 w
[2] = 0.5 / cos(delta
* 2);
1148 w
[3] = 0.5 / cos(delta
* 6);
1149 for (j
= 4; j
< nwh
; j
+= 4) {
1150 w
[j
] = cos(delta
* j
);
1151 w
[j
+ 1] = sin(delta
* j
);
1152 w
[j
+ 2] = cos(3 * delta
* j
);
1153 w
[j
+ 3] = -sin(3 * delta
* j
);
1163 REAL wk1r
= w
[nw0
+ 4];
1164 REAL wk1i
= w
[nw0
+ 5];
1167 } else if (nwh
> 4) {
1168 REAL wk1r
= w
[nw0
+ 4];
1169 REAL wk9r
= w
[nw0
+ 6];
1170 w
[nw1
+ 2] = 0.5 / wk1r
;
1171 w
[nw1
+ 3] = 0.5 / wk9r
;
1172 for (j
= 4; j
< nwh
; j
+= 4) {
1173 wk1r
= w
[nw0
+ 2 * j
];
1174 REAL wk1i
= w
[nw0
+ 2 * j
+ 1];
1175 REAL wk3r
= w
[nw0
+ 2 * j
+ 2];
1176 REAL wk3i
= w
[nw0
+ 2 * j
+ 3];
1178 w
[nw1
+ j
+ 1] = wk1i
;
1179 w
[nw1
+ j
+ 2] = wk3r
;
1180 w
[nw1
+ j
+ 3] = wk3i
;
1189 void makeipt(int nw
, int *ip
)
1191 int j
, l
, m
, m2
, p
, q
;
1196 for (l
= nw
; l
> 32; l
>>= 2) {
1199 for (j
= m
; j
< m2
; j
++) {
1209 void makect(int nc
, int *ip
, REAL
*c
)
1211 import std
.math
: atan
, cos
, sin
;
1218 REAL delta
= atan(1.0) / nch
;
1219 c
[0] = cos(delta
* nch
);
1220 c
[nch
] = 0.5 * c
[0];
1221 for (j
= 1; j
< nch
; j
++) {
1222 c
[j
] = 0.5 * cos(delta
* j
);
1223 c
[nc
- j
] = 0.5 * sin(delta
* j
);
1229 /* -------- child routines -------- */
1231 void cftfsub(int n
, REAL
*a
, int *ip
, int nw
, REAL
*w
)
1236 cftf1st(n
, a
, &w
[nw
- (n
>> 2)]);
1238 cftrec4(n
, a
, nw
, w
);
1239 } else if (n
> 128) {
1240 cftleaf(n
, 1, a
, nw
, w
);
1242 cftfx41(n
, a
, nw
, w
);
1245 } else if (n
== 32) {
1246 cftf161(a
, &w
[nw
- 8]);
1252 } else if (n
== 8) {
1254 } else if (n
== 4) {
1260 void cftbsub(int n
, REAL
*a
, int *ip
, int nw
, REAL
*w
)
1264 cftb1st(n
, a
, &w
[nw
- (n
>> 2)]);
1266 cftrec4(n
, a
, nw
, w
);
1267 } else if (n
> 128) {
1268 cftleaf(n
, 1, a
, nw
, w
);
1270 cftfx41(n
, a
, nw
, w
);
1272 bitrv2conj(n
, ip
, a
);
1273 } else if (n
== 32) {
1274 cftf161(a
, &w
[nw
- 8]);
1280 } else if (n
== 8) {
1282 } else if (n
== 4) {
1288 void bitrv2(int n
, int *ip
, REAL
*a
)
1290 int j
, j1
, k
, k1
, l
, m
, nh
, nm
;
1291 //REAL xr, xi, yr, yi;
1294 for (l
= n
>> 2; l
> 8; l
>>= 2) {
1300 for (k
= 0; k
< m
; k
++) {
1301 for (j
= 0; j
< k
; j
++) {
1302 j1
= 4 * j
+ 2 * ip
[m
+ k
];
1303 k1
= 4 * k
+ 2 * ip
[m
+ j
];
1305 REAL xi
= a
[j1
+ 1];
1307 REAL yi
= a
[k1
+ 1];
1463 k1
= 4 * k
+ 2 * ip
[m
+ k
];
1467 REAL xi
= a
[j1
+ 1];
1469 REAL yi
= a
[k1
+ 1];
1526 for (k
= 0; k
< m
; k
++) {
1527 for (j
= 0; j
< k
; j
++) {
1528 j1
= 4 * j
+ ip
[m
+ k
];
1529 k1
= 4 * k
+ ip
[m
+ j
];
1531 REAL xi
= a
[j1
+ 1];
1533 REAL yi
= a
[k1
+ 1];
1609 k1
= 4 * k
+ ip
[m
+ k
];
1613 REAL xi
= a
[j1
+ 1];
1615 REAL yi
= a
[k1
+ 1];
1635 void bitrv2conj(int n
, int *ip
, REAL
*a
)
1637 int j
, j1
, k
, k1
, l
, m
, nh
, nm
;
1638 //REAL xr, xi, yr, yi;
1641 for (l
= n
>> 2; l
> 8; l
>>= 2) {
1647 for (k
= 0; k
< m
; k
++) {
1648 for (j
= 0; j
< k
; j
++) {
1649 j1
= 4 * j
+ 2 * ip
[m
+ k
];
1650 k1
= 4 * k
+ 2 * ip
[m
+ j
];
1652 REAL xi
= -a
[j1
+ 1];
1654 REAL yi
= -a
[k1
+ 1];
1810 k1
= 4 * k
+ 2 * ip
[m
+ k
];
1813 a
[j1
- 1] = -a
[j1
- 1];
1815 REAL xi
= -a
[j1
+ 1];
1817 REAL yi
= -a
[k1
+ 1];
1822 a
[k1
+ 3] = -a
[k1
+ 3];
1865 a
[j1
- 1] = -a
[j1
- 1];
1874 a
[k1
+ 3] = -a
[k1
+ 3];
1877 for (k
= 0; k
< m
; k
++) {
1878 for (j
= 0; j
< k
; j
++) {
1879 j1
= 4 * j
+ ip
[m
+ k
];
1880 k1
= 4 * k
+ ip
[m
+ j
];
1882 REAL xi
= -a
[j1
+ 1];
1884 REAL yi
= -a
[k1
+ 1];
1960 k1
= 4 * k
+ ip
[m
+ k
];
1963 a
[j1
- 1] = -a
[j1
- 1];
1965 REAL xi
= -a
[j1
+ 1];
1967 REAL yi
= -a
[k1
+ 1];
1972 a
[k1
+ 3] = -a
[k1
+ 3];
1975 a
[j1
- 1] = -a
[j1
- 1];
1984 a
[k1
+ 3] = -a
[k1
+ 3];
1990 void bitrv216(REAL
*a
)
1993 REAL x1r, x1i, x2r, x2i, x3r, x3i, x4r, x4i,
1994 x5r, x5i, x7r, x7i, x8r, x8i, x10r, x10i,
1995 x11r, x11i, x12r, x12i, x13r, x13i, x14r, x14i;
1997 immutable REAL x1r
= a
[2];
1998 immutable REAL x1i
= a
[3];
1999 immutable REAL x2r
= a
[4];
2000 immutable REAL x2i
= a
[5];
2001 immutable REAL x3r
= a
[6];
2002 immutable REAL x3i
= a
[7];
2003 immutable REAL x4r
= a
[8];
2004 immutable REAL x4i
= a
[9];
2005 immutable REAL x5r
= a
[10];
2006 immutable REAL x5i
= a
[11];
2007 immutable REAL x7r
= a
[14];
2008 immutable REAL x7i
= a
[15];
2009 immutable REAL x8r
= a
[16];
2010 immutable REAL x8i
= a
[17];
2011 immutable REAL x10r
= a
[20];
2012 immutable REAL x10i
= a
[21];
2013 immutable REAL x11r
= a
[22];
2014 immutable REAL x11i
= a
[23];
2015 immutable REAL x12r
= a
[24];
2016 immutable REAL x12i
= a
[25];
2017 immutable REAL x13r
= a
[26];
2018 immutable REAL x13i
= a
[27];
2019 immutable REAL x14r
= a
[28];
2020 immutable REAL x14i
= a
[29];
2048 void bitrv216neg(REAL
*a
)
2051 REAL x1r, x1i, x2r, x2i, x3r, x3i, x4r, x4i,
2052 x5r, x5i, x6r, x6i, x7r, x7i, x8r, x8i,
2053 x9r, x9i, x10r, x10i, x11r, x11i, x12r, x12i,
2054 x13r, x13i, x14r, x14i, x15r, x15i;
2056 immutable REAL x1r
= a
[2];
2057 immutable REAL x1i
= a
[3];
2058 immutable REAL x2r
= a
[4];
2059 immutable REAL x2i
= a
[5];
2060 immutable REAL x3r
= a
[6];
2061 immutable REAL x3i
= a
[7];
2062 immutable REAL x4r
= a
[8];
2063 immutable REAL x4i
= a
[9];
2064 immutable REAL x5r
= a
[10];
2065 immutable REAL x5i
= a
[11];
2066 immutable REAL x6r
= a
[12];
2067 immutable REAL x6i
= a
[13];
2068 immutable REAL x7r
= a
[14];
2069 immutable REAL x7i
= a
[15];
2070 immutable REAL x8r
= a
[16];
2071 immutable REAL x8i
= a
[17];
2072 immutable REAL x9r
= a
[18];
2073 immutable REAL x9i
= a
[19];
2074 immutable REAL x10r
= a
[20];
2075 immutable REAL x10i
= a
[21];
2076 immutable REAL x11r
= a
[22];
2077 immutable REAL x11i
= a
[23];
2078 immutable REAL x12r
= a
[24];
2079 immutable REAL x12i
= a
[25];
2080 immutable REAL x13r
= a
[26];
2081 immutable REAL x13i
= a
[27];
2082 immutable REAL x14r
= a
[28];
2083 immutable REAL x14i
= a
[29];
2084 immutable REAL x15r
= a
[30];
2085 immutable REAL x15i
= a
[31];
2119 void bitrv208(REAL
*a
)
2121 //REAL x1r, x1i, x3r, x3i, x4r, x4i, x6r, x6i;
2123 immutable REAL x1r
= a
[2];
2124 immutable REAL x1i
= a
[3];
2125 immutable REAL x3r
= a
[6];
2126 immutable REAL x3i
= a
[7];
2127 immutable REAL x4r
= a
[8];
2128 immutable REAL x4i
= a
[9];
2129 immutable REAL x6r
= a
[12];
2130 immutable REAL x6i
= a
[13];
2142 void bitrv208neg(REAL
*a
)
2144 //REAL x1r, x1i, x2r, x2i, x3r, x3i, x4r, x4i, x5r, x5i, x6r, x6i, x7r, x7i;
2146 immutable REAL x1r
= a
[2];
2147 immutable REAL x1i
= a
[3];
2148 immutable REAL x2r
= a
[4];
2149 immutable REAL x2i
= a
[5];
2150 immutable REAL x3r
= a
[6];
2151 immutable REAL x3i
= a
[7];
2152 immutable REAL x4r
= a
[8];
2153 immutable REAL x4i
= a
[9];
2154 immutable REAL x5r
= a
[10];
2155 immutable REAL x5i
= a
[11];
2156 immutable REAL x6r
= a
[12];
2157 immutable REAL x6i
= a
[13];
2158 immutable REAL x7r
= a
[14];
2159 immutable REAL x7i
= a
[15];
2177 void cftf1st(int n
, REAL
*a
, REAL
*w
)
2179 int j
, j0
, j1
, j2
, j3
, k
, m
, mh
;
2180 //REAL wn4r, csc1, csc3, wk1r, wk1i, wk3r, wk3i, wd1r, wd1i, wd3r, wd3i;
2181 //REAL x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i, y0r, y0i, y1r, y1i, y2r, y2i, y3r, y3i;
2188 REAL x0r
= a
[0] + a
[j2
];
2189 REAL x0i
= a
[1] + a
[j2
+ 1];
2190 REAL x1r
= a
[0] - a
[j2
];
2191 REAL x1i
= a
[1] - a
[j2
+ 1];
2192 REAL x2r
= a
[j1
] + a
[j3
];
2193 REAL x2i
= a
[j1
+ 1] + a
[j3
+ 1];
2194 REAL x3r
= a
[j1
] - a
[j3
];
2195 REAL x3i
= a
[j1
+ 1] - a
[j3
+ 1];
2199 a
[j1
+ 1] = x0i
- x2i
;
2201 a
[j2
+ 1] = x1i
+ x3r
;
2203 a
[j3
+ 1] = x1i
- x3r
;
2212 for (j
= 2; j
< mh
- 2; j
+= 4) {
2214 REAL wk1r
= csc1
* (wd1r
+ w
[k
]);
2215 REAL wk1i
= csc1
* (wd1i
+ w
[k
+ 1]);
2216 REAL wk3r
= csc3
* (wd3r
+ w
[k
+ 2]);
2217 REAL wk3i
= csc3
* (wd3i
+ w
[k
+ 3]);
2226 x0i
= a
[j
+ 1] + a
[j2
+ 1];
2228 x1i
= a
[j
+ 1] - a
[j2
+ 1];
2229 REAL y0r
= a
[j
+ 2] + a
[j2
+ 2];
2230 REAL y0i
= a
[j
+ 3] + a
[j2
+ 3];
2231 REAL y1r
= a
[j
+ 2] - a
[j2
+ 2];
2232 REAL y1i
= a
[j
+ 3] - a
[j2
+ 3];
2233 x2r
= a
[j1
] + a
[j3
];
2234 x2i
= a
[j1
+ 1] + a
[j3
+ 1];
2235 x3r
= a
[j1
] - a
[j3
];
2236 x3i
= a
[j1
+ 1] - a
[j3
+ 1];
2237 REAL y2r
= a
[j1
+ 2] + a
[j3
+ 2];
2238 REAL y2i
= a
[j1
+ 3] + a
[j3
+ 3];
2239 REAL y3r
= a
[j1
+ 2] - a
[j3
+ 2];
2240 REAL y3i
= a
[j1
+ 3] - a
[j3
+ 3];
2242 a
[j
+ 1] = x0i
+ x2i
;
2243 a
[j
+ 2] = y0r
+ y2r
;
2244 a
[j
+ 3] = y0i
+ y2i
;
2246 a
[j1
+ 1] = x0i
- x2i
;
2247 a
[j1
+ 2] = y0r
- y2r
;
2248 a
[j1
+ 3] = y0i
- y2i
;
2251 a
[j2
] = wk1r
* x0r
- wk1i
* x0i
;
2252 a
[j2
+ 1] = wk1r
* x0i
+ wk1i
* x0r
;
2255 a
[j2
+ 2] = wd1r
* x0r
- wd1i
* x0i
;
2256 a
[j2
+ 3] = wd1r
* x0i
+ wd1i
* x0r
;
2259 a
[j3
] = wk3r
* x0r
+ wk3i
* x0i
;
2260 a
[j3
+ 1] = wk3r
* x0i
- wk3i
* x0r
;
2263 a
[j3
+ 2] = wd3r
* x0r
+ wd3i
* x0i
;
2264 a
[j3
+ 3] = wd3r
* x0i
- wd3i
* x0r
;
2269 x0r
= a
[j0
] + a
[j2
];
2270 x0i
= a
[j0
+ 1] + a
[j2
+ 1];
2271 x1r
= a
[j0
] - a
[j2
];
2272 x1i
= a
[j0
+ 1] - a
[j2
+ 1];
2273 y0r
= a
[j0
- 2] + a
[j2
- 2];
2274 y0i
= a
[j0
- 1] + a
[j2
- 1];
2275 y1r
= a
[j0
- 2] - a
[j2
- 2];
2276 y1i
= a
[j0
- 1] - a
[j2
- 1];
2277 x2r
= a
[j1
] + a
[j3
];
2278 x2i
= a
[j1
+ 1] + a
[j3
+ 1];
2279 x3r
= a
[j1
] - a
[j3
];
2280 x3i
= a
[j1
+ 1] - a
[j3
+ 1];
2281 y2r
= a
[j1
- 2] + a
[j3
- 2];
2282 y2i
= a
[j1
- 1] + a
[j3
- 1];
2283 y3r
= a
[j1
- 2] - a
[j3
- 2];
2284 y3i
= a
[j1
- 1] - a
[j3
- 1];
2286 a
[j0
+ 1] = x0i
+ x2i
;
2287 a
[j0
- 2] = y0r
+ y2r
;
2288 a
[j0
- 1] = y0i
+ y2i
;
2290 a
[j1
+ 1] = x0i
- x2i
;
2291 a
[j1
- 2] = y0r
- y2r
;
2292 a
[j1
- 1] = y0i
- y2i
;
2295 a
[j2
] = wk1i
* x0r
- wk1r
* x0i
;
2296 a
[j2
+ 1] = wk1i
* x0i
+ wk1r
* x0r
;
2299 a
[j2
- 2] = wd1i
* x0r
- wd1r
* x0i
;
2300 a
[j2
- 1] = wd1i
* x0i
+ wd1r
* x0r
;
2303 a
[j3
] = wk3i
* x0r
+ wk3r
* x0i
;
2304 a
[j3
+ 1] = wk3i
* x0i
- wk3r
* x0r
;
2307 a
[j3
- 2] = wd3i
* x0r
+ wd3r
* x0i
;
2308 a
[j3
- 1] = wd3i
* x0i
- wd3r
* x0r
;
2310 REAL wk1r
= csc1
* (wd1r
+ wn4r
);
2311 REAL wk1i
= csc1
* (wd1i
+ wn4r
);
2312 REAL wk3r
= csc3
* (wd3r
- wn4r
);
2313 REAL wk3i
= csc3
* (wd3i
- wn4r
);
2318 x0r
= a
[j0
- 2] + a
[j2
- 2];
2319 x0i
= a
[j0
- 1] + a
[j2
- 1];
2320 x1r
= a
[j0
- 2] - a
[j2
- 2];
2321 x1i
= a
[j0
- 1] - a
[j2
- 1];
2322 x2r
= a
[j1
- 2] + a
[j3
- 2];
2323 x2i
= a
[j1
- 1] + a
[j3
- 1];
2324 x3r
= a
[j1
- 2] - a
[j3
- 2];
2325 x3i
= a
[j1
- 1] - a
[j3
- 1];
2326 a
[j0
- 2] = x0r
+ x2r
;
2327 a
[j0
- 1] = x0i
+ x2i
;
2328 a
[j1
- 2] = x0r
- x2r
;
2329 a
[j1
- 1] = x0i
- x2i
;
2332 a
[j2
- 2] = wk1r
* x0r
- wk1i
* x0i
;
2333 a
[j2
- 1] = wk1r
* x0i
+ wk1i
* x0r
;
2336 a
[j3
- 2] = wk3r
* x0r
+ wk3i
* x0i
;
2337 a
[j3
- 1] = wk3r
* x0i
- wk3i
* x0r
;
2338 x0r
= a
[j0
] + a
[j2
];
2339 x0i
= a
[j0
+ 1] + a
[j2
+ 1];
2340 x1r
= a
[j0
] - a
[j2
];
2341 x1i
= a
[j0
+ 1] - a
[j2
+ 1];
2342 x2r
= a
[j1
] + a
[j3
];
2343 x2i
= a
[j1
+ 1] + a
[j3
+ 1];
2344 x3r
= a
[j1
] - a
[j3
];
2345 x3i
= a
[j1
+ 1] - a
[j3
+ 1];
2347 a
[j0
+ 1] = x0i
+ x2i
;
2349 a
[j1
+ 1] = x0i
- x2i
;
2352 a
[j2
] = wn4r
* (x0r
- x0i
);
2353 a
[j2
+ 1] = wn4r
* (x0i
+ x0r
);
2356 a
[j3
] = -wn4r
* (x0r
+ x0i
);
2357 a
[j3
+ 1] = -wn4r
* (x0i
- x0r
);
2358 x0r
= a
[j0
+ 2] + a
[j2
+ 2];
2359 x0i
= a
[j0
+ 3] + a
[j2
+ 3];
2360 x1r
= a
[j0
+ 2] - a
[j2
+ 2];
2361 x1i
= a
[j0
+ 3] - a
[j2
+ 3];
2362 x2r
= a
[j1
+ 2] + a
[j3
+ 2];
2363 x2i
= a
[j1
+ 3] + a
[j3
+ 3];
2364 x3r
= a
[j1
+ 2] - a
[j3
+ 2];
2365 x3i
= a
[j1
+ 3] - a
[j3
+ 3];
2366 a
[j0
+ 2] = x0r
+ x2r
;
2367 a
[j0
+ 3] = x0i
+ x2i
;
2368 a
[j1
+ 2] = x0r
- x2r
;
2369 a
[j1
+ 3] = x0i
- x2i
;
2372 a
[j2
+ 2] = wk1i
* x0r
- wk1r
* x0i
;
2373 a
[j2
+ 3] = wk1i
* x0i
+ wk1r
* x0r
;
2376 a
[j3
+ 2] = wk3i
* x0r
+ wk3r
* x0i
;
2377 a
[j3
+ 3] = wk3i
* x0i
- wk3r
* x0r
;
2381 void cftb1st(int n
, REAL
*a
, REAL
*w
)
2383 int j
, j0
, j1
, j2
, j3
, k
, m
, mh
;
2384 //REAL wn4r, csc1, csc3, wk1r, wk1i, wk3r, wk3i, wd1r, wd1i, wd3r, wd3i;
2385 //REAL x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i, y0r, y0i, y1r, y1i, y2r, y2i, y3r, y3i;
2392 REAL x0r
= a
[0] + a
[j2
];
2393 REAL x0i
= -a
[1] - a
[j2
+ 1];
2394 REAL x1r
= a
[0] - a
[j2
];
2395 REAL x1i
= -a
[1] + a
[j2
+ 1];
2396 REAL x2r
= a
[j1
] + a
[j3
];
2397 REAL x2i
= a
[j1
+ 1] + a
[j3
+ 1];
2398 REAL x3r
= a
[j1
] - a
[j3
];
2399 REAL x3i
= a
[j1
+ 1] - a
[j3
+ 1];
2403 a
[j1
+ 1] = x0i
+ x2i
;
2405 a
[j2
+ 1] = x1i
+ x3r
;
2407 a
[j3
+ 1] = x1i
- x3r
;
2416 for (j
= 2; j
< mh
- 2; j
+= 4) {
2418 REAL wk1r
= csc1
* (wd1r
+ w
[k
]);
2419 REAL wk1i
= csc1
* (wd1i
+ w
[k
+ 1]);
2420 REAL wk3r
= csc3
* (wd3r
+ w
[k
+ 2]);
2421 REAL wk3i
= csc3
* (wd3i
+ w
[k
+ 3]);
2430 x0i
= -a
[j
+ 1] - a
[j2
+ 1];
2432 x1i
= -a
[j
+ 1] + a
[j2
+ 1];
2433 REAL y0r
= a
[j
+ 2] + a
[j2
+ 2];
2434 REAL y0i
= -a
[j
+ 3] - a
[j2
+ 3];
2435 REAL y1r
= a
[j
+ 2] - a
[j2
+ 2];
2436 REAL y1i
= -a
[j
+ 3] + a
[j2
+ 3];
2437 x2r
= a
[j1
] + a
[j3
];
2438 x2i
= a
[j1
+ 1] + a
[j3
+ 1];
2439 x3r
= a
[j1
] - a
[j3
];
2440 x3i
= a
[j1
+ 1] - a
[j3
+ 1];
2441 REAL y2r
= a
[j1
+ 2] + a
[j3
+ 2];
2442 REAL y2i
= a
[j1
+ 3] + a
[j3
+ 3];
2443 REAL y3r
= a
[j1
+ 2] - a
[j3
+ 2];
2444 REAL y3i
= a
[j1
+ 3] - a
[j3
+ 3];
2446 a
[j
+ 1] = x0i
- x2i
;
2447 a
[j
+ 2] = y0r
+ y2r
;
2448 a
[j
+ 3] = y0i
- y2i
;
2450 a
[j1
+ 1] = x0i
+ x2i
;
2451 a
[j1
+ 2] = y0r
- y2r
;
2452 a
[j1
+ 3] = y0i
+ y2i
;
2455 a
[j2
] = wk1r
* x0r
- wk1i
* x0i
;
2456 a
[j2
+ 1] = wk1r
* x0i
+ wk1i
* x0r
;
2459 a
[j2
+ 2] = wd1r
* x0r
- wd1i
* x0i
;
2460 a
[j2
+ 3] = wd1r
* x0i
+ wd1i
* x0r
;
2463 a
[j3
] = wk3r
* x0r
+ wk3i
* x0i
;
2464 a
[j3
+ 1] = wk3r
* x0i
- wk3i
* x0r
;
2467 a
[j3
+ 2] = wd3r
* x0r
+ wd3i
* x0i
;
2468 a
[j3
+ 3] = wd3r
* x0i
- wd3i
* x0r
;
2473 x0r
= a
[j0
] + a
[j2
];
2474 x0i
= -a
[j0
+ 1] - a
[j2
+ 1];
2475 x1r
= a
[j0
] - a
[j2
];
2476 x1i
= -a
[j0
+ 1] + a
[j2
+ 1];
2477 y0r
= a
[j0
- 2] + a
[j2
- 2];
2478 y0i
= -a
[j0
- 1] - a
[j2
- 1];
2479 y1r
= a
[j0
- 2] - a
[j2
- 2];
2480 y1i
= -a
[j0
- 1] + a
[j2
- 1];
2481 x2r
= a
[j1
] + a
[j3
];
2482 x2i
= a
[j1
+ 1] + a
[j3
+ 1];
2483 x3r
= a
[j1
] - a
[j3
];
2484 x3i
= a
[j1
+ 1] - a
[j3
+ 1];
2485 y2r
= a
[j1
- 2] + a
[j3
- 2];
2486 y2i
= a
[j1
- 1] + a
[j3
- 1];
2487 y3r
= a
[j1
- 2] - a
[j3
- 2];
2488 y3i
= a
[j1
- 1] - a
[j3
- 1];
2490 a
[j0
+ 1] = x0i
- x2i
;
2491 a
[j0
- 2] = y0r
+ y2r
;
2492 a
[j0
- 1] = y0i
- y2i
;
2494 a
[j1
+ 1] = x0i
+ x2i
;
2495 a
[j1
- 2] = y0r
- y2r
;
2496 a
[j1
- 1] = y0i
+ y2i
;
2499 a
[j2
] = wk1i
* x0r
- wk1r
* x0i
;
2500 a
[j2
+ 1] = wk1i
* x0i
+ wk1r
* x0r
;
2503 a
[j2
- 2] = wd1i
* x0r
- wd1r
* x0i
;
2504 a
[j2
- 1] = wd1i
* x0i
+ wd1r
* x0r
;
2507 a
[j3
] = wk3i
* x0r
+ wk3r
* x0i
;
2508 a
[j3
+ 1] = wk3i
* x0i
- wk3r
* x0r
;
2511 a
[j3
- 2] = wd3i
* x0r
+ wd3r
* x0i
;
2512 a
[j3
- 1] = wd3i
* x0i
- wd3r
* x0r
;
2514 REAL wk1r
= csc1
* (wd1r
+ wn4r
);
2515 REAL wk1i
= csc1
* (wd1i
+ wn4r
);
2516 REAL wk3r
= csc3
* (wd3r
- wn4r
);
2517 REAL wk3i
= csc3
* (wd3i
- wn4r
);
2522 x0r
= a
[j0
- 2] + a
[j2
- 2];
2523 x0i
= -a
[j0
- 1] - a
[j2
- 1];
2524 x1r
= a
[j0
- 2] - a
[j2
- 2];
2525 x1i
= -a
[j0
- 1] + a
[j2
- 1];
2526 x2r
= a
[j1
- 2] + a
[j3
- 2];
2527 x2i
= a
[j1
- 1] + a
[j3
- 1];
2528 x3r
= a
[j1
- 2] - a
[j3
- 2];
2529 x3i
= a
[j1
- 1] - a
[j3
- 1];
2530 a
[j0
- 2] = x0r
+ x2r
;
2531 a
[j0
- 1] = x0i
- x2i
;
2532 a
[j1
- 2] = x0r
- x2r
;
2533 a
[j1
- 1] = x0i
+ x2i
;
2536 a
[j2
- 2] = wk1r
* x0r
- wk1i
* x0i
;
2537 a
[j2
- 1] = wk1r
* x0i
+ wk1i
* x0r
;
2540 a
[j3
- 2] = wk3r
* x0r
+ wk3i
* x0i
;
2541 a
[j3
- 1] = wk3r
* x0i
- wk3i
* x0r
;
2542 x0r
= a
[j0
] + a
[j2
];
2543 x0i
= -a
[j0
+ 1] - a
[j2
+ 1];
2544 x1r
= a
[j0
] - a
[j2
];
2545 x1i
= -a
[j0
+ 1] + a
[j2
+ 1];
2546 x2r
= a
[j1
] + a
[j3
];
2547 x2i
= a
[j1
+ 1] + a
[j3
+ 1];
2548 x3r
= a
[j1
] - a
[j3
];
2549 x3i
= a
[j1
+ 1] - a
[j3
+ 1];
2551 a
[j0
+ 1] = x0i
- x2i
;
2553 a
[j1
+ 1] = x0i
+ x2i
;
2556 a
[j2
] = wn4r
* (x0r
- x0i
);
2557 a
[j2
+ 1] = wn4r
* (x0i
+ x0r
);
2560 a
[j3
] = -wn4r
* (x0r
+ x0i
);
2561 a
[j3
+ 1] = -wn4r
* (x0i
- x0r
);
2562 x0r
= a
[j0
+ 2] + a
[j2
+ 2];
2563 x0i
= -a
[j0
+ 3] - a
[j2
+ 3];
2564 x1r
= a
[j0
+ 2] - a
[j2
+ 2];
2565 x1i
= -a
[j0
+ 3] + a
[j2
+ 3];
2566 x2r
= a
[j1
+ 2] + a
[j3
+ 2];
2567 x2i
= a
[j1
+ 3] + a
[j3
+ 3];
2568 x3r
= a
[j1
+ 2] - a
[j3
+ 2];
2569 x3i
= a
[j1
+ 3] - a
[j3
+ 3];
2570 a
[j0
+ 2] = x0r
+ x2r
;
2571 a
[j0
+ 3] = x0i
- x2i
;
2572 a
[j1
+ 2] = x0r
- x2r
;
2573 a
[j1
+ 3] = x0i
+ x2i
;
2576 a
[j2
+ 2] = wk1i
* x0r
- wk1r
* x0i
;
2577 a
[j2
+ 3] = wk1i
* x0i
+ wk1r
* x0r
;
2580 a
[j3
+ 2] = wk3i
* x0r
+ wk3r
* x0i
;
2581 a
[j3
+ 3] = wk3i
* x0i
- wk3r
* x0r
;
2585 void cftrec4(int n
, REAL
*a
, int nw
, REAL
*w
)
2592 cftmdl1(m
, &a
[n
- m
], &w
[nw
- (m
>> 1)]);
2594 cftleaf(m
, 1, &a
[n
- m
], nw
, w
);
2596 for (j
= n
- m
; j
> 0; j
-= m
) {
2598 isplt
= cfttree(m
, j
, k
, a
, nw
, w
);
2599 cftleaf(m
, isplt
, &a
[j
- m
], nw
, w
);
2604 int cfttree(int n
, int j
, int k
, REAL
*a
, int nw
, REAL
*w
)
2611 cftmdl1(n
, &a
[j
- n
], &w
[nw
- (n
>> 1)]);
2613 cftmdl2(n
, &a
[j
- n
], &w
[nw
- n
]);
2617 for (i
= k
; (i
& 3) == 0; i
>>= 2) {
2623 cftmdl1(m
, &a
[j
- m
], &w
[nw
- (m
>> 1)]);
2628 cftmdl2(m
, &a
[j
- m
], &w
[nw
- m
]);
2637 void cftleaf(int n
, int isplt
, REAL
*a
, int nw
, REAL
*w
)
2640 cftmdl1(128, a
, &w
[nw
- 64]);
2641 cftf161(a
, &w
[nw
- 8]);
2642 cftf162(&a
[32], &w
[nw
- 32]);
2643 cftf161(&a
[64], &w
[nw
- 8]);
2644 cftf161(&a
[96], &w
[nw
- 8]);
2645 cftmdl2(128, &a
[128], &w
[nw
- 128]);
2646 cftf161(&a
[128], &w
[nw
- 8]);
2647 cftf162(&a
[160], &w
[nw
- 32]);
2648 cftf161(&a
[192], &w
[nw
- 8]);
2649 cftf162(&a
[224], &w
[nw
- 32]);
2650 cftmdl1(128, &a
[256], &w
[nw
- 64]);
2651 cftf161(&a
[256], &w
[nw
- 8]);
2652 cftf162(&a
[288], &w
[nw
- 32]);
2653 cftf161(&a
[320], &w
[nw
- 8]);
2654 cftf161(&a
[352], &w
[nw
- 8]);
2656 cftmdl1(128, &a
[384], &w
[nw
- 64]);
2657 cftf161(&a
[480], &w
[nw
- 8]);
2659 cftmdl2(128, &a
[384], &w
[nw
- 128]);
2660 cftf162(&a
[480], &w
[nw
- 32]);
2662 cftf161(&a
[384], &w
[nw
- 8]);
2663 cftf162(&a
[416], &w
[nw
- 32]);
2664 cftf161(&a
[448], &w
[nw
- 8]);
2666 cftmdl1(64, a
, &w
[nw
- 32]);
2667 cftf081(a
, &w
[nw
- 8]);
2668 cftf082(&a
[16], &w
[nw
- 8]);
2669 cftf081(&a
[32], &w
[nw
- 8]);
2670 cftf081(&a
[48], &w
[nw
- 8]);
2671 cftmdl2(64, &a
[64], &w
[nw
- 64]);
2672 cftf081(&a
[64], &w
[nw
- 8]);
2673 cftf082(&a
[80], &w
[nw
- 8]);
2674 cftf081(&a
[96], &w
[nw
- 8]);
2675 cftf082(&a
[112], &w
[nw
- 8]);
2676 cftmdl1(64, &a
[128], &w
[nw
- 32]);
2677 cftf081(&a
[128], &w
[nw
- 8]);
2678 cftf082(&a
[144], &w
[nw
- 8]);
2679 cftf081(&a
[160], &w
[nw
- 8]);
2680 cftf081(&a
[176], &w
[nw
- 8]);
2682 cftmdl1(64, &a
[192], &w
[nw
- 32]);
2683 cftf081(&a
[240], &w
[nw
- 8]);
2685 cftmdl2(64, &a
[192], &w
[nw
- 64]);
2686 cftf082(&a
[240], &w
[nw
- 8]);
2688 cftf081(&a
[192], &w
[nw
- 8]);
2689 cftf082(&a
[208], &w
[nw
- 8]);
2690 cftf081(&a
[224], &w
[nw
- 8]);
2695 void cftmdl1(int n
, REAL
*a
, REAL
*w
)
2697 int j
, j0
, j1
, j2
, j3
, k
, m
, mh
;
2698 //REAL wn4r, wk1r, wk1i, wk3r, wk3i;
2699 //REAL x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i;
2706 REAL x0r
= a
[0] + a
[j2
];
2707 REAL x0i
= a
[1] + a
[j2
+ 1];
2708 REAL x1r
= a
[0] - a
[j2
];
2709 REAL x1i
= a
[1] - a
[j2
+ 1];
2710 REAL x2r
= a
[j1
] + a
[j3
];
2711 REAL x2i
= a
[j1
+ 1] + a
[j3
+ 1];
2712 REAL x3r
= a
[j1
] - a
[j3
];
2713 REAL x3i
= a
[j1
+ 1] - a
[j3
+ 1];
2717 a
[j1
+ 1] = x0i
- x2i
;
2719 a
[j2
+ 1] = x1i
+ x3r
;
2721 a
[j3
+ 1] = x1i
- x3r
;
2724 for (j
= 2; j
< mh
; j
+= 2) {
2727 REAL wk1i
= w
[k
+ 1];
2728 REAL wk3r
= w
[k
+ 2];
2729 REAL wk3i
= w
[k
+ 3];
2734 x0i
= a
[j
+ 1] + a
[j2
+ 1];
2736 x1i
= a
[j
+ 1] - a
[j2
+ 1];
2737 x2r
= a
[j1
] + a
[j3
];
2738 x2i
= a
[j1
+ 1] + a
[j3
+ 1];
2739 x3r
= a
[j1
] - a
[j3
];
2740 x3i
= a
[j1
+ 1] - a
[j3
+ 1];
2742 a
[j
+ 1] = x0i
+ x2i
;
2744 a
[j1
+ 1] = x0i
- x2i
;
2747 a
[j2
] = wk1r
* x0r
- wk1i
* x0i
;
2748 a
[j2
+ 1] = wk1r
* x0i
+ wk1i
* x0r
;
2751 a
[j3
] = wk3r
* x0r
+ wk3i
* x0i
;
2752 a
[j3
+ 1] = wk3r
* x0i
- wk3i
* x0r
;
2757 x0r
= a
[j0
] + a
[j2
];
2758 x0i
= a
[j0
+ 1] + a
[j2
+ 1];
2759 x1r
= a
[j0
] - a
[j2
];
2760 x1i
= a
[j0
+ 1] - a
[j2
+ 1];
2761 x2r
= a
[j1
] + a
[j3
];
2762 x2i
= a
[j1
+ 1] + a
[j3
+ 1];
2763 x3r
= a
[j1
] - a
[j3
];
2764 x3i
= a
[j1
+ 1] - a
[j3
+ 1];
2766 a
[j0
+ 1] = x0i
+ x2i
;
2768 a
[j1
+ 1] = x0i
- x2i
;
2771 a
[j2
] = wk1i
* x0r
- wk1r
* x0i
;
2772 a
[j2
+ 1] = wk1i
* x0i
+ wk1r
* x0r
;
2775 a
[j3
] = wk3i
* x0r
+ wk3r
* x0i
;
2776 a
[j3
+ 1] = wk3i
* x0i
- wk3r
* x0r
;
2782 x0r
= a
[j0
] + a
[j2
];
2783 x0i
= a
[j0
+ 1] + a
[j2
+ 1];
2784 x1r
= a
[j0
] - a
[j2
];
2785 x1i
= a
[j0
+ 1] - a
[j2
+ 1];
2786 x2r
= a
[j1
] + a
[j3
];
2787 x2i
= a
[j1
+ 1] + a
[j3
+ 1];
2788 x3r
= a
[j1
] - a
[j3
];
2789 x3i
= a
[j1
+ 1] - a
[j3
+ 1];
2791 a
[j0
+ 1] = x0i
+ x2i
;
2793 a
[j1
+ 1] = x0i
- x2i
;
2796 a
[j2
] = wn4r
* (x0r
- x0i
);
2797 a
[j2
+ 1] = wn4r
* (x0i
+ x0r
);
2800 a
[j3
] = -wn4r
* (x0r
+ x0i
);
2801 a
[j3
+ 1] = -wn4r
* (x0i
- x0r
);
2805 void cftmdl2(int n
, REAL
*a
, REAL
*w
)
2807 int j
, j0
, j1
, j2
, j3
, k
, kr
, m
, mh
;
2808 //REAL wn4r, wk1r, wk1i, wk3r, wk3i, wd1r, wd1i, wd3r, wd3i;
2809 //REAL x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i, y0r, y0i, y2r, y2i;
2817 REAL x0r
= a
[0] - a
[j2
+ 1];
2818 REAL x0i
= a
[1] + a
[j2
];
2819 REAL x1r
= a
[0] + a
[j2
+ 1];
2820 REAL x1i
= a
[1] - a
[j2
];
2821 REAL x2r
= a
[j1
] - a
[j3
+ 1];
2822 REAL x2i
= a
[j1
+ 1] + a
[j3
];
2823 REAL x3r
= a
[j1
] + a
[j3
+ 1];
2824 REAL x3i
= a
[j1
+ 1] - a
[j3
];
2825 REAL y0r
= wn4r
* (x2r
- x2i
);
2826 REAL y0i
= wn4r
* (x2i
+ x2r
);
2830 a
[j1
+ 1] = x0i
- y0i
;
2831 y0r
= wn4r
* (x3r
- x3i
);
2832 y0i
= wn4r
* (x3i
+ x3r
);
2834 a
[j2
+ 1] = x1i
+ y0r
;
2836 a
[j3
+ 1] = x1i
- y0r
;
2839 for (j
= 2; j
< mh
; j
+= 2) {
2842 REAL wk1i
= w
[k
+ 1];
2843 REAL wk3r
= w
[k
+ 2];
2844 REAL wk3i
= w
[k
+ 3];
2847 REAL wd1r
= w
[kr
+ 1];
2848 REAL wd3i
= w
[kr
+ 2];
2849 REAL wd3r
= w
[kr
+ 3];
2853 x0r
= a
[j
] - a
[j2
+ 1];
2854 x0i
= a
[j
+ 1] + a
[j2
];
2855 x1r
= a
[j
] + a
[j2
+ 1];
2856 x1i
= a
[j
+ 1] - a
[j2
];
2857 x2r
= a
[j1
] - a
[j3
+ 1];
2858 x2i
= a
[j1
+ 1] + a
[j3
];
2859 x3r
= a
[j1
] + a
[j3
+ 1];
2860 x3i
= a
[j1
+ 1] - a
[j3
];
2861 y0r
= wk1r
* x0r
- wk1i
* x0i
;
2862 y0i
= wk1r
* x0i
+ wk1i
* x0r
;
2863 REAL y2r
= wd1r
* x2r
- wd1i
* x2i
;
2864 REAL y2i
= wd1r
* x2i
+ wd1i
* x2r
;
2866 a
[j
+ 1] = y0i
+ y2i
;
2868 a
[j1
+ 1] = y0i
- y2i
;
2869 y0r
= wk3r
* x1r
+ wk3i
* x1i
;
2870 y0i
= wk3r
* x1i
- wk3i
* x1r
;
2871 y2r
= wd3r
* x3r
+ wd3i
* x3i
;
2872 y2i
= wd3r
* x3i
- wd3i
* x3r
;
2874 a
[j2
+ 1] = y0i
+ y2i
;
2876 a
[j3
+ 1] = y0i
- y2i
;
2881 x0r
= a
[j0
] - a
[j2
+ 1];
2882 x0i
= a
[j0
+ 1] + a
[j2
];
2883 x1r
= a
[j0
] + a
[j2
+ 1];
2884 x1i
= a
[j0
+ 1] - a
[j2
];
2885 x2r
= a
[j1
] - a
[j3
+ 1];
2886 x2i
= a
[j1
+ 1] + a
[j3
];
2887 x3r
= a
[j1
] + a
[j3
+ 1];
2888 x3i
= a
[j1
+ 1] - a
[j3
];
2889 y0r
= wd1i
* x0r
- wd1r
* x0i
;
2890 y0i
= wd1i
* x0i
+ wd1r
* x0r
;
2891 y2r
= wk1i
* x2r
- wk1r
* x2i
;
2892 y2i
= wk1i
* x2i
+ wk1r
* x2r
;
2894 a
[j0
+ 1] = y0i
+ y2i
;
2896 a
[j1
+ 1] = y0i
- y2i
;
2897 y0r
= wd3i
* x1r
+ wd3r
* x1i
;
2898 y0i
= wd3i
* x1i
- wd3r
* x1r
;
2899 y2r
= wk3i
* x3r
+ wk3r
* x3i
;
2900 y2i
= wk3i
* x3i
- wk3r
* x3r
;
2902 a
[j2
+ 1] = y0i
+ y2i
;
2904 a
[j3
+ 1] = y0i
- y2i
;
2907 REAL wk1i
= w
[m
+ 1];
2912 x0r
= a
[j0
] - a
[j2
+ 1];
2913 x0i
= a
[j0
+ 1] + a
[j2
];
2914 x1r
= a
[j0
] + a
[j2
+ 1];
2915 x1i
= a
[j0
+ 1] - a
[j2
];
2916 x2r
= a
[j1
] - a
[j3
+ 1];
2917 x2i
= a
[j1
+ 1] + a
[j3
];
2918 x3r
= a
[j1
] + a
[j3
+ 1];
2919 x3i
= a
[j1
+ 1] - a
[j3
];
2920 y0r
= wk1r
* x0r
- wk1i
* x0i
;
2921 y0i
= wk1r
* x0i
+ wk1i
* x0r
;
2922 REAL y2r
= wk1i
* x2r
- wk1r
* x2i
;
2923 REAL y2i
= wk1i
* x2i
+ wk1r
* x2r
;
2925 a
[j0
+ 1] = y0i
+ y2i
;
2927 a
[j1
+ 1] = y0i
- y2i
;
2928 y0r
= wk1i
* x1r
- wk1r
* x1i
;
2929 y0i
= wk1i
* x1i
+ wk1r
* x1r
;
2930 y2r
= wk1r
* x3r
- wk1i
* x3i
;
2931 y2i
= wk1r
* x3i
+ wk1i
* x3r
;
2933 a
[j2
+ 1] = y0i
- y2i
;
2935 a
[j3
+ 1] = y0i
+ y2i
;
2939 void cftfx41(int n
, REAL
*a
, int nw
, REAL
*w
)
2942 cftf161(a
, &w
[nw
- 8]);
2943 cftf162(&a
[32], &w
[nw
- 32]);
2944 cftf161(&a
[64], &w
[nw
- 8]);
2945 cftf161(&a
[96], &w
[nw
- 8]);
2947 cftf081(a
, &w
[nw
- 8]);
2948 cftf082(&a
[16], &w
[nw
- 8]);
2949 cftf081(&a
[32], &w
[nw
- 8]);
2950 cftf081(&a
[48], &w
[nw
- 8]);
2955 void cftf161(REAL
*a
, REAL
*w
)
2958 REAL wn4r, wk1r, wk1i,
2959 x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i,
2960 y0r, y0i, y1r, y1i, y2r, y2i, y3r, y3i,
2961 y4r, y4i, y5r, y5i, y6r, y6i, y7r, y7i,
2962 y8r, y8i, y9r, y9i, y10r, y10i, y11r, y11i,
2963 y12r, y12i, y13r, y13i, y14r, y14i, y15r, y15i;
2968 REAL x0r
= a
[0] + a
[16];
2969 REAL x0i
= a
[1] + a
[17];
2970 REAL x1r
= a
[0] - a
[16];
2971 REAL x1i
= a
[1] - a
[17];
2972 REAL x2r
= a
[8] + a
[24];
2973 REAL x2i
= a
[9] + a
[25];
2974 REAL x3r
= a
[8] - a
[24];
2975 REAL x3i
= a
[9] - a
[25];
2976 REAL y0r
= x0r
+ x2r
;
2977 REAL y0i
= x0i
+ x2i
;
2978 REAL y4r
= x0r
- x2r
;
2979 REAL y4i
= x0i
- x2i
;
2980 REAL y8r
= x1r
- x3i
;
2981 REAL y8i
= x1i
+ x3r
;
2982 REAL y12r
= x1r
+ x3i
;
2983 REAL y12i
= x1i
- x3r
;
2988 x2r
= a
[10] + a
[26];
2989 x2i
= a
[11] + a
[27];
2990 x3r
= a
[10] - a
[26];
2991 x3i
= a
[11] - a
[27];
2992 REAL y1r
= x0r
+ x2r
;
2993 REAL y1i
= x0i
+ x2i
;
2994 REAL y5r
= x0r
- x2r
;
2995 REAL y5i
= x0i
- x2i
;
2998 REAL y9r
= wk1r
* x0r
- wk1i
* x0i
;
2999 REAL y9i
= wk1r
* x0i
+ wk1i
* x0r
;
3002 REAL y13r
= wk1i
* x0r
- wk1r
* x0i
;
3003 REAL y13i
= wk1i
* x0i
+ wk1r
* x0r
;
3008 x2r
= a
[12] + a
[28];
3009 x2i
= a
[13] + a
[29];
3010 x3r
= a
[12] - a
[28];
3011 x3i
= a
[13] - a
[29];
3012 REAL y2r
= x0r
+ x2r
;
3013 REAL y2i
= x0i
+ x2i
;
3014 REAL y6r
= x0r
- x2r
;
3015 REAL y6i
= x0i
- x2i
;
3018 REAL y10r
= wn4r
* (x0r
- x0i
);
3019 REAL y10i
= wn4r
* (x0i
+ x0r
);
3022 REAL y14r
= wn4r
* (x0r
+ x0i
);
3023 REAL y14i
= wn4r
* (x0i
- x0r
);
3028 x2r
= a
[14] + a
[30];
3029 x2i
= a
[15] + a
[31];
3030 x3r
= a
[14] - a
[30];
3031 x3i
= a
[15] - a
[31];
3032 REAL y3r
= x0r
+ x2r
;
3033 REAL y3i
= x0i
+ x2i
;
3034 REAL y7r
= x0r
- x2r
;
3035 REAL y7i
= x0i
- x2i
;
3038 REAL y11r
= wk1i
* x0r
- wk1r
* x0i
;
3039 REAL y11i
= wk1i
* x0i
+ wk1r
* x0r
;
3042 REAL y15r
= wk1r
* x0r
- wk1i
* x0i
;
3043 REAL y15i
= wk1r
* x0i
+ wk1i
* x0r
;
3078 x2r
= wn4r
* (x0r
- x0i
);
3079 x2i
= wn4r
* (x0i
+ x0r
);
3082 x3r
= wn4r
* (x0r
- x0i
);
3083 x3i
= wn4r
* (x0i
+ x0r
);
3115 void cftf162(REAL
*a
, REAL
*w
)
3118 REAL wn4r, wk1r, wk1i, wk2r, wk2i, wk3r, wk3i,
3119 x0r, x0i, x1r, x1i, x2r, x2i,
3120 y0r, y0i, y1r, y1i, y2r, y2i, y3r, y3i,
3121 y4r, y4i, y5r, y5i, y6r, y6i, y7r, y7i,
3122 y8r, y8i, y9r, y9i, y10r, y10i, y11r, y11i,
3123 y12r, y12i, y13r, y13i, y14r, y14i, y15r, y15i;
3132 REAL x1r
= a
[0] - a
[17];
3133 REAL x1i
= a
[1] + a
[16];
3134 REAL x0r
= a
[8] - a
[25];
3135 REAL x0i
= a
[9] + a
[24];
3136 REAL x2r
= wn4r
* (x0r
- x0i
);
3137 REAL x2i
= wn4r
* (x0i
+ x0r
);
3138 REAL y0r
= x1r
+ x2r
;
3139 REAL y0i
= x1i
+ x2i
;
3140 REAL y4r
= x1r
- x2r
;
3141 REAL y4i
= x1i
- x2i
;
3146 x2r
= wn4r
* (x0r
- x0i
);
3147 x2i
= wn4r
* (x0i
+ x0r
);
3148 REAL y8r
= x1r
- x2i
;
3149 REAL y8i
= x1i
+ x2r
;
3150 REAL y12r
= x1r
+ x2i
;
3151 REAL y12i
= x1i
- x2r
;
3154 x1r
= wk1r
* x0r
- wk1i
* x0i
;
3155 x1i
= wk1r
* x0i
+ wk1i
* x0r
;
3156 x0r
= a
[10] - a
[27];
3157 x0i
= a
[11] + a
[26];
3158 x2r
= wk3i
* x0r
- wk3r
* x0i
;
3159 x2i
= wk3i
* x0i
+ wk3r
* x0r
;
3160 REAL y1r
= x1r
+ x2r
;
3161 REAL y1i
= x1i
+ x2i
;
3162 REAL y5r
= x1r
- x2r
;
3163 REAL y5i
= x1i
- x2i
;
3166 x1r
= wk3r
* x0r
- wk3i
* x0i
;
3167 x1i
= wk3r
* x0i
+ wk3i
* x0r
;
3168 x0r
= a
[10] + a
[27];
3169 x0i
= a
[11] - a
[26];
3170 x2r
= wk1r
* x0r
+ wk1i
* x0i
;
3171 x2i
= wk1r
* x0i
- wk1i
* x0r
;
3172 REAL y9r
= x1r
- x2r
;
3173 REAL y9i
= x1i
- x2i
;
3174 REAL y13r
= x1r
+ x2r
;
3175 REAL y13i
= x1i
+ x2i
;
3178 x1r
= wk2r
* x0r
- wk2i
* x0i
;
3179 x1i
= wk2r
* x0i
+ wk2i
* x0r
;
3180 x0r
= a
[12] - a
[29];
3181 x0i
= a
[13] + a
[28];
3182 x2r
= wk2i
* x0r
- wk2r
* x0i
;
3183 x2i
= wk2i
* x0i
+ wk2r
* x0r
;
3184 REAL y2r
= x1r
+ x2r
;
3185 REAL y2i
= x1i
+ x2i
;
3186 REAL y6r
= x1r
- x2r
;
3187 REAL y6i
= x1i
- x2i
;
3190 x1r
= wk2i
* x0r
- wk2r
* x0i
;
3191 x1i
= wk2i
* x0i
+ wk2r
* x0r
;
3192 x0r
= a
[12] + a
[29];
3193 x0i
= a
[13] - a
[28];
3194 x2r
= wk2r
* x0r
- wk2i
* x0i
;
3195 x2i
= wk2r
* x0i
+ wk2i
* x0r
;
3196 REAL y10r
= x1r
- x2r
;
3197 REAL y10i
= x1i
- x2i
;
3198 REAL y14r
= x1r
+ x2r
;
3199 REAL y14i
= x1i
+ x2i
;
3202 x1r
= wk3r
* x0r
- wk3i
* x0i
;
3203 x1i
= wk3r
* x0i
+ wk3i
* x0r
;
3204 x0r
= a
[14] - a
[31];
3205 x0i
= a
[15] + a
[30];
3206 x2r
= wk1i
* x0r
- wk1r
* x0i
;
3207 x2i
= wk1i
* x0i
+ wk1r
* x0r
;
3208 REAL y3r
= x1r
+ x2r
;
3209 REAL y3i
= x1i
+ x2i
;
3210 REAL y7r
= x1r
- x2r
;
3211 REAL y7i
= x1i
- x2i
;
3214 x1r
= wk1i
* x0r
+ wk1r
* x0i
;
3215 x1i
= wk1i
* x0i
- wk1r
* x0r
;
3216 x0r
= a
[14] + a
[31];
3217 x0i
= a
[15] - a
[30];
3218 x2r
= wk3i
* x0r
- wk3r
* x0i
;
3219 x2i
= wk3i
* x0i
+ wk3r
* x0r
;
3220 REAL y11r
= x1r
+ x2r
;
3221 REAL y11i
= x1i
+ x2i
;
3222 REAL y15r
= x1r
- x2r
;
3223 REAL y15i
= x1i
- x2i
;
3244 x2r
= wn4r
* (x0r
- x0i
);
3245 x2i
= wn4r
* (x0i
+ x0r
);
3254 x2r
= wn4r
* (x0r
- x0i
);
3255 x2i
= wn4r
* (x0i
+ x0r
);
3280 x2r
= wn4r
* (x0r
- x0i
);
3281 x2i
= wn4r
* (x0i
+ x0r
);
3290 x2r
= wn4r
* (x0r
- x0i
);
3291 x2i
= wn4r
* (x0i
+ x0r
);
3299 void cftf081(REAL
*a
, REAL
*w
)
3302 REAL wn4r, x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i,
3303 y0r, y0i, y1r, y1i, y2r, y2i, y3r, y3i,
3304 y4r, y4i, y5r, y5i, y6r, y6i, y7r, y7i;
3307 REAL x0r
= a
[0] + a
[8];
3308 REAL x0i
= a
[1] + a
[9];
3309 REAL x1r
= a
[0] - a
[8];
3310 REAL x1i
= a
[1] - a
[9];
3311 REAL x2r
= a
[4] + a
[12];
3312 REAL x2i
= a
[5] + a
[13];
3313 REAL x3r
= a
[4] - a
[12];
3314 REAL x3i
= a
[5] - a
[13];
3315 REAL y0r
= x0r
+ x2r
;
3316 REAL y0i
= x0i
+ x2i
;
3317 REAL y2r
= x0r
- x2r
;
3318 REAL y2i
= x0i
- x2i
;
3319 REAL y1r
= x1r
- x3i
;
3320 REAL y1i
= x1i
+ x3r
;
3321 REAL y3r
= x1r
+ x3i
;
3322 REAL y3i
= x1i
- x3r
;
3331 REAL y4r
= x0r
+ x2r
;
3332 REAL y4i
= x0i
+ x2i
;
3333 REAL y6r
= x0r
- x2r
;
3334 REAL y6i
= x0i
- x2i
;
3339 REAL y5r
= wn4r
* (x0r
- x0i
);
3340 REAL y5i
= wn4r
* (x0r
+ x0i
);
3341 REAL y7r
= wn4r
* (x2r
- x2i
);
3342 REAL y7i
= wn4r
* (x2r
+ x2i
);
3362 void cftf082(REAL
*a
, REAL
*w
)
3365 REAL wn4r, wk1r, wk1i, x0r, x0i, x1r, x1i,
3366 y0r, y0i, y1r, y1i, y2r, y2i, y3r, y3i,
3367 y4r, y4i, y5r, y5i, y6r, y6i, y7r, y7i;
3372 REAL y0r
= a
[0] - a
[9];
3373 REAL y0i
= a
[1] + a
[8];
3374 REAL y1r
= a
[0] + a
[9];
3375 REAL y1i
= a
[1] - a
[8];
3376 REAL x0r
= a
[4] - a
[13];
3377 REAL x0i
= a
[5] + a
[12];
3378 REAL y2r
= wn4r
* (x0r
- x0i
);
3379 REAL y2i
= wn4r
* (x0i
+ x0r
);
3382 REAL y3r
= wn4r
* (x0r
- x0i
);
3383 REAL y3i
= wn4r
* (x0i
+ x0r
);
3386 REAL y4r
= wk1r
* x0r
- wk1i
* x0i
;
3387 REAL y4i
= wk1r
* x0i
+ wk1i
* x0r
;
3390 REAL y5r
= wk1i
* x0r
- wk1r
* x0i
;
3391 REAL y5i
= wk1i
* x0i
+ wk1r
* x0r
;
3394 REAL y6r
= wk1i
* x0r
- wk1r
* x0i
;
3395 REAL y6i
= wk1i
* x0i
+ wk1r
* x0r
;
3398 REAL y7r
= wk1r
* x0r
- wk1i
* x0i
;
3399 REAL y7i
= wk1r
* x0i
+ wk1i
* x0r
;
3402 REAL x1r
= y4r
+ y6r
;
3403 REAL x1i
= y4i
+ y6i
;
3435 void cftf040(REAL
*a
)
3437 //REAL x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i;
3439 immutable REAL x0r
= a
[0] + a
[4];
3440 immutable REAL x0i
= a
[1] + a
[5];
3441 immutable REAL x1r
= a
[0] - a
[4];
3442 immutable REAL x1i
= a
[1] - a
[5];
3443 immutable REAL x2r
= a
[2] + a
[6];
3444 immutable REAL x2i
= a
[3] + a
[7];
3445 immutable REAL x3r
= a
[2] - a
[6];
3446 immutable REAL x3i
= a
[3] - a
[7];
3458 void cftb040(REAL
*a
)
3460 //REAL x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i;
3462 immutable REAL x0r
= a
[0] + a
[4];
3463 immutable REAL x0i
= a
[1] + a
[5];
3464 immutable REAL x1r
= a
[0] - a
[4];
3465 immutable REAL x1i
= a
[1] - a
[5];
3466 immutable REAL x2r
= a
[2] + a
[6];
3467 immutable REAL x2i
= a
[3] + a
[7];
3468 immutable REAL x3r
= a
[2] - a
[6];
3469 immutable REAL x3i
= a
[3] - a
[7];
3481 void cftx020(REAL
*a
)
3485 immutable REAL x0r
= a
[0] - a
[2];
3486 immutable REAL x0i
= a
[1] - a
[3];
3494 void rftfsub(int n
, REAL
*a
, int nc
, REAL
*c
)
3496 int j
, k
, kk
, ks
, m
;
3497 //REAL wkr, wki, xr, xi, yr, yi;
3502 for (j
= 2; j
< m
; j
+= 2) {
3505 REAL wkr
= 0.5 - c
[nc
- kk
];
3507 REAL xr
= a
[j
] - a
[k
];
3508 REAL xi
= a
[j
+ 1] + a
[k
+ 1];
3509 REAL yr
= wkr
* xr
- wki
* xi
;
3510 REAL yi
= wkr
* xi
+ wki
* xr
;
3519 void rftbsub(int n
, REAL
*a
, int nc
, REAL
*c
)
3521 int j
, k
, kk
, ks
, m
;
3522 //REAL wkr, wki, xr, xi, yr, yi;
3527 for (j
= 2; j
< m
; j
+= 2) {
3530 REAL wkr
= 0.5 - c
[nc
- kk
];
3532 REAL xr
= a
[j
] - a
[k
];
3533 REAL xi
= a
[j
+ 1] + a
[k
+ 1];
3534 REAL yr
= wkr
* xr
+ wki
* xi
;
3535 REAL yi
= wkr
* xi
- wki
* xr
;
3544 void dctsub(int n
, REAL
*a
, int nc
, REAL
*c
)
3546 int j
, k
, kk
, ks
, m
;
3547 //REAL wkr, wki, xr;
3552 for (j
= 1; j
< m
; j
++) {
3555 REAL wkr
= c
[kk
] - c
[nc
- kk
];
3556 REAL wki
= c
[kk
] + c
[nc
- kk
];
3557 REAL xr
= wki
* a
[j
] - wkr
* a
[k
];
3558 a
[j
] = wkr
* a
[j
] + wki
* a
[k
];
3565 void dstsub(int n
, REAL
*a
, int nc
, REAL
*c
)
3567 int j
, k
, kk
, ks
, m
;
3568 //REAL wkr, wki, xr;
3573 for (j
= 1; j
< m
; j
++) {
3576 REAL wkr
= c
[kk
] - c
[nc
- kk
];
3577 REAL wki
= c
[kk
] + c
[nc
- kk
];
3578 REAL xr
= wki
* a
[k
] - wkr
* a
[j
];
3579 a
[k
] = wkr
* a
[k
] + wki
* a
[j
];