Thank you Thaddy,
If you be so kind, please look at my testing program.
uses types, Math, fftw_s;
const
L = 256;
var
i: Word;
Signal: TSingleDynArray;
Fourier, Fourier_preserved: array of complex_single;
p: fftw_plan_single;
procedure Report(const Head: string);
var
i: Word;
MaxError: Single;
begin
MaxError := 0;
for i := 0 to High(Fourier) do
begin
MaxError := Max(MaxError, Abs(Fourier[i].Re - Fourier_preserved[i].Re));
MaxError := Max(MaxError, Abs(Fourier[i].Im - Fourier_preserved[i].Im));
end;
WriteLn('Error ' + Head, #9, MaxError:0:4);
end;
begin
SetLength(Signal, L);
SetLength(Fourier, L div 2 + 1);
for i := 0 to High(Signal) do Signal[i] := i;
// Real to complex - just to fill the complex array in
p := fftw_plan_dft_1d(L, PSingle(@Signal[0]), @Fourier[0], [fftw_estimate]);
fftw_execute(p);
fftw_destroy_plan(p);
Fourier_preserved := Copy(Fourier, 0, Length(Fourier));
Report('before inverse transform' );
// complex to Real - reverse just to test whether Fourier is preserved;
p := fftw_plan_dft_1d(L, Pcomplex_single(@Fourier[0]), @Signal[0], [fftw_estimate, fftw_preserve_input]);
fftw_execute(p);
fftw_destroy_plan(p);
Report('after inverse transform' );
end.
I got such results:
Error before inverse transform 0.0000
Error after inverse transform 32768.0000
The first number is obviously zero because it compares immediate copy. The second number is the evident error and may be random.
I run the test under Windows 10, 64 bits.
I don't know the newer ffftw*.dll for this platform. Version 3.3.6 is not yes compiled (as far as I know).
Obviously, I can manage my problem as it has been shown on my testing program.
I wanted just share the problem, that we can not trust the documentation.
On the other hand, it would be elegant to have a library which does not enforce such patches.