Skip to content

order of individual FFTs for calculating numpy.fft.irfftn #28950

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

Open
vtavana opened this issue May 13, 2025 · 2 comments
Open

order of individual FFTs for calculating numpy.fft.irfftn #28950

vtavana opened this issue May 13, 2025 · 2 comments
Labels
33 - Question Question about NumPy usage or development component: numpy.fft

Comments

@vtavana
Copy link
Contributor

vtavana commented May 13, 2025

For numpy.fft.fftn and numpy.fft.ifftn, individual FFTs over axes are performed in reverse order.

Similarly, for numpy.fft.rfftn, individual FFTs are performed in reverse order.

However, for numpy.fft.irfftn individual FFTs are performed in forward order.
Currently we compute complex-to-complex FFT for axes[0], axes[1], .. axes[-2] and then one final complex-to-real FFT for axes[-1].
Should it be changed to complex-to-complex FFT for axes[-2], axes[-3], .. axes[0] and one final complex-to-real FFT for axes[-1] (still keeping the complex-to-real FFT over last axis)?

In general, order is not important when calculating complex-to-complex FFTs. However, when we pass s and axes parameters (with repeated indices in axes), order can affect the final shape of the array.

@mhvk
Copy link
Contributor

mhvk commented May 14, 2025

Hmm, good question. Maybe it is more logical to also use forward order for ifft?

@jorenham jorenham added component: numpy.fft 33 - Question Question about NumPy usage or development labels May 14, 2025
@vtavana
Copy link
Contributor Author

vtavana commented May 16, 2025

@mhvk yes, what you said make more sense.

In general, order is only important when there is repeated indices in axes, I noticed that SciPy does not allow repeated axes at all. I do not if there are real use cases for repeated axes, if not maybe NumPy can also raises an error when repeated axes are passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
33 - Question Question about NumPy usage or development component: numpy.fft
Projects
None yet
Development

No branches or pull requests

3 participants