Re: FFTW versus NRC FFT



stevenj@xxxxxxxxxxxx wrote:
In particular, if I remember correctly, the "sinft" transform that NRC
introduces corresponds to the type-I DST, or RODFT00 in FFTW (as
defined by the above link). In your code, however, you are calling
RODFT10, corresponding to a type-II DST.

Another thing to watch out for is that there is a difference in the
definition of "n" in Numerical Recipes compared to FFTW for RODFT00.

In Numerical Recipes, the input to sinft(y, n) is an array y[1...n] of
length n. However, y[1] is set to zero in the routine --- that is, the
input contains a "superfluous" value corresponding to the zeroth input
of the odd-symmetry DFT (this input is always zero for an odd
function).

In FFTW, the input to RODFT00 (DST-I) does not contain this superfluous
zero input..i.e., it corresponds to the NR input starting at y[2].
FFTW's arrays are also zero-based. Thus, FFTW calls corresponding to
to Numerical Recipes' sinft(y, n) should be:

fftw_plan plan = fftw_plan_r2r_1d(n-1, y-2, y-2, RODFT00,
FFTW_ESTIMATE);
fftw_execute(plan);

Note the n-1 to give the number of (non-zero) inputs, and the y-2 to
give a zero-based array starting at y[2]. Note also that FFTW's
normalization differs by an overall scale factor of 2 from Numerical
Recipes'.

Regards,
Steven G. Johnson

.



Relevant Pages

  • Re: Derivative of 2d function with fftw
    ... I compare the ... amplitude of each mode in 2d with both numerical recipes and fftw. ... mode) the numerical recipes set 0 (more precisely are of order ...
    (comp.dsp)
  • Re: Derivative of 2d function with fftw
    ... I compare the amplitude of each ... mode in 2d with both numerical recipes and fftw. ... of exp*expthe 1-1 fourier mode) the numerical recipes set 0 (more ...
    (comp.dsp)