Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify the use of plan_fft! #82

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

JeffFessler
Copy link

@JeffFessler JeffFessler commented Dec 7, 2022

The existing docstring refers to the array A that is used to construct the plan, but that array is irrelevant (other than its eltype and size) (Edit: and strides) when using the plan later. The old wording made it sound like the A in the constructor itself is used.

The existing docstring refers to the array `A` that is used to construct the plan, but that array is irrelevant (other than its eltype and size) when using the plan later.  The old wording made it sound like the `A` in the constructor itself is used.
@codecov
Copy link

codecov bot commented Dec 7, 2022

Codecov Report

Base: 84.13% // Head: 84.13% // No change to project coverage 👍

Coverage data is based on head (cf0f5af) compared to base (7d698db).
Patch has no changes to coverable lines.

Additional details and impacted files
@@           Coverage Diff           @@
##           master      #82   +/-   ##
=======================================
  Coverage   84.13%   84.13%           
=======================================
  Files           2        2           
  Lines         208      208           
=======================================
  Hits          175      175           
  Misses         33       33           
Impacted Files Coverage Δ
src/definitions.jl 68.26% <ø> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@JeffFessler
Copy link
Author

bump :)

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants