/* main.cpp */ #include #include #include #include #include #include #include int main() { std::fstream f; std::vector data; double const dx = 0.01; double x = 0.0; while( x <= 2 * M_PI ) { data.push_back( sin( x ) ); x += dx; } f.open("data.dat",std::ios::out); for(double x : data) f << x << std::endl; f.close(); std::unique_ptr real(gsl_fft_real_wavetable_alloc(data.size()),gsl_fft_real_wavetable_free); std::unique_ptr work(gsl_fft_real_workspace_alloc(data.size()),gsl_fft_real_workspace_free); std::unique_ptr hc(gsl_fft_halfcomplex_wavetable_alloc(data.size()),gsl_fft_halfcomplex_wavetable_free); gsl_fft_real_transform(data.data(),1,data.size(),real.get(),work.get()); //gsl_fft_halfcomplex_transform(data.data(),1,data.size(),hc.get(),work.get()); f.open("fft-data.dat",std::ios::out); for(double x : data) f << x << std::endl; f.close(); return 0; }