7 #include "TVirtualFFT.h" 24 m_flag(opt==2 ? FFTW_PATIENT : opt==1 ? FFTW_MEASURE : FFTW_ESTIMATE),
25 m_inData((
Float*) fftw_malloc(m_nsamMax*sizeof(
Float))),
31 for (
auto& iplan :
m_forwardPlans ) fftw_destroy_plan(iplan.second);
40 const string myname =
"FwFFT::forwardPlan";
43 cout << myname <<
"Sample count is too large. Maximum is " <<
m_nsamMax <<
endl;
55 const string myname =
"FwFFT::backwardPlan";
58 cout << myname <<
"Sample count is too large. Maximum is " <<
m_nsamMax <<
endl;
71 const string myname =
"FwFFT::fftForward: ";
73 cout << myname <<
"Sample count is too large. Maximum is " <<
m_nsamMax <<
endl;
77 if ( ! dft.
isValid() )
return 1;
78 if ( nsam == 0 )
return 0;
79 for (
Index isam=0; isam<nsam; ++isam )
m_inData[isam] = psam[isam];
92 for (
Index ifrq=0; ifrq<namp; ++ifrq ) {
97 double xam = ifrq < npha ? sqrt(xre*xre + xim*xim) : xre;
98 double xph = atan2(xim, xre);
106 if ( logLevel >= 3 ) {
107 cout << myname <<
setw(4) << ifrq <<
": (" 108 <<
setw(10) << fixed << xre <<
", " 109 <<
setw(10) << fixed << xim <<
"): " 110 <<
setw(10) << fixed << xam;
111 if ( ifrq < npha ) cout <<
" @ " <<
setw(10) << fixed << xph;
122 return fftForward(sams.size(), &sams[0], dft, logLevel);
129 const string myname =
"FwFFT::fftInverse: ";
130 if ( ! dft.
isValid() )
return 1;
133 if ( namp == 0 || npha == 0 )
return 1;
134 if ( namp < npha )
return 2;
135 if ( namp - npha > 1 )
return 3;
136 Index nsam = namp + npha - 1;
138 cout << myname <<
"Sample count is too large. Maximum is " <<
m_nsamMax <<
endl;
141 for (
Index ifrq=0; ifrq<nsam; ++ifrq ) {
143 double pha = dft.
phase(ifrq);
144 double xre = amp*cos(pha);
145 double xim = amp*sin(pha);
151 float nfac = 1.0/nsam;
153 for (
Index isam=0; isam<nsam; ++isam ) sams[isam] = nfac*
m_inData[isam];
bool isConsistent() const
int setPhase(Index ifrq, F val)
int fftForward(Index nsam, const float *psam, DFT &dft, Index logLevel=0)
FwFFT(Index nsamMax, Index opt)
void reset(Index nsam) override
virtual bool isValid() const
F phase(Index ifrq) const override
F convAmplitude(Index ifrq) const
Plan & forwardPlan(Index nsam)
int setAmplitude(Index ifrq, F val)
bool isAliased(Index ifrq) const
Q_EXPORT QTSManip setw(int w)
Plan & backwardPlan(Index nsam)
const Norm & normalization() const override
int fftInverse(const DFT &dft, FloatVector &sams, Index logLevel=0)
std::vector< float > FloatVector
QTextStream & endl(QTextStream &s)