Created
November 3, 2013 13:26
-
-
Save vlofgren/7290266 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
| double fourier1(double x_in[], double n, int length) { | |
| double x_complex[2] = { 0, 0 }; | |
| int i; | |
| for(i = 0; i < length; i++) { | |
| x_complex[0] += x_in[i] * cos(M_PI * 2 * i * n / (double) length); | |
| x_complex[1] += x_in[i] * sin(M_PI * 2 * i * n / (double) length); | |
| } | |
| return sqrt(x_complex[0]*x_complex[0] + x_complex[1]*x_complex[1]) / (double) length; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment