17 #include <unsupported/Eigen/FFT> 20 using namespace Eigen;
34 T
mag2(
const std::vector<T> & vec)
37 for (
size_t k=0;k<vec.size();++k)
43 T
mag2(
const std::vector<std::complex<T> > & vec)
46 for (
size_t k=0;k<vec.size();++k)
52 vector<T>
operator-(
const vector<T> & a,
const vector<T> &
b )
55 for (
size_t k=0;k<b.size();++k)
63 for (
size_t k=0;k<vec.size();++k)
64 vec[k] = T( rand() )/T(RAND_MAX) - .5;
70 for (
size_t k=0;k<vec.size();++k)
71 vec[k] = std::complex<T> ( T( rand() )/T(RAND_MAX) - .5, T( rand() )/T(RAND_MAX) - .5);
74 template <
typename T_time,
typename T_freq>
78 vector<T_time> timebuf(nfft);
81 vector<T_freq> freqbuf;
82 static FFT<Scalar> fft;
83 fft.fwd(freqbuf,timebuf);
85 vector<T_time> timebuf2;
86 fft.inv(timebuf2,freqbuf);
88 long double rmse =
mag2(timebuf - timebuf2) /
mag2(timebuf);
89 cout <<
"roundtrip rmse: " << rmse << endl;
92 template <
typename T_scalar>
96 fwd_inv<T_scalar,std::complex<T_scalar> >(nfft);
98 fwd_inv<std::complex<T_scalar>,std::complex<T_scalar> >(nfft);
103 cout <<
"nfft=" << nfft << endl;
104 cout <<
" float" << endl;
105 two_demos<float>(nfft);
106 cout <<
" double" << endl;
107 two_demos<double>(nfft);
108 cout <<
" long double" << endl;
109 two_demos<long double>(nfft);
void fwd_inv(size_t nfft)
void demo_all_types(int nfft)
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
vector< T > operator-(const vector< T > &a, const vector< T > &b)
void RandomFill(std::vector< T > &vec)
EIGEN_DEVICE_FUNC const Scalar & b