Created
August 7, 2021 14:06
-
-
Save Ben-0-mad/92c87bbbf72579410c185cef8dda3a18 to your computer and use it in GitHub Desktop.
FFT of (0,1,2,3,4,5,6,7) using FFTW3
This file contains 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
#include <fftw3.h> | |
#include <iostream> | |
int main() | |
{ | |
int numOfPoints = 8; | |
fftw_complex* input = new fftw_complex[numOfPoints]; | |
fftw_complex* output = new fftw_complex[numOfPoints]; | |
for (int i = 0; i <numOfPoints; i++){ | |
input[i][0] = i; | |
input[i][1] = 0; | |
} | |
fftw_plan plan = fftw_plan_dft_1d(numOfPoints, | |
input, | |
output, | |
FFTW_FORWARD, | |
FFTW_ESTIMATE); | |
fftw_execute(plan); | |
fftw_destroy_plan(plan); | |
for (int i = 0; i < numOfPoints; i++){ | |
std::cout << output[i][0] << " + i*" << output[i][1] << std::endl; | |
} | |
fftw_free(input); | |
fftw_free(output); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment