Difference in `fft` implementation between stan and numpy/scipy

Oh my, it seems this is a bug not in Stan, but in cmdstanpy:

generated quantities {
   complex_vector[n] y = fft(x);
   print(get_real(y));
   print(get_imag(y));
}

outputs

Chain [1] [3.14295,1.0746,1.0746]
Chain [1] [0,0.501066,-0.501066]

This is not good! Thank you for finding this

1 Like