Created
November 10, 2021 11:10
-
-
Save grey-area/a764b70480851ff5c4b25d1b0acaeb7c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def real_forward_fft(x): | |
N = len(x) # length of input signal | |
K = N // 2 + 1 # length of resulting FFT | |
result = np.zeros(K, dtype=np.complex64) | |
for k in range(K): | |
val = 0.0 | |
for n in range(N): # note, in Python j is the imaginary number sqrt(-1) | |
val += x[n] * np.exp(-1j * 2 * np.pi / N * k * n) | |
result[k] = val | |
return result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment