diff options
-rw-r--r-- | include/ffts.h | 25 | ||||
-rw-r--r-- | src/ffts.c | 2 | ||||
-rw-r--r-- | src/ffts.h | 17 | ||||
-rw-r--r-- | tests/test.c | 10 |
4 files changed, 18 insertions, 36 deletions
diff --git a/include/ffts.h b/include/ffts.h index 75392eb..f2194dc 100644 --- a/include/ffts.h +++ b/include/ffts.h @@ -43,31 +43,14 @@ extern "C" { #endif /* __cplusplus */ -/* -typedef size_t transform_index_t; -struct _ffts_plan_t { - ptrdiff_t *offsets; - void __attribute__ ((aligned(32))) *ws; - void __attribute__ ((aligned(32))) *oe_ws, *eo_ws, *ee_ws; - ptrdiff_t *is; - size_t *ws_is; - size_t i0, i1, n_luts; - size_t N; - void *lastlut; - transform_index_t *transforms; - //transform_func_t transform; - void (*transform)(struct _ffts_plan_t * , const float * , float * ); - void *transform_base; - size_t transform_size; - void *constants; -}; -*/ - struct _ffts_plan_t; typedef struct _ffts_plan_t ffts_plan_t; +ffts_plan_t *ffts_init_1d(size_t N, int sign); +ffts_plan_t *ffts_init_2d(size_t N1, size_t N2, int sign); +ffts_plan_t *ffts_init_nd(int rank, size_t *Ns, int sign); + void ffts_execute(ffts_plan_t * , const void * , const void * ); -ffts_plan_t *ffts_init(size_t N, int sign); void ffts_free(ffts_plan_t *); #ifdef __cplusplus @@ -74,7 +74,7 @@ void ffts_free(ffts_plan_t *p) { free(p); } -ffts_plan_t *ffts_init(size_t N, int sign) { +ffts_plan_t *ffts_init_1d(size_t N, int sign) { ffts_plan_t *p = malloc(sizeof(ffts_plan_t)); size_t leafN = 8; size_t i; @@ -50,14 +50,8 @@ static const __attribute__ ((aligned(64))) float w_data[16] = {0.707106781186547 0.70710678118654757273731092936941,0.70710678118654746171500846685376, 0.70710678118654757273731092936941,0.70710678118654746171500846685376, 1.0f,0.70710678118654757273731092936941f, 0.0f,0.70710678118654746171500846685376}; -inline float W_re(float N, float k) { - return cos(-2.0f * PI * k / N); -} - -inline float W_im(float N, float k) { - return sin(-2.0f * PI * k / N); -} - +inline float W_re(float N, float k) { return cos(-2.0f * PI * k / N); } +inline float W_im(float N, float k) { return sin(-2.0f * PI * k / N); } typedef size_t transform_index_t; @@ -75,10 +69,15 @@ struct _ffts_plan_t { void *lastlut; transform_index_t *transforms; //transform_func_t transform; - void (*transform)(struct _ffts_plan_t * restrict, const float * restrict, float * restrict); + void (*transform)(struct _ffts_plan_t * , const float * , float * ); void *transform_base; size_t transform_size; void *constants; + + // multi-dimensional stuff: + struct _ffts_plan_t *plans; + int rank; + size_t *Ns; }; typedef struct _ffts_plan_t ffts_plan_t; diff --git a/tests/test.c b/tests/test.c index deb1fbc..326e7e2 100644 --- a/tests/test.c +++ b/tests/test.c @@ -88,10 +88,10 @@ test_transform(int n, int sign) { input[2] = 1.0f; - ffts_plan_t *p = ffts_init(i, sign); + ffts_plan_t *p = ffts_init_1d(i, sign); if(p) { ffts_execute(p, input, output); - printf("%5d | %9d | %10E\n", sign, n, impulse_error(n, sign, output)); + printf(" %3d | %9d | %10E\n", sign, n, impulse_error(n, sign, output)); ffts_free(p); }else{ printf("Plan unsupported\n"); @@ -124,7 +124,7 @@ main(int argc, char *argv[]) { // input[2] = 1.0f; - ffts_plan_t *p = ffts_init(i, sign); + ffts_plan_t *p = ffts_init_1d(i, sign); if(p) { ffts_execute(p, input, output); for(i=0;i<n;i++) printf("%d %d %f %f\n", i, sign, output[2*i], output[2*i+1]); @@ -144,8 +144,8 @@ main(int argc, char *argv[]) { }else{ // test various sizes and display error - printf("Direction | Size | L2 Error\n"); - printf("----------+-----------+-------------\n"); + printf(" Sign | Size | L2 Error\n"); + printf("------+-----------+-------------\n"); int n; for(n=1;n<=18;n++) { test_transform(pow(2,n), -1); |