ludvigak / FINUFFT.jl

Julia interface to the nonuniform FFT library FINUFFT
Other
33 stars 9 forks source link

Minor type stability and allocation improvements #52

Closed jipolanco closed 2 months ago

jipolanco commented 1 year ago

First of all, thank you for this amazing library and for providing a Julia interface.

This PR is to propose a few minor changes with the aim of suppressing some tiny memory allocations which occur when performing transforms using the guru interface. When performing many transforms with the same plan, these allocations can add up, and it may be nice to have them removed.

The changes completely suppress allocations when applying a plan using finufft_setpts! and finufft_exec!. This is in part achieved by fixing some type instabilities, and also by avoiding the allocation of some empty arrays (as in T[]). Some tests are also included.

For convenience, the PR introduces an undocumented variant of finufft_makeplan which takes dtype as its first positional argument and which is type stable (in the sense that the dtype, Float32 or Float64, is known by the compiler). But one could change the name of this variant if this is confusing.