Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/definitions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,14 @@ plan_fft
"""
plan_fft!(A [, dims]; flags=FFTW.ESTIMATE, timelimit=Inf)

Same as [`plan_fft`](@ref), but operates in-place on `A`.
Same as [`plan_fft`](@ref),
but creates a plan that operates in-place.
`A` must be an array of complex floating-point numbers.
When `p = plan_fft!(A, ...)`,
one evaluates the FFT of an array `B`
of the same `size`
via `p * B` or via `mul!(B, p, B)`.
For the `mul!` use, `B` must have the same `eltype` as `A`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even for p * B, it won't work in-place if B doesn't have the same eltype, no?

(Note also that the strides have to be the same too, when applying a plan to a new array. This is typically only relevant for arrays that are views of other arrays, as otherwise the strides are determined by the size.)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the p * B version works fine even if B has different eltype and strides from A:

using LinearAlgebra: mul!
using FFTW: plan_fft! 
dima = (8,16)
A = Array{ComplexF32}(undef, dima)
B = rand(ComplexF16, 4, dima...)
p = plan_fft!(A)
C = @view B[1,:,:] # strides and eltype differs from A
p * C # works fine!
D = collect(C)
@assert p * C == p * D # passes 

You make a good point that the mul! version requires matching strides too so I updated the PR to mention that.

"""
plan_fft!

Expand Down