I would make a “config” or “workspace” object that holds the temporary buffers, and have the caller construct and re-use it. Examples: https://docs.juliadsp.org/stable/periodograms/#Configuration-objects, https://github.com/baggepinnen/DynamicAxisWarping.jl/blob/a5e760e49758b2aaf6bcb52aca855585be7f6c9c/src/gdtw.jl#L1-L12. Similar to passing around buffer, but grouped up if you have more than one, and possibly along with the settings (I guess n_atoms, n_basis here), if those determine the size of the buffers.
2 Likes