/* make_fourier_data.cc generates a list of doubles to mimic the uniform sampling of a time-dependent signal. output file: fourier_raw.dat output file is eventually read in by fourier.cc to generate the digital fourier transform of the data created in the present code. */ #include #include #include using namespace std; double func(double x); int main() { int i_max = 1000 ; // max number of points to sample // int i,n; // double data[n]; double y = 0.0; double step = 0.001; // time between samples, user units // (step)^-1 is the sampling rate const double two_pi = 2*acos(-1.0); ofstream outfile; outfile.open("fourier_raw.dat"); // store output data /* for (i = 0; i < i_max; ++i) { data[i] = 0.0; } for (i = n / 3; i < 2 * n / 3; i++) { data[i] = 1.0; } for (i = 0; i < n; i++) { printf ("%d %e\n", i, data[i]); } printf ("\n"); */ for (int k = 0 ; k < i_max; ++k){ // "sample" the waveform y = func(step *k*two_pi); outfile << k << "\t" << y << endl; } outfile.close(); cout << "data written to fourier_raw.dat" << endl; return 0; } double func(double x){ // sampled waveform // return cos(5.0*x) + cos(20.0*x); return cos(5.0*x) + cos(40.0*x); }