/* From: "COMPUTATIONAL PHYSICS, 2nd Ed" by RH Landau, MJ Paez, and CC Bordeianu Copyright Wiley-VCH, 2007. Electronic Materials copyright: R Landau, Oregon State Univ, 2007; MJ Paez, Univ Antioquia, 2007; & CC Bordeianu, Univ Bucharest, 2007 Support by National Science Foundation */ // fourier.c: Discrete Fourier Transformation /* comment: The program reads its input data from a file in the * same directory called input.dat. This file has to contain * only y(t) values separated by whitespaces which are real * The output is the direct output from the algorithm which * will probably look very different than what you are used * to. The output has the form * frequency index \t real part \t imaginary part * related programs: invfour.c */ #include #include #define max 1000 // max number of input data #define PI 3.1415926535897932385E0 main() { double imag, real,input[max+1]; int i = 0,j,k; FILE *data; FILE *output; // read data from input.dat, save data in fourier.dat data = fopen("input.dat", "r"); output = fopen("fourier.dat", "w"); while ((fscanf(data, "%lf", &input[i]) ! = EOF) && (i