#include #include #include #include #include /* #include #include */ #ifndef M_PI #define M_PI 3.1415 #endif #include "util/util.h" #include "param/complex.h" #include "algorithm/fft.h" using namespace std; #define fft_ct fft #define ifft_ct ifft int main(){ cout << exp(Complex(0, M_PI / 2)) << endl; cout << iexp(0., M_PI / 2) << endl; cout << (1.0 / iexp(0., M_PI / 2)) << endl; cout << iexp(0., M_PI / 2).sqrt() << endl; cout << sqrt(iexp(0., M_PI / 2)) << endl; cout << iexp(1., 0.).sqrt() << endl; cout << sqrt(iexp(1., 0.)) << endl; cout << Complex(-3, 0).sqrt() << endl; cout << sqrt(Complex(-3, 0)) << endl; typedef vector vd; typedef vector > vcd; vd v1_td; v1_td.push_back(1); v1_td.push_back(2); v1_td.push_back(3); v1_td.push_back(4); /*vd hoge(v1_td.size() * 2); cout << hoge.size() << endl; //copy(v1_td.begin(), v1_td.end(), hoge.begin()); cout << hoge.size() << endl; //copy(v1_td.begin(), v1_td.end(), hoge.begin() + 4); merge(v1_td.begin(), v1_td.end(), v1_td.begin(), v1_td.end(), hoge.begin()); cout << hoge.size() << endl; for(vd::const_iterator it = hoge.begin(); it < hoge.end(); it++){ cout << *it << endl; }*/ vcd v1_fd; for(vd::const_iterator it = v1_td.begin(); it < v1_td.end(); it++){ v1_fd.push_back(FFT::ft(v1_td, it - v1_td.begin())); } for(vcd::const_iterator it = v1_fd.begin(); it < v1_fd.end(); it++){ cout << *it << endl; } for(int i = 0; i < v1_fd.size(); i++){ cout << FFT::ift(v1_fd, i) << endl; } vcd v1_td_ifft(FFT::ifft_ct(v1_fd)); for(vcd::const_iterator it = v1_td_ifft.begin(); it < v1_td_ifft.end(); it++){ cout << *it << endl; } vcd v2_td; v2_td.push_back(Complex(1, 2)); v2_td.push_back(Complex(2, 3)); v2_td.push_back(Complex(3, 4)); v2_td.push_back(Complex(4, 5)); vcd v2_fd; for(vcd::const_iterator it = v2_td.begin(); it < v2_td.end(); it++){ v2_fd.push_back(FFT::ft(v2_td, it - v2_td.begin())); } for(vcd::const_iterator it = v2_fd.begin(); it < v2_fd.end(); it++){ cout << *it << endl; } vcd v2_fd_2(FFT::fft_ct(v2_td)); for(vcd::const_iterator it = v2_fd_2.begin(); it < v2_fd_2.end(); it++){ cout << *it << endl; } for(int i = 0; i < v2_fd.size(); i++){ cout << FFT::ift(v2_fd, i) << endl; } return 0; } /* class ComplexTestSuite : public Test::Suite{ public: ComplexTestSuite(){ TEST_ADD(ComplexTestSuite::test1); } protected: virtual void setup(){ } virtual void tear_down(){ } private: void test1(){ } }; bool run_tests(){ ComplexTestSuite test_suits; Test::TextOutput output(Test::TextOutput::Verbose); return test_suits.run(output, false); // Note the 'false' parameter } int main(){run_tests();return 0;} */