diff options
author | Anthony Blake <anthonix@me.com> | 2012-11-15 18:22:31 +1300 |
---|---|---|
committer | Anthony Blake <anthonix@me.com> | 2012-11-15 18:22:31 +1300 |
commit | 124e309c63654f43f8daa7121d776b256c97b3bc (patch) | |
tree | 1aa6b46ed22bcc294c9e08312d6d132e25636294 /src/ffts_real.c | |
parent | 02e3467b75a6e205c6bd2e82d3a1c8daa3c81f6f (diff) | |
download | ffts-124e309c63654f43f8daa7121d776b256c97b3bc.zip ffts-124e309c63654f43f8daa7121d776b256c97b3bc.tar.gz |
Fixed inverse real-valued transform
Diffstat (limited to 'src/ffts_real.c')
-rw-r--r-- | src/ffts_real.c | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/ffts_real.c b/src/ffts_real.c index 8d29757..9d5bf84 100644 --- a/src/ffts_real.c +++ b/src/ffts_real.c @@ -104,6 +104,10 @@ void ffts_execute_1d_real(ffts_plan_t *p, const void *vin, void *vout) { for(i=0;i<N/2;i++) { out[2*i] = buf[2*i]*A[2*i] - buf[2*i+1]*A[2*i+1] + buf[N-2*i]*B[2*i] + buf[N-2*i+1]*B[2*i+1]; out[2*i+1] = buf[2*i+1]*A[2*i] + buf[2*i]*A[2*i+1] + buf[N-2*i]*B[2*i+1] - buf[N-2*i+1]*B[2*i]; + +// out[2*N-2*i] = out[2*i]; +// out[2*N-2*i+1] = -out[2*i+1]; + #endif } @@ -122,6 +126,7 @@ void ffts_execute_1d_real_inv(ffts_plan_t *p, const void *vin, void *vout) { float *p_buf0 = in; float *p_buf1 = in + N - 2; + float *p_out = buf; size_t i; @@ -197,13 +202,23 @@ ffts_plan_t *ffts_init_1d_real(size_t N, int sign) { p->A = valloc(sizeof(float) * N); p->B = valloc(sizeof(float) * N); - int i; - for (i = 0; i < N/2; i++) { - p->A[2 * i] = 0.5 * (1.0 - sin (2 * PI / (double) N * (double) i)); - p->A[2 * i + 1] = 0.5 * (-1.0 * cos (2 * PI / (double) N * (double) i)); - p->B[2 * i] = 0.5 * (1.0 + sin (2 * PI / (double) N * (double) i)); - p->B[2 * i + 1] = 0.5 * (1.0 * cos (2 * PI / (double) N * (double) i)); - } + if(sign < 0) { + int i; + for (i = 0; i < N/2; i++) { + p->A[2 * i] = 0.5 * (1.0 - sin (2.0f * PI / (double) (N) * (double) i)); + p->A[2 * i + 1] = 0.5 * (-1.0 * cos (2.0f * PI / (double) (N) * (double) i)); + p->B[2 * i] = 0.5 * (1.0 + sin (2.0f * PI / (double) (N) * (double) i)); + p->B[2 * i + 1] = 0.5 * (1.0 * cos (2.0f * PI / (double) (N) * (double) i)); + } + }else{ + int i; + for (i = 0; i < N/2; i++) { + p->A[2 * i] = 1.0 * (1.0 - sin (2.0f * PI / (double) (N) * (double) i)); + p->A[2 * i + 1] = 1.0 * (-1.0 * cos (2.0f * PI / (double) (N) * (double) i)); + p->B[2 * i] = 1.0 * (1.0 + sin (2.0f * PI / (double) (N) * (double) i)); + p->B[2 * i + 1] = 1.0 * (1.0 * cos (2.0f * PI / (double) (N) * (double) i)); + } + } return p; } |