|
|
@ -36,40 +36,44 @@
|
|
|
|
#define div(a,b) ((a-1)/b+1)
|
|
|
|
#define div(a,b) ((a-1)/b+1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int dft_plan_multi(const int *dft_points, dft_mode_t *modes, dft_dir_t *dirs,
|
|
|
|
int dft_plan_vector(dft_plan_t *plans, const int *dft_points,
|
|
|
|
int nof_plans, dft_plan_t *plans) {
|
|
|
|
dft_mode_t *modes, dft_dir_t *dirs, int nof_plans) {
|
|
|
|
int i;
|
|
|
|
int i;
|
|
|
|
for (i=0;i<nof_plans;i++) {
|
|
|
|
for (i=0;i<nof_plans;i++) {
|
|
|
|
if (dft_plan(dft_points[i],modes[i],dirs[i], &plans[i])) {
|
|
|
|
if (dft_plan(&plans[i], dft_points[i],modes[i],dirs[i])) {
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int dft_plan_multi_c2c(const int *dft_points, dft_dir_t dir, int nof_plans, dft_plan_t *plans) {
|
|
|
|
int dft_plan_multi_c2c(dft_plan_t *plans, const int *dft_points,
|
|
|
|
|
|
|
|
dft_dir_t dir, int nof_plans) {
|
|
|
|
int i;
|
|
|
|
int i;
|
|
|
|
for (i=0;i<nof_plans;i++) {
|
|
|
|
for (i=0;i<nof_plans;i++) {
|
|
|
|
if (dft_plan(dft_points[i],COMPLEX_2_COMPLEX,dir,&plans[i])) {
|
|
|
|
if (dft_plan(&plans[i],dft_points[i],COMPLEX_2_COMPLEX,dir)) {
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int dft_plan_multi_c2r(const int *dft_points, dft_dir_t dir, int nof_plans, dft_plan_t *plans) {
|
|
|
|
int dft_plan_multi_c2r(dft_plan_t *plans, const int *dft_points,
|
|
|
|
|
|
|
|
dft_dir_t dir, int nof_plans) {
|
|
|
|
int i;
|
|
|
|
int i;
|
|
|
|
for (i=0;i<nof_plans;i++) {
|
|
|
|
for (i=0;i<nof_plans;i++) {
|
|
|
|
if (dft_plan(dft_points[i],COMPLEX_2_REAL,dir,&plans[i])) {
|
|
|
|
if (dft_plan(&plans[i], dft_points[i],COMPLEX_2_REAL,dir)) {
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
int dft_plan_multi_r2r(const int *dft_points, dft_dir_t dir, int nof_plans, dft_plan_t *plans) {
|
|
|
|
|
|
|
|
|
|
|
|
int dft_plan_multi_r2r(dft_plan_t *plans, const int *dft_points,
|
|
|
|
|
|
|
|
dft_dir_t dir, int nof_plans) {
|
|
|
|
int i;
|
|
|
|
int i;
|
|
|
|
for (i=0;i<nof_plans;i++) {
|
|
|
|
for (i=0;i<nof_plans;i++) {
|
|
|
|
if (dft_plan(dft_points[i],REAL_2_REAL,dir,&plans[i])) {
|
|
|
|
if (dft_plan(&plans[i], dft_points[i],REAL_2_REAL,dir)) {
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -77,21 +81,22 @@ int dft_plan_multi_r2r(const int *dft_points, dft_dir_t dir, int nof_plans, dft_
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int dft_plan(const int dft_points, dft_mode_t mode, dft_dir_t dir, dft_plan_t *plan) {
|
|
|
|
int dft_plan(dft_plan_t *plan, const int dft_points,
|
|
|
|
|
|
|
|
dft_mode_t mode, dft_dir_t dir) {
|
|
|
|
|
|
|
|
|
|
|
|
switch(mode) {
|
|
|
|
switch(mode) {
|
|
|
|
case COMPLEX_2_COMPLEX:
|
|
|
|
case COMPLEX_2_COMPLEX:
|
|
|
|
if (dft_plan_c2c(dft_points,dir,plan)) {
|
|
|
|
if (dft_plan_c2c(plan,dft_points,dir)) {
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case REAL_2_REAL:
|
|
|
|
case REAL_2_REAL:
|
|
|
|
if (dft_plan_r2r(dft_points,dir,plan)) {
|
|
|
|
if (dft_plan_r2r(plan,dft_points,dir)) {
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case COMPLEX_2_REAL:
|
|
|
|
case COMPLEX_2_REAL:
|
|
|
|
if (dft_plan_c2r(dft_points,dir,plan)) {
|
|
|
|
if (dft_plan_c2r(plan,dft_points,dir)) {
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -104,7 +109,7 @@ static void allocate(dft_plan_t *plan, int size_in, int size_out, int len) {
|
|
|
|
plan->out = fftwf_malloc(size_out*len);
|
|
|
|
plan->out = fftwf_malloc(size_out*len);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int dft_plan_c2c(const int dft_points, dft_dir_t dir, dft_plan_t *plan) {
|
|
|
|
int dft_plan_c2c(dft_plan_t *plan, const int dft_points, dft_dir_t dir) {
|
|
|
|
int sign;
|
|
|
|
int sign;
|
|
|
|
sign = (dir == FORWARD) ? FFTW_FORWARD : FFTW_BACKWARD;
|
|
|
|
sign = (dir == FORWARD) ? FFTW_FORWARD : FFTW_BACKWARD;
|
|
|
|
allocate(plan,sizeof(fftwf_complex),sizeof(fftwf_complex), dft_points);
|
|
|
|
allocate(plan,sizeof(fftwf_complex),sizeof(fftwf_complex), dft_points);
|
|
|
@ -120,7 +125,7 @@ int dft_plan_c2c(const int dft_points, dft_dir_t dir, dft_plan_t *plan) {
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int dft_plan_r2r(const int dft_points, dft_dir_t dir, dft_plan_t *plan) {
|
|
|
|
int dft_plan_r2r(dft_plan_t *plan, const int dft_points, dft_dir_t dir) {
|
|
|
|
int sign;
|
|
|
|
int sign;
|
|
|
|
sign = (dir == FORWARD) ? FFTW_R2HC : FFTW_HC2R;
|
|
|
|
sign = (dir == FORWARD) ? FFTW_R2HC : FFTW_HC2R;
|
|
|
|
|
|
|
|
|
|
|
@ -137,8 +142,8 @@ int dft_plan_r2r(const int dft_points, dft_dir_t dir, dft_plan_t *plan) {
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int dft_plan_c2r(const int dft_points, dft_dir_t dir, dft_plan_t *plan) {
|
|
|
|
int dft_plan_c2r(dft_plan_t *plan, const int dft_points, dft_dir_t dir) {
|
|
|
|
if (dft_plan_c2c(dft_points, dir, plan)) {
|
|
|
|
if (dft_plan_c2c(plan, dft_points, dir)) {
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
plan->mode = COMPLEX_2_REAL;
|
|
|
|
plan->mode = COMPLEX_2_REAL;
|
|
|
|