/* make_fourier_data.cc generates a list of doubles to mimic the uniform sampling of a square wave. output file: square_wave.dat output file is eventually read by either dft.cc or fft.cc to generate the discrete fourier transform by the clunky dft algorithm or fft algorithm, respectively. */ #include #include #include using namespace std; int main() { int i, i_max = 100 ; // max number of points to sample double data[i_max]; ofstream outfile; outfile.open("square_wave.dat"); // store output data for (i = 0; i < i_max; ++i) { data[i] = 0.0; } for (i = i_max/ 3; i < 2 * i_max / 3; i++) { data[i] = 1.0; } for (i = 0; i < i_max; i++) { outfile << i << "\t" << data[i] << endl; } outfile.close(); cout << "data written to square_wave.dat" << endl; return 0; }