|
|
|
@ -37,6 +37,20 @@
|
|
|
|
|
#define dft_ceil(a,b) ((a-1)/b+1)
|
|
|
|
|
#define dft_floor(a,b) (a/b)
|
|
|
|
|
|
|
|
|
|
#define FFTW_WISDOM_FILE ".fftw_wisdom"
|
|
|
|
|
|
|
|
|
|
void srslte_dft_load() {
|
|
|
|
|
if (!fftwf_import_wisdom_from_filename(FFTW_WISDOM_FILE)) {
|
|
|
|
|
fprintf(stderr, "Error loading FFTW wisdom from file %s\n", FFTW_WISDOM_FILE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void srslte_dft_exit() {
|
|
|
|
|
if (!fftwf_export_wisdom_to_filename(FFTW_WISDOM_FILE)) {
|
|
|
|
|
fprintf(stderr, "Error saving FFTW wisdom to file %s\n", FFTW_WISDOM_FILE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int srslte_dft_plan(srslte_dft_plan_t *plan, const int dft_points, srslte_dft_dir_t dir,
|
|
|
|
|
srslte_dft_mode_t mode) {
|
|
|
|
|
if(mode == SRSLTE_DFT_COMPLEX){
|
|
|
|
@ -85,7 +99,7 @@ int srslte_dft_replan_c(srslte_dft_plan_t *plan, const int new_dft_points) {
|
|
|
|
|
int srslte_dft_plan_c(srslte_dft_plan_t *plan, const int dft_points, srslte_dft_dir_t dir) {
|
|
|
|
|
allocate(plan,sizeof(fftwf_complex),sizeof(fftwf_complex), dft_points);
|
|
|
|
|
int sign = (dir == SRSLTE_DFT_FORWARD) ? FFTW_FORWARD : FFTW_BACKWARD;
|
|
|
|
|
plan->p = fftwf_plan_dft_1d(dft_points, plan->in, plan->out, sign, 0U);
|
|
|
|
|
plan->p = fftwf_plan_dft_1d(dft_points, plan->in, plan->out, sign, FFTW_MEASURE);
|
|
|
|
|
if (!plan->p) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
@ -108,7 +122,7 @@ int srslte_dft_replan_r(srslte_dft_plan_t *plan, const int new_dft_points) {
|
|
|
|
|
fftwf_destroy_plan(plan->p);
|
|
|
|
|
plan->p = NULL;
|
|
|
|
|
}
|
|
|
|
|
plan->p = fftwf_plan_r2r_1d(new_dft_points, plan->in, plan->out, sign, 0U);
|
|
|
|
|
plan->p = fftwf_plan_r2r_1d(new_dft_points, plan->in, plan->out, sign, FFTW_MEASURE);
|
|
|
|
|
if (!plan->p) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|