17 #include <unsupported/Eigen/FFT> 19 using namespace Eigen;
41 using namespace Eigen;
44 void bench(
int nfft,
bool fwd,
bool unscaled=
false,
bool halfspec=
false)
47 typedef typename std::complex<Scalar>
Complex;
48 int nits =
NDATA/nfft;
49 vector<T> inbuf(nfft);
50 vector<Complex > outbuf(nfft);
54 fft.SetFlag(fft.Unscaled);
58 fft.SetFlag(fft.HalfSpectrum);
63 std::fill(inbuf.begin(),inbuf.end(),0);
64 fft.fwd( outbuf , inbuf);
68 for (
int k=0;k<8;++k) {
71 for(
int i = 0;
i < nits;
i++)
72 fft.fwd( outbuf , inbuf);
74 for(
int i = 0;
i < nits;
i++)
75 fft.inv(inbuf,outbuf);
79 cout << nameof<Scalar>() <<
" ";
80 double mflops = 5.*nfft*
log2((
double)nfft) / (1e6 * timer.
value() / (double)nits );
94 cout <<
" NFFT=" << nfft <<
" " << (double(1
e-6*nfft*nits)/timer.
value()) <<
" MS/s " << mflops <<
"MFLOPS\n";
97 int main(
int argc,
char ** argv)
99 bench<complex<float> >(
NFFT,
true);
100 bench<complex<float> >(
NFFT,
false);
101 bench<float>(
NFFT,
true);
102 bench<float>(
NFFT,
false);
103 bench<float>(
NFFT,
false,
true);
104 bench<float>(
NFFT,
false,
true,
true);
106 bench<complex<double> >(
NFFT,
true);
107 bench<complex<double> >(
NFFT,
false);
108 bench<double>(
NFFT,
true);
109 bench<double>(
NFFT,
false);
110 bench<complex<long double> >(
NFFT,
true);
111 bench<complex<long double> >(
NFFT,
false);
112 bench<long double>(
NFFT,
true);
113 bench<long double>(
NFFT,
false);
string nameof< long double >()
Namespace containing all symbols from the Eigen library.
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
std::complex< RealScalar > Complex
Array< double, 1, 3 > e(1./3., 0.5, 2.)
string nameof< double >()
double value(int TIMER=CPU_TIMER) const
void bench(int nfft, bool fwd, bool unscaled=false, bool halfspec=false)
static constexpr int log2(size_t n, int k=0)
int main(int argc, char **argv)