does anyone understand how to use the pocketfft by martin reinecke?

Link: https://gitlab.mpcdf.mpg.de/mtr/pocketfft

Basically it's just this snipped of code:

rfft_forward(rfft_plan plan, double c[], double fct);

I understood,

  1. that the plan needs to be created to the "internal" planning of the algorithm,

  2. the array c[] is input data and will be overwritten with output data, but what stands the double fct for?

I recorded some data with my embededd system (STM32f446RE with a sensor) and did a reference fft in python ( that one works ) which differs alot from the pocketfft and I dont understand why

Is my code maybe wrong somehow?

double resultD[SIZE];
for (i=0; i < SIZE; i++){                     
     resultD[i] = (double)result[i][1];

rfft_plan plan = make_rfft_plan(SIZE);
rfft_forward(plan, resultD, 1.);

n = sprintf( buffer, "%s\n", "X" );
HAL_UART_Transmit(&huart2, buffer, n, 1000);

for(i = 0; i < SIZE; i++) {
n = sprintf( buffer, "%f\n", resultD[i] );
    HAL_UART_Transmit(&huart2, buffer, n, 1000);


In blue u can see the reference fft with python, in red the fft from the µC and the code above.

It differs in amplitude and it's shifted.

Therefor I think it's not about just a scaling factor

  • $\begingroup$ Thanks for adding the plot (please add it to your question by editing your question next time; it's not an "answer"). It looks like the Python (blue) plot is using an FFT size twice the length of the pocketfft one. Try changing rfft_plan plan = make_rfft_plan(SIZE); to rfft_plan plan = make_rfft_plan(2*SIZE); and see if they better align. $\endgroup$
    – Peter K.
    Aug 1 at 15:24
  • $\begingroup$ unfortunately playing with rfft_plan plan = make_rfft_plan(2*SIZE); did not help here. Is it maybe possible that two different ffts deliver such different results? $\endgroup$
    – jp21
    Aug 2 at 6:40


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy