I have a simple struct wrapping a planned fft and I’m not really sure how to make it type stable
I might need to write the type of the fft, but I’m not really sure how to do it (I cannot really interpret the type of a planed fft)
function simple_fft(x, pfft::wrapper)
return pfft.pfft * x
W = wrapper(plan_fft(zeros(10)), inv(plan_fft(zeros(10))))
@code_warntype simple_fft(zeros(10), W)
Sorry only on mobile, so can’t test stuff.
I think the issue here is that your struct has untyped fields which implicitely means
Any. You should either put explicit types there (which you can find via
typeof(plan_fft(...))) und generic type paramters like
By the way, depending on what you want to do you might not need to create a wrapper.
In the docs of AbstractFFTs it says:
You can compute the inverse-transform plan by
inv(P) and apply the inverse plan with
P \ Â (the inverse plan is cached and reused for subsequent calls to
\), and apply the inverse plan to a pre-allocated output array
ldiv!(A, P, Â).
If you want the wrapper for dispatch reasons thats fine of course.