Enumerations | Functions
FancyFFTs Namespace Reference

My implementation of a wrapper for FFTW for use with ROOT thing. More...

Enumerations

enum  conventionFlag {
  kSum = 0, kAverage = 1, kTimeIntegral = 2, kPowSpecDensity = 3,
  kPowSpecDensity_dBm = 4
}
 Flag to pass to FancyFFT functions specifying normalization of power spectra.
 

Functions

complex< double > * doFFT (int len, double *input, bool copyOutputToNewArray, int threadInd=0)
 Does a forward fast fourier transform on a real input array. More...
 
complex< double > * doFFT (int len, double *input, complex< double > *output, int threadInd=0)
 Does a forward fast fourier transform on a real input array. More...
 
complex< double > * doFFT (int len, double *input, complex< double > *output, bool copyOutputToNewArray, int threadInd=0)
 Does a forward fast fourier transform on a real input array. More...
 
double * doInvFFT (int len, complex< double > *input, bool copyOutputToNewArray, int threadInd=0)
 Does an inverse fast fourier transform on an array of complex<double>s. More...
 
double * doInvFFT (int len, complex< double > *input, double *output, int threadInd=0)
 Does an inverse fast fourier transform on an array of complex<double>s. More...
 
double * doInvFFT (int len, complex< double > *input, double *output, bool copyOutputToNewArray, int threadInd=0)
 Does an inverse fast fourier transform on an array of complex<double>s. More...
 
double * getPowerSpectrum (int len, double *input, double dt, conventionFlag normFlag, int threadInd=0)
 Creates the power spectrum in an array of doubles of length (len/2 + 1). More...
 
double * getPowerSpectrum (int len, double *input, double dt, conventionFlag normFlag, double *outputPtr, int threadInd=0)
 Creates the power spectrum in an array of doubles of length (len/2 + 1). More...
 
TGraph * getPowerSpectrumTGraph (int len, double *input, double dt, conventionFlag normFlag, bool dBScale, int threadInd=0)
 Creates a power spectrum TGraph from an array of doubles. More...
 
double * getFreqArray (int len, double dt)
 Get the array of frequencies to go with FFT output, determined by the tranform length and dt. More...
 
int getNumFreqs (int len)
 Get the number of frequencies from the number of samples. More...
 
int printListOfKeys ()
 Prints the list of keys of plans to stdout.
 
double * crossCorrelate (int len, double *v1, double *v2, int threadInd=0)
 Cross correlates the two input arrays. More...
 
double * crossCorrelate (int len, complex< double > *fft1, complex< double > *fft2, int threadInd=0)
 Cross correlates the two input arrays. More...
 
double * crossCorrelate (int len, complex< double > *fft1, complex< double > *fft2, double *output, int threadInd=0)
 Cross correlates the two input arrays. More...
 
int extendToPowerOfTwo (int len)
 Find the next highest power of two. More...
 
complex< double > * zeroPadFFT (complex< double > *fft, int numSamples, int numSamplesUpsampled)
 Zero padds FFTts,. More...
 
complex< double > * zeroPadFFT (complex< double > *fft, complex< double > *output, int numSamples, int numSamplesUpsampled)
 Zero padds FFTts,. More...
 
bool makeNewPlanIfNeeded (int len, int threadInd=0)
 Creates new fftw plan to handle 1D transforms of length len if they haven't been allocated already. More...
 
double * getRealArray (std::pair< Int_t, Int_t > key)
 Get the real array of the internal fftw memory. Do not delete this! More...
 

Detailed Description

My implementation of a wrapper for FFTW for use with ROOT thing.

Most functionality has been merged into FFTtools, except some of the threading options. Hopefully that will get done at some point in the future and this namespace can be done away with.

Function Documentation

double * FancyFFTs::crossCorrelate ( int  len,
double *  v1,
double *  v2,
int  threadInd = 0 
)

Cross correlates the two input arrays.

Parameters
lenis the length of both arrays, v1 and 2.
v1is the first input array.
v2is the second input array.
threadInduses a particular threads plans to do the ffts.
Returns
a pointer to an array of doubles containing the cross correlations.

Definition at line 541 of file FancyFFTs.cxx.

double * FancyFFTs::crossCorrelate ( int  len,
complex< double > *  fft1,
complex< double > *  fft2,
int  threadInd = 0 
)

Cross correlates the two input arrays.

Parameters
lenis the length of both arrays, v1 and 2.
fft1is the fft of the first input array.
fft2is the fft of the second input array.
threadInduses a particular threads plans to do the ffts.
Returns
a pointer to an array of doubles containing the cross correlations.

Definition at line 593 of file FancyFFTs.cxx.

double * FancyFFTs::crossCorrelate ( int  len,
complex< double > *  fft1,
complex< double > *  fft2,
double *  output,
int  threadInd = 0 
)

Cross correlates the two input arrays.

Parameters
lenis the length of the time domain input (not the length of the ffts).
fft1is the fft of the first input array.
fft2is the fft of the second input array.
outputis a pointer to copy the outputted cross correlations to.
threadInduses a particular threads plans to do the ffts.
Returns
a pointer to an array of doubles containing the cross correlations.

Definition at line 612 of file FancyFFTs.cxx.

complex< double > * FancyFFTs::doFFT ( int  len,
double *  input,
bool  copyOutputToNewArray,
int  threadInd = 0 
)

Does a forward fast fourier transform on a real input array.

Parameters
lenis the length of the input.
inputis a pointer to an array of doubles of length len.
copyOutputToNewArrayleave output in internal memory (false) or allocate new memory and copy (true).
threadInduses a particular threads plans to do the ffts.
Returns
a pointer to an array of complex<double>s containing the fft.

Definition at line 212 of file FancyFFTs.cxx.

complex< double > * FancyFFTs::doFFT ( int  len,
double *  input,
complex< double > *  output,
int  threadInd = 0 
)

Does a forward fast fourier transform on a real input array.

Parameters
lenis the length of the input.
inputis a pointer to an array of doubles of length len.
outputis a pointer to an array of complex<double> to copy the output to.
threadInduses a particular threads plans to do the ffts.
Returns
a pointer to an array of complex<double>s containing the fft.

Definition at line 228 of file FancyFFTs.cxx.

complex< double > * FancyFFTs::doFFT ( int  len,
double *  input,
complex< double > *  output,
bool  copyOutputToNewArray,
int  threadInd = 0 
)

Does a forward fast fourier transform on a real input array.

Parameters
lenis the length of the input.
inputis a pointer to an array of doubles of length len.
outputis a pointer to an array of complex<double> to copy the output to.
copyOutputToNewArrayleave output in internal memory (false) or allocate new memory and copy (true).
threadInduses a particular threads plans to do the ffts.
Returns
a pointer to an array of complex<double>s containing the fft.

Definition at line 245 of file FancyFFTs.cxx.

double * FancyFFTs::doInvFFT ( int  len,
complex< double > *  input,
bool  copyOutputToNewArray,
int  threadInd = 0 
)

Does an inverse fast fourier transform on an array of complex<double>s.

Parameters
lenis the length of the real output array.
inputis a pointer to an array of complex<double>s of length (len/2 +1).
copyOutputToNewArrayleave output in internal memory (false) or allocate new memory and copy (true).
threadInduses a particular threads plans to do the ffts.
Returns
a pointer to an array of doubles containing the (real) inverse FFT.

Definition at line 288 of file FancyFFTs.cxx.

double * FancyFFTs::doInvFFT ( int  len,
complex< double > *  input,
double *  output,
int  threadInd = 0 
)

Does an inverse fast fourier transform on an array of complex<double>s.

Parameters
lenis the length of the real output array.
inputis a pointer to an array of complex<double>s of length (len/2 +1).
outputis a pointer to an array of doubles to copy the output to.
threadInduses a particular threads plans to do the ffts.
Returns
a pointer to an array of doubles containing the (real) inverse FFT.

Definition at line 306 of file FancyFFTs.cxx.

double * FancyFFTs::doInvFFT ( int  len,
complex< double > *  input,
double *  output,
bool  copyOutputToNewArray,
int  threadInd = 0 
)

Does an inverse fast fourier transform on an array of complex<double>s.

Parameters
lenis the length of the real output array.
inputis a pointer to an array of complex<double>s of length (len/2 +1).
outputis a pointer to an array of doubles to copy the output to.
copyOutputToNewArrayleave output in internal memory (false) or allocate new memory and copy (true).
threadInduses a particular threads plans to do the ffts.
Returns
a pointer to an array of doubles containing the (real) inverse FFT.

Definition at line 325 of file FancyFFTs.cxx.

int FancyFFTs::extendToPowerOfTwo ( int  len)

Find the next highest power of two.

Parameters
lenis the number to find the next highest power of two.
Returns
the next highest power of two.

Definition at line 377 of file FancyFFTs.cxx.

double * FancyFFTs::getFreqArray ( int  len,
double  dt 
)

Get the array of frequencies to go with FFT output, determined by the tranform length and dt.

Parameters
lenis the length of the real fft input.
dtis the time between real input samples.
Returns
a pointer to an array of doubles containing the frequencies.

Definition at line 394 of file FancyFFTs.cxx.

int FancyFFTs::getNumFreqs ( int  len)

Get the number of frequencies from the number of samples.

Parameters
lenis the length of the real fft input.
Returns
the number of frequencies.

Definition at line 416 of file FancyFFTs.cxx.

double * FancyFFTs::getPowerSpectrum ( int  len,
double *  input,
double  dt,
FancyFFTs::conventionFlag  normFlag,
int  threadInd = 0 
)

Creates the power spectrum in an array of doubles of length (len/2 + 1).

Parameters
lenis the length of the input.
inputis a pointer to an array of doubles of length len.
dtis the time step between samples.
normFlagis a flag specifying how to normalize the output TGraph.
threadInduses a particular threads plans to do the ffts.
Returns
a pointer to the array containing the power spectrum.

Definition at line 77 of file FancyFFTs.cxx.

double * FancyFFTs::getPowerSpectrum ( int  len,
double *  input,
double  dt,
FancyFFTs::conventionFlag  normFlag,
double *  outputPtr,
int  threadInd = 0 
)

Creates the power spectrum in an array of doubles of length (len/2 + 1).

Parameters
lenis the length of the input.
inputis a pointer to an array of doubles of length len.
dtis the time step between samples.
normFlagis a flag specifying how to normalize the output TGraph.
threadInduses a particular threads plans to do the ffts.
outputPtrcan be used to direct FancyFFTs to copy the output into pre-allocatred memory.
Returns
a pointer to the array containing the power spectrum.

Definition at line 98 of file FancyFFTs.cxx.

TGraph * FancyFFTs::getPowerSpectrumTGraph ( int  len,
double *  input,
double  dt,
FancyFFTs::conventionFlag  normFlag,
bool  dBScale,
int  threadInd = 0 
)

Creates a power spectrum TGraph from an array of doubles.

Parameters
lenis the length of the input.
inputis a pointer to an array of doubles of length len.
dtis the time step between samples.
normFlagis a flag specifying how to normalize the output TGraph.
dBScalespecifies whether to return the TGraph in dB or linear scale.
threadIndspecifies the thread index of the fftw plans to use.
Returns
the power spectrum TGraph.

Definition at line 52 of file FancyFFTs.cxx.

double * FancyFFTs::getRealArray ( std::pair< Int_t, Int_t >  key)

Get the real array of the internal fftw memory. Do not delete this!

Parameters
keyis an std::pair of the real array length and the thread index of the plan.
Returns
a pointer to fftw's internal real array. DO NOT DELETE THIS!

Definition at line 673 of file FancyFFTs.cxx.

bool FancyFFTs::makeNewPlanIfNeeded ( int  len,
int  threadInd = 0 
)

Creates new fftw plan to handle 1D transforms of length len if they haven't been allocated already.

Parameters
lenis the length of the input.
threadIndis the index of the thread that needs an fftw plan.

Definition at line 19 of file FancyFFTs.cxx.

complex< double > * FancyFFTs::zeroPadFFT ( complex< double > *  fft,
int  numSamples,
int  numSamplesUpsampled 
)

Zero padds FFTts,.

Parameters
fftis the unpadded fft.
numSamplesis the length of the time domain of the fft (i.e. NOT the number of frequency bins)
numSamplesUpsampledis the length of the time domain of the padded fft (i.e. NOT the number of frequency bins)
Returns
the a pointer to an array of complex<doubles> containing the padded fft.

This is for doing interpolation in the time domain. Zero padding in the time/frequency domain is equivelent to interpolation in the time/frequency domain.

Definition at line 436 of file FancyFFTs.cxx.

complex< double > * FancyFFTs::zeroPadFFT ( complex< double > *  fft,
complex< double > *  output,
int  numSamples,
int  numSamplesUpsampled 
)

Zero padds FFTts,.

Parameters
fftis the unpadded fft.
numSamplesis the length of the time domain of the fft (i.e. NOT the number of frequency bins)
numSamplesUpsampledis the length of the time domain of the padded fft (i.e. NOT the number of frequency bins)
outputis where the padded fft should be copied to.
Returns
the a pointer to an array of complex<doubles> containing the padded fft.

This is for doing interpolation in the time domain. Zero padding in the time/frequency domain is equivelent to interpolation in the time/frequency domain.

Definition at line 457 of file FancyFFTs.cxx.