#include <DuneFFT.h>
Definition at line 23 of file DuneFFT.h.
int DuneFFT::fftForward |
( |
Index |
ntick, |
|
|
const float * |
psam, |
|
|
DFT & |
dft, |
|
|
Index |
logLevel = 0 |
|
) |
| |
|
static |
Definition at line 23 of file DuneFFT.cxx.
24 const string myname =
"DuneFFT::fftForward: ";
26 if ( ! dft.
isValid() )
return 1;
27 if ( nsam == 0 )
return 0;
29 for (
Index isam=0; isam<nsam; ++isam ) sams[isam] = psam[isam];
31 TVirtualFFT* pfft = TVirtualFFT::FFT(1, &nsamInt,
"R2C");
32 pfft->SetPoints(&sams[0]);
44 for (
Index ifrq=0; ifrq<namp; ++ifrq ) {
45 pfft->GetPointComplex(ifrq, xre, xim);
48 double xam = ifrq < npha ? sqrt(xre*xre + xim*xim) : xre;
49 double xph = atan2(xim, xre);
57 if ( logLevel >= 3 ) {
58 cout << myname <<
setw(4) << ifrq <<
": (" 59 <<
setw(10) << fixed << xre <<
", " 60 <<
setw(10) << fixed << xim <<
"): " 61 <<
setw(10) << fixed << xam;
62 if ( ifrq < npha ) cout <<
" @ " <<
setw(10) << fixed << xph;
bool isConsistent() const
int setPhase(Index ifrq, F val)
void reset(Index nsam) override
virtual bool isValid() const
int setAmplitude(Index ifrq, F val)
bool isAliased(Index ifrq) const
Q_EXPORT QTSManip setw(int w)
const Norm & normalization() const override
Dft::FloatVector FloatVector
QTextStream & endl(QTextStream &s)
Definition at line 72 of file DuneFFT.cxx.
73 return fftForward(sams.size(), &sams[0], dft, logLevel);
static int fftForward(Index ntick, const float *psam, DFT &dft, Index logLevel=0)
Definition at line 79 of file DuneFFT.cxx.
80 const string myname =
"DuneFFT::fftInverse: ";
81 if ( ! dft.
isValid() )
return 1;
84 if ( namp == 0 || npha == 0 )
return 1;
85 if ( namp < npha )
return 2;
86 if ( namp - npha > 1 )
return 3;
87 Index nsam = namp + npha - 1;
89 TVirtualFFT* pfft = TVirtualFFT::FFT(1, &nsamInt,
"C2R");
92 for (
Index ifrq=0; ifrq<nsam; ++ifrq ) {
94 double pha = dft.
phase(ifrq);
95 double xre = amp*cos(pha);
96 double xim = amp*sin(pha);
100 pfft->SetPointsComplex(&xdres[0], &xdims[0]);
101 if ( logLevel >= 3 ) {
102 cout << myname <<
"Inverting" <<
endl;
103 cout << myname <<
"Real/imag components:" <<
endl;
104 for (
Index ifrq=0; ifrq<nsam; ++ifrq ) {
105 float xre = xdres[ifrq];
106 float xim = xdims[ifrq];
107 cout << myname <<
setw(4) << ifrq <<
": (" <<
setw(10) << fixed << xre
108 <<
", " <<
setw(10) << fixed << xim <<
")" <<
endl;
113 float nfac = 1.0/nsam;
114 for (
Index isam=0; isam<nsam; ++isam ) sams[isam] = nfac*pfft->GetPointReal(isam);
virtual bool isValid() const
F phase(Index ifrq) const override
F convAmplitude(Index ifrq) const
Q_EXPORT QTSManip setw(int w)
QTextStream & endl(QTextStream &s)
The documentation for this class was generated from the following files: