I would like to know whether there's a possiblity to enforce pyFFTW (wrapper around FFTW) the input vector to be preserved during forward r2c transform.
At least in original FFTW the FFTW_PRESERVE_INPUT seems to be a default option (look at algorithm-restriction flags here: http://www.fftw.org/doc/Planner-Flags.html )
With pyFFTW's FFTW.__call__() one can pass several flags, but only 'FFTW_DESTROY_INPUT' is listed here: http://hgomersall.github.io/pyFFTW/pyfftw/pyfftw.html#pyfftw.FFTW
Probably, that's not only lapse in documentation because in the source code, in the file builders/builders.py there's a bit terrifying statement (line 166):
overwrite_input: Whether or not the input array can be overwritten during the transform.
Further in the code in file builders/_utils.py in definition of a function _Xfftn, only destory flag is present:
if overwrite_input:
flags.append('FFTW_DESTROY_INPUT')
The ultimate question is: knowing that the FFTW_PRESERVE_INPUT cannot be passed with pyFFTW, could I at least rely on the fact that in original FFTW this flag FFTW_PRESERVE_INPUT is default? Recall the comment quoted above: "Whether or not the input array can be overwritten" Does the authors of pyFFTW wrapper know something more and default FFTW_PRESERVE_INPUT won't work?
$ rpm -q fftw
fftw-3.3.4-6.fc23.x86_64
>>> pyfftw.__version__
'0.10.1
Yes, all the defaults are used unless explicitly requested - this means that unless you request DESTROY_INPUT
, then PRESERVE_INPUT
is implicit, except in the case where you have a multi-dimensional c2r transform, in which case the input will be destroyed (this is documented in the Schemes
section of the documentation you linked to, as well as the FFTW docs you linked to).
If you find a case where the input is destroyed and it is not either explicitly requested as such or is not one of the above transforms, this is a bug and should be reported.
The interfaces
code makes various copies to make sure transforms are preserved when necessary.
My recollection is the planning stage is much looser about protecting arrays - the easiest way of protecting the array is to use the builders
interface which, unless explicitly advised otherwise, will always store the original array and copy it back in.