/****************************************************************************** * * * COMPUTE GAUSS SUM * * 04/02/10 (dkc) * * * ******************************************************************************/ #include <math.h> void gauss(unsigned int n, unsigned int k, double *xi, double *out) { unsigned int i; double pi,sumre,sumim,tempre,tempim; pi=3.141592654; sumre=0.0; sumim=0.0; for (i=1; i<=k; i++) { tempre=cos(2.0*pi*(double)i*(double)n/(double)k); tempim=sin(2.0*pi*(double)i*(double)n/(double)k); sumre=sumre+xi[2*i-2]*tempre-xi[2*i-1]*tempim; sumim=sumim+xi[2*i-2]*tempim+xi[2*i-1]*tempre; } out[0]=sumre; out[1]=sumim; return; }