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

Add an option to use plan_r2r of FFTW #4

Closed
ptiede opened this issue Jan 7, 2025 · 5 comments
Closed

Add an option to use plan_r2r of FFTW #4

ptiede opened this issue Jan 7, 2025 · 5 comments
Labels
enhancement New feature or request

Comments

@ptiede
Copy link
Member

ptiede commented Jan 7, 2025

For FFTW it provides a built in Hartley transform with, its r1r function which may save time and memory. Did we want to use this instead?

@ptiede
Copy link
Member Author

ptiede commented Jan 7, 2025

@kazuakiyama
Copy link
Member

@ptiede Yes this was the first thing I checked. I tested FFTW's r2r before pushing this to the public repository.

I would note that FFTW's FFTW_DHT mode for r2r transform does NOT provide the exact multi-dimensional transform for the two or larger dimensions. See the note below in FFTW's documentation:

If FFTW_DHT is specified for multiple dimensions of a multi-dimensional transform, FFTW computes the separable product of 1d DHTs along each dimension. Unfortunately, this is not quite the same thing as a true multi-dimensional DHT; you can compute the latter, if necessary, with at most rank-1 post-processing passes [see e.g. H. Hao and R. N. Bracewell, Proc. IEEE 75, 264–266 (1987)].
https://www.fftw.org/doc/The-Discrete-Hartley-Transform.html

It turns out that FFTW's implementation of multidimensional transform is not only inaccurate but also slow. I tested with 2 and 3 dimensional cases, and found that pure Julia implementation (basically using real(ffted array) .+ imag(ffted array) seems to be at least a factor of two times faster. This is simply because FFTW does a separable transform.

Having said that it is possible that we can force to use FFTW's r2r for one dimensional transform --- indeed for 1 dimensional case FFTW is slightly faster. I will think about that. At least I confirmed that my implementation is consistent with FFTW for 1 dimensional transform.

@kazuakiyama kazuakiyama changed the title Use plan_r2r instead of plan_bfft Add an option to use plan_r2r of FFTW Jan 8, 2025
@kazuakiyama kazuakiyama added the enhancement New feature or request label Jan 8, 2025
@ptiede
Copy link
Member Author

ptiede commented Jan 9, 2025

Ahh makes sense! This looks good then!

@kazuakiyama
Copy link
Member

OK I have added an option to use r2r (ndim(A) > 1 will show a warn message). For 1d array, it will use FFTW's r2r transform as it is faster.

@kazuakiyama
Copy link
Member

I will close this issue as I have officially released the first version (which is now being registered to the Julia package repo). Feel free to open the issue again if needed.

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

No branches or pull requests

2 participants