void rdft(int n, int isgn, double *a) { void bitrv2(int n, double *a); void cftfsub(int n, double *a); void cftbsub(int n, double *a); void rftfsub(int n, double *a); void rftbsub(int n, double *a); double xi; if (isgn >= 0) { if (n > 4) { bitrv2(n, a); cftfsub(n, a); rftfsub(n, a); } else if (n == 4) { cftfsub(n, a); } xi = a[0] - a[1]; a[0] += a[1]; a[1] = xi; } else { a[1] = 0.5 * (a[0] - a[1]); a[0] -= a[1]; if (n > 4) { rftbsub(n, a); bitrv2(n, a); cftbsub(n, a); } else if (n == 4) { cftfsub(n, a); } } }
void rdft(int n, int isgn, float *a, int *ip, float *w) { int j, nw, nc; float xi; void bitrv2(int n, int *ip, float *a), cftsub(int n, float *a, float *w), rftsub(int n, float *a, int nc, float *c); nw = ip[0]; nc = ip[1]; if (isgn < 0) { a[1] = 0.5 * (a[1] - a[0]); a[0] += a[1]; for (j = 3; j <= n - 1; j += 2) { a[j] = -a[j]; } if (n > 4) { rftsub(n, a, nc, w + nw); bitrv2(n, ip + 2, a); } cftsub(n, a, w); for (j = 1; j <= n - 1; j += 2) { a[j] = -a[j]; } } else { if (n > 4) { bitrv2(n, ip + 2, a); } cftsub(n, a, w); if (n > 4) { rftsub(n, a, nc, w + nw); } xi = a[0] - a[1]; a[0] += a[1]; a[1] = xi; } }
void ddst(int n, int isgn, double *a) { void bitrv2(int n, double *a); void cftfsub(int n, double *a); void cftbsub(int n, double *a); void rftfsub(int n, double *a); void rftbsub(int n, double *a); void dstsub(int n, double *a); void dstsub4(int n, double *a); int j; double xr; if (isgn < 0) { xr = a[n - 1]; for (j = n - 2; j >= 2; j -= 2) { a[j + 1] = -a[j] - a[j - 1]; a[j] -= a[j - 1]; } a[1] = a[0] + xr; a[0] -= xr; if (n > 4) { rftbsub(n, a); bitrv2(n, a); cftbsub(n, a); } else if (n == 4) { cftfsub(n, a); } } if (n > 4) { dstsub(n, a); } else { dstsub4(n, a); } if (isgn >= 0) { if (n > 4) { bitrv2(n, a); cftfsub(n, a); rftfsub(n, a); } else if (n == 4) { cftfsub(n, a); } xr = a[0] - a[1]; a[0] += a[1]; for (j = 2; j < n; j += 2) { a[j - 1] = -a[j] - a[j + 1]; a[j] -= a[j + 1]; } a[n - 1] = -xr; } }
void makewt(int nw, int *ip, float *w) { void bitrv2(int n, int *ip, float *a); int nwh, j; float delta, x, y; ip[0] = nw; ip[1] = 1; if (nw > 2) { nwh = nw >> 1; delta = atan(1.0) / nwh; w[0] = 1; w[1] = 0; w[nwh] = cos(delta * nwh); w[nwh + 1] = w[nwh]; for (j = 2; j <= nwh - 2; j += 2) { x = cos(delta * j); y = sin(delta * j); w[j] = x; w[j + 1] = y; w[nw - j] = y; w[nw - j + 1] = x; } bitrv2(nw, ip + 2, w); }
static void makewt(int nw, int *ip, double *w) { int j, nwh; double delta, x, y; if (nw > 2) { nwh = nw >> 1; delta = M_PI_4 / nwh; w[0] = 1; w[1] = 0; w[nwh] = cos(delta * nwh); w[nwh + 1] = w[nwh]; if (nwh > 2) { for (j = 2; j < nwh; j += 2) { x = cos(delta * j); y = sin(delta * j); w[j] = x; w[j + 1] = y; w[nw - j] = y; w[nw - j + 1] = x; } //makebr(nw, ip); bitrv2(nw, ip, w); } }
inline void makewt(int nw, int *ip, double *w) { int j, nwh; double delta, x, y; ip[0] = nw; ip[1] = 1; if (nw > 2) { nwh = nw >> 1; delta = atan(1.0) / nwh; w[0] = 1; w[1] = 0; w[nwh] = cos(delta * nwh); w[nwh + 1] = w[nwh]; if (nwh > 2) { for (j = 2; j < nwh; j += 2) { x = cos(delta * j); y = sin(delta * j); w[j] = x; w[j + 1] = y; w[nw - j] = y; w[nw - j + 1] = x; } bitrv2(nw, ip + 2, w); } }
void lsx_rdft_generic(int isgn, double *a, FFTcontext z) { double xi; int n = z.n; int nw = n >> 2; if (isgn >= 0) { if (n > 4) { bitrv2(n, z.br, a); cftfsub(n, a, z.sc); rftfsub(n, a, nw, z.sc + nw); } else if (n == 4) { cftfsub(n, a, z.sc); } xi = a[0] - a[1]; a[0] += a[1]; a[1] = xi; } else { a[1] = 0.5 * (a[0] - a[1]); a[0] -= a[1]; if (n > 4) { rftbsub(n, a, nw, z.sc + nw); bitrv2(n, z.br, a); cftbsub(n, a, z.sc); } else if (n == 4) { cftfsub(n, a, z.sc); } } }
void cdft(int n, int isgn, double *a) { void bitrv2(int n, double *a); void bitrv2conj(int n, double *a); void cftfsub(int n, double *a); void cftbsub(int n, double *a); if (n > 4) { if (isgn >= 0) { bitrv2(n, a); cftfsub(n, a); } else { bitrv2conj(n, a); cftbsub(n, a); } } else if (n == 4) { cftfsub(n, a); } }