/* spectrum.c */
/* */
/* gcc-4.1.0 complilation command: */
/* */
/* gcc spectrum.c -lm */
/* */
/* g++-4.1.0 compilation command: */
/* */
/* g++ spectrum.c */
/* */
#include
#include
main()
{
float eta=0.01;
float x0=4.0;
int n0=100;
/* there is no complex variable type in c. */
float gr, gi;
float zr, zi;
float zzr, zzi;
/* open output file. */
FILE *fp;
fp=fopen("output.dat","w");
/* compute frequency increment. */
float x=n0;
float dx=x0/x;
/* compute number of bins. */
int n=n0*2;
/* loop over frequencies. */
float pi=3.1415927;
int j;
for(j=0;j0)
{
gr=-gr;
gi=-gi;
}
gr=(gr+zzr)/2.0;
gi=(gi+zzi)/2.0;
/* write result to file. */
fprintf(fp,"%10.4f %10.4f %10.4f\n",x,gr,gi);
}
}