Skip to content

Instantly share code, notes, and snippets.

@vlofgren
Created November 3, 2013 13:26
Show Gist options
  • Select an option

  • Save vlofgren/7290266 to your computer and use it in GitHub Desktop.

Select an option

Save vlofgren/7290266 to your computer and use it in GitHub Desktop.
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