Content-Length: 256257 | pFad | http://github.com/numpy/numpy/issues/28914

98 DOC: indices on numpy.fft.ifft · Issue #28914 · numpy/numpy · GitHub
Skip to content

DOC: indices on numpy.fft.ifft #28914

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

Closed
saulopo opened this issue May 6, 2025 · 4 comments
Closed

DOC: indices on numpy.fft.ifft #28914

saulopo opened this issue May 6, 2025 · 4 comments

Comments

@saulopo
Copy link

saulopo commented May 6, 2025

Issue with current documentation:

https://numpy.org/doc/stable/reference/generated/numpy.fft.ifft.html#numpy.fft.ifft

In the description "The input should be ordered in the same way as is returned by fft, i.e.,

  • a[0] should contain the zero frequency term,
  • a[1:n//2] should contain the positive-frequency terms,
  • a[n//2 + 1:] should contain the negative-frequency terms, in increasing order starting from the most negative frequency",

shouldn't "a[n//2 + 1:]" be "a[n//2:]" ? The former item (a[1:n//2]) ranges from 1 to n//2-1.

Idea or request for content:

No response

@eendebakpt
Copy link
Contributor

I think you are right. Would you like to open a PR to fix this?

@saulopo
Copy link
Author

saulopo commented May 8, 2025

Hmm maybe not a good idea as I am not skilled with it.. but I can see the tutorial when I have a chance

@vtavana
Copy link
Contributor

vtavana commented May 9, 2025

@saulopo The next line in the doc says that "For an even number of input points, A[n//2] represents the sum of ..." so the missing element you mentioned is explained separately
It is explained here in more detail: https://numpy.org/doc/stable/reference/routines.fft.html#:~:text=The%20values%20in,largest%20negative%20frequency.

However, I believe the correct way to write it is

* ``a[0]`` ...,
* ``a[1:(n+1)//2]`` ..., (This one should be modified to be correct with both `n` even or odd 
* ``a[n//2 + 1:]`` ...

For an even number of input points, ``a[n//2]`` ...

For example

import numpy as np
n=5   # odd
a = np.arange(n)
a[1:(n+1)//2]
# array([1, 2])
a[n//2 + 1:]
# array([3, 4])

n=6  # even
a = np.arange(n)
a[1:(n+1)//2]
# array([1, 2])
a[n//2 + 1:]
# array([4, 5])
a[n//2]
# np.int64(3)

@saulopo
Copy link
Author

saulopo commented May 10, 2025

Thanks @vtavana , I see what you mean.

@saulopo saulopo closed this as completed May 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/numpy/numpy/issues/28914

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy