/* * Copyright (c) 2003-2010, Mark Borgerding. All rights reserved. * This file is part of KISS FFT - https://github.com/mborgerding/kissfft * * SPDX-License-Identifier: BSD-3-Clause * See COPYING file for more information. */ #include "kissfft.hh" #include #include #include #include static inline double curtime(void) { struct timeval tv; gettimeofday(&tv, NULL); return (double)tv.tv_sec + (double)tv.tv_usec*.000001; } using namespace std; template void dotest(int nfft) { typedef kissfft FFT; typedef std::complex cpx_type; cout << "type:" << typeid(T).name() << " nfft:" << nfft; FFT fft(nfft,false); vector inbuf(nfft); vector outbuf(nfft); for (int k=0;k acc = 0; long double phinc = 2*k0* M_PIl / nfft; for (int k1=0;k1 x(inbuf[k1].real(),inbuf[k1].imag()); acc += x * exp( complex(0,-k1*phinc) ); } totalpower += norm(acc); complex x(outbuf[k0].real(),outbuf[k0].imag()); complex dif = acc - x; difpower += norm(dif); } cout << " RMSE:" << sqrt(difpower/totalpower) << "\t"; double t0 = curtime(); int nits=20e6/nfft; for (int k=0;k1) { for (int k=1;k(nfft); dotest(nfft); dotest(nfft); } }else{ dotest(32); dotest(32); dotest(32); dotest(1024); dotest(1024); dotest(1024); dotest(840); dotest(840); dotest(840); } return 0; }