summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnthony Blake <anthonix@me.com>2012-10-31 15:33:50 +1300
committerAnthony Blake <anthonix@me.com>2012-10-31 15:33:50 +1300
commitcdd3a3a385f9539e85dec17bd84ec81ab8eb7e21 (patch)
tree7863af09bb37bb0931a80b49736da035c96f3b83
parent20fb90955801191a4531cd4b767740299ab6911e (diff)
downloadffts-cdd3a3a385f9539e85dec17bd84ec81ab8eb7e21.zip
ffts-cdd3a3a385f9539e85dec17bd84ec81ab8eb7e21.tar.gz
Modified API to make way for multi-dimensional transforms
-rw-r--r--include/ffts.h25
-rw-r--r--src/ffts.c2
-rw-r--r--src/ffts.h17
-rw-r--r--tests/test.c10
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
diff --git a/src/ffts.c b/src/ffts.c
index 5e88ec3..036de84 100644
--- a/src/ffts.c
+++ b/src/ffts.c
@@ -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;
diff --git a/src/ffts.h b/src/ffts.h
index ad7d41d..84a0434 100644
--- a/src/ffts.h
+++ b/src/ffts.h
@@ -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);
OpenPOWER on IntegriCloud