Skip to content

Commit 1f98169

Browse files
committed
Revised documentation for plan_fft.
- Added warnings about serialization and overwriting inputs. - Section breaks and more info on FFTW planning. - Light copyediting.
1 parent 04a14f5 commit 1f98169

File tree

1 file changed

+48
-26
lines changed

1 file changed

+48
-26
lines changed

src/definitions.jl

Lines changed: 48 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -102,32 +102,54 @@ plan_bfft
102102
"""
103103
plan_fft(A [, dims]; flags=FFTW.ESTIMATE, timelimit=Inf)
104104
105-
Pre-plan an optimized FFT along given dimensions (`dims`) of arrays matching the shape and
106-
type of `A`. (The first two arguments have the same meaning as for [`fft`](@ref).)
107-
Returns an object `P` which represents the linear operator computed by the FFT, and which
108-
contains all of the information needed to compute `fft(A, dims)` quickly.
109-
110-
To apply `P` to an array `A`, use `P * A`; in general, the syntax for applying plans is much
111-
like that of matrices. (A plan can only be applied to arrays of the same size as the `A`
112-
for which the plan was created.) You can also apply a plan with a preallocated output array `Â`
113-
by calling `mul!(Â, plan, A)`. (For `mul!`, however, the input array `A` must
114-
be a complex floating-point array like the output `Â`.) You can compute the inverse-transform plan by `inv(P)`
115-
and apply the inverse plan with `P \\ Â` (the inverse plan is cached and reused for
116-
subsequent calls to `inv` or `\\`), and apply the inverse plan to a pre-allocated output
117-
array `A` with `ldiv!(A, P, Â)`.
118-
119-
The `flags` argument is a bitwise-or of FFTW planner flags, defaulting to `FFTW.ESTIMATE`.
120-
e.g. passing `FFTW.MEASURE` or `FFTW.PATIENT` will instead spend several seconds (or more)
121-
benchmarking different possible FFT algorithms and picking the fastest one; see the FFTW
122-
manual for more information on planner flags. The optional `timelimit` argument specifies a
123-
rough upper bound on the allowed planning time, in seconds. Passing `FFTW.MEASURE` or
124-
`FFTW.PATIENT` may cause the input array `A` to be overwritten with zeros during plan
125-
creation.
126-
127-
[`plan_fft!`](@ref) is the same as [`plan_fft`](@ref) but creates a
128-
plan that operates in-place on its argument (which must be an array of complex
129-
floating-point numbers). [`plan_ifft`](@ref) and so on are similar but produce
130-
plans that perform the equivalent of the inverse transforms [`ifft`](@ref) and so on.
105+
Pre-plan an optimized FFT for arrays of the same size and shape as `A`, acting along
106+
dimensions `dims`. The returned plan object `P` contains the information and
107+
preallocated buffers needed to efficiently perform that transform.
108+
109+
### Applying Plans
110+
111+
Plans are applied using a syntax similar to matrix operations. To apply the plan `P` to an
112+
array `A`, use `P * A`, which returns a new array containing the transformed data. To use a
113+
preallocated output array `Â`, call `mul!(Â, P, A)`. A plan can only be applied to arrays
114+
of the same size and type as the array `A` for which the plan was created. For `mul!`, both
115+
the input and output arrays must be complex floating-point arrays.
116+
117+
### Inverse transforms
118+
119+
When a plan `P` is available, `inv(P)` will compute its inverse, which can then be applied
120+
via `P \\ Â`, which returns a new array. Alternately, use `ldiv!(A, P, Â)` to store the
121+
results in the preallocated output array `A`. Inverse plans are automatically cached and
122+
reused for subsequent calls. When only the inverse plan is needed, generate it directly
123+
with [`plan_ifft`](@ref).
124+
125+
### Planner Flags and Performance
126+
127+
Planner flags are back-end specific and the default back-end, FFTW, takes two keyword options.
128+
The `flags` argument is a bitwise-OR of FFTW planner flags that control the planning strategy.
129+
The optional `timelimit` (in seconds) sets a rough upper bound on planning time.
130+
131+
- `FFTW.ESTIMATE` (default): A fast heuristic-based approach.
132+
- `FFTW.MEASURE`, `FFTW.PATIENT`, `FFTW.EXHAUSTIVE`: These flags benchmark different FFT
133+
algorithms to find the fastest one for your specific input. This can take a significant
134+
amount of time and may overwrite `A`.
135+
136+
For more details, see §4.2 of the [FFTW Manual](https://www.fftw.org/fftw3_doc/Planner-Flags.html).
137+
138+
> **Warning**: Using flags other than `FFTW.ESTIMATE` may cause the input array `A` to be
139+
> overwritten with zeros during plan creation.
140+
141+
### Parallel Processing and Serialization
142+
143+
Plan objects may contain pointers to internal buffers and thus should not be serialized or
144+
copied. In parallel environments, each worker process requires its own separately-constructed
145+
plan object. Some back-ends provide mechanisms for reusing benchmarks, like FFTW's "wisdom"
146+
mechanism.
147+
148+
### Related Functions
149+
150+
- [`plan_fft!`](@ref): Creates a plan that computes the FFT in-place.
151+
- [`plan_ifft`](@ref), [`plan_bfft`](@ref), etc.: Create plans for the corresponding
152+
inverse and unnormalized transforms.
131153
"""
132154
plan_fft
133155

0 commit comments

Comments
 (0)