Cleanup of dft interface

master
Paul Sutton 11 years ago
parent 27ef1a58bc
commit c762cd6f0f

@ -72,24 +72,25 @@ typedef float dft_r_t;
/* Create DFT plans */
LIBLTE_API int dft_plan(const int dft_points, dft_mode_t mode, dft_dir_t dir, dft_plan_t *plan);
LIBLTE_API int dft_plan_c2c(const int dft_points, dft_dir_t dir, dft_plan_t *plan);
LIBLTE_API int dft_plan_r2r(const int dft_points, dft_dir_t dir, dft_plan_t *plan);
LIBLTE_API int dft_plan_c2r(const int dft_points, dft_dir_t dir, dft_plan_t *plan);
LIBLTE_API int dft_plan(dft_plan_t *plan, const int dft_points,
dft_mode_t mode, dft_dir_t dir);
LIBLTE_API int dft_plan_c2c(dft_plan_t *plan, const int dft_points, dft_dir_t dir);
LIBLTE_API int dft_plan_r2r(dft_plan_t *plan, const int dft_points, dft_dir_t dir);
LIBLTE_API int dft_plan_c2r(dft_plan_t *plan, const int dft_points, dft_dir_t dir);
LIBLTE_API void dft_plan_free(dft_plan_t *plan);
/* Create a vector of DFT plans */
LIBLTE_API int dft_plan_vector(const int *dft_points, dft_mode_t *modes, dft_dir_t *dirs,
int nof_plans, dft_plan_t *plans);
LIBLTE_API int dft_plan_multi_c2c(const int *dft_points, dft_dir_t dir, int nof_plans,
dft_plan_t *plans);
LIBLTE_API int dft_plan_multi_c2r(const int *dft_points, dft_dir_t dir, int nof_plans,
dft_plan_t *plans);
LIBLTE_API int dft_plan_multi_r2r(const int *dft_points, dft_dir_t dir, int nof_plans,
dft_plan_t *plans);
LIBLTE_API void dft_plan_free_vector(dft_plan_t *plan, int nof_plans);
LIBLTE_API int dft_plan_vector(dft_plan_t *plans, const int *dft_points,
dft_mode_t *modes, dft_dir_t *dirs, int nof_plans);
LIBLTE_API int dft_plan_multi_c2c(dft_plan_t *plans, const int *dft_points,
dft_dir_t dir, int nof_plans);
LIBLTE_API int dft_plan_multi_c2r(dft_plan_t *plans, const int *dft_points,
dft_dir_t dir, int nof_plans);
LIBLTE_API int dft_plan_multi_r2r(dft_plan_t *plans, const int *dft_points,
dft_dir_t dir, int nof_plans);
LIBLTE_API void dft_plan_free_vector(dft_plan_t *plans, int nof_plans);
/* Compute DFT */

@ -42,7 +42,7 @@ int lte_fft_init_(lte_fft_t *q, lte_cp_t cp_type, int nof_prb, dft_dir_t dir) {
fprintf(stderr, "Error: Invalid nof_prb=%d\n", nof_prb);
return -1;
}
if (dft_plan_c2c(symbol_sz, dir, &q->fft_plan)) {
if (dft_plan_c2c(&q->fft_plan, symbol_sz, dir)) {
fprintf(stderr, "Error: Creating DFT plan\n");
return -1;
}

@ -183,7 +183,7 @@ int pss_synch_set_N_id_2(pss_synch_t *q, int N_id_2) {
memset(q->pss_signal_freq, 0, PSS_LEN_FREQ * sizeof(cf_t));
memcpy(&pss_signal_pad[33], pss_signal_time, PSS_LEN * sizeof(cf_t));
if (dft_plan(PSS_LEN_FREQ - 1, COMPLEX_2_COMPLEX, BACKWARD, &plan)) {
if (dft_plan(&plan, PSS_LEN_FREQ - 1, COMPLEX_2_COMPLEX, BACKWARD)) {
return -1;
}
plan.options = DFT_MIRROR_PRE | DFT_DC_OFFSET;

@ -42,7 +42,7 @@ void generate_N_id_1_table(int table[30][30]);
int sss_synch_init(sss_synch_t *q) {
bzero(q, sizeof(sss_synch_t));
if (dft_plan(SSS_DFT_LEN, COMPLEX_2_COMPLEX, FORWARD, &q->dftp_input)) {
if (dft_plan(&q->dftp_input, SSS_DFT_LEN, COMPLEX_2_COMPLEX, FORWARD)) {
return -1;
}
generate_N_id_1_table(q->N_id_1_table);

@ -44,13 +44,13 @@ int conv_fft_cc_init(conv_fft_cc_t *state, int input_len, int filter_len) {
if (!state->input_fft || !state->filter_fft || !state->output_fft) {
return -1;
}
if (dft_plan(state->output_len,COMPLEX_2_COMPLEX,FORWARD,&state->input_plan)) {
if (dft_plan(&state->input_plan,state->output_len,COMPLEX_2_COMPLEX,FORWARD)) {
return -2;
}
if (dft_plan(state->output_len,COMPLEX_2_COMPLEX,FORWARD,&state->filter_plan)) {
if (dft_plan(&state->filter_plan,state->output_len,COMPLEX_2_COMPLEX,FORWARD)) {
return -3;
}
if (dft_plan(state->output_len,COMPLEX_2_COMPLEX,BACKWARD,&state->output_plan)) {
if (dft_plan(&state->output_plan,state->output_len,COMPLEX_2_COMPLEX,BACKWARD)) {
return -4;
}
return 0;

@ -36,40 +36,44 @@
#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 nof_plans, dft_plan_t *plans) {
int dft_plan_vector(dft_plan_t *plans, const int *dft_points,
dft_mode_t *modes, dft_dir_t *dirs, int nof_plans) {
int 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 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;
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 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;
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 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;
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;
}
}
@ -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) {
case COMPLEX_2_COMPLEX:
if (dft_plan_c2c(dft_points,dir,plan)) {
if (dft_plan_c2c(plan,dft_points,dir)) {
return -1;
}
break;
case REAL_2_REAL:
if (dft_plan_r2r(dft_points,dir,plan)) {
if (dft_plan_r2r(plan,dft_points,dir)) {
return -1;
}
break;
case COMPLEX_2_REAL:
if (dft_plan_c2r(dft_points,dir,plan)) {
if (dft_plan_c2r(plan,dft_points,dir)) {
return -1;
}
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);
}
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;
sign = (dir == FORWARD) ? FFTW_FORWARD : FFTW_BACKWARD;
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;
}
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;
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;
}
int dft_plan_c2r(const int dft_points, dft_dir_t dir, dft_plan_t *plan) {
if (dft_plan_c2c(dft_points, dir, plan)) {
int dft_plan_c2r(dft_plan_t *plan, const int dft_points, dft_dir_t dir) {
if (dft_plan_c2c(plan, dft_points, dir)) {
return -1;
}
plan->mode = COMPLEX_2_REAL;

Loading…
Cancel
Save