JuliaMath / FFTW.jl

Julia bindings to the FFTW library for fast Fourier transforms
https://juliamath.github.io/FFTW.jl/stable
MIT License
273 stars 55 forks source link

Normalization of FFTW.r2r for FFTW.RODFT00 #268

Closed almost6heads closed 1 year ago

almost6heads commented 1 year ago

I am confused about the r2r transform with odd symmetry. According to the FFTW manual, if I apply the RODFT00 transform to a unit vector of length 1, the result should be the vector [2]. But in Julia the commands u=ones(1,1) and v = FFTW.r2r(u,FFTW.RODFT00) gives the vector 4. Am I using this routine wrong?

stevengj commented 1 year ago

With ones(1,1) you have a 2d array, so you did a 2d RODFT00 x RODFT00 transform, which multiplies by 2 twice. If you want a 1d vector of length 1, use ones(1). (If you want to transform just the columns of a 2d array, you can pass dims=1.)