lasp/cpp_src/dsp/lasp_fft.h

100 lines
2.3 KiB
C++

// lasp_fft.h
//
// Author: J.A. de Jong - ASCEE
//
// Description: FFT class
// Interface to the FFT library, multiple channel FFT's
//////////////////////////////////////////////////////////////////////
#pragma once
#include <memory>
#include "lasp_mathtypes.h"
/**
* \addtogroup dsp
* @{
*/
class Fft_impl;
/**
* @brief Perform forward FFT's on real time data. Computes single-sided spectra,
* equivalent to Numpy's rfft and irfft functions. But then faster as it can
* use a fast FFT backend, such as FFTW.
*/
class Fft {
std::unique_ptr<Fft_impl> _impl;
public:
/**
* @brief Initialize FFT
*
* @param nfft The length of nfft
*/
Fft(const us nfft);
~Fft();
Fft(const Fft&) = delete;
Fft& operator=(const Fft&) = delete;
/**
* @brief Return nfft
*
* @return nfft NFFT (lenght of the DFT transform)
*/
us nfft() const;
/**
* Compute the fft for a single channel of data.
*
* @param[in] timedata Input time data, should have size nfft
* @return Result complex vector
* */
vc fft(const vd& timedata);
/**
* Compute the fft of the data matrix, first axis is assumed to be
* the time axis.
*
* @param[in] timedata Input time data, should have size nfft. First axis
* is time, second axis is channel
* @returns Result complex array
*/
cmat fft(const dmat& timedata);
/**
* Perform inverse fft on a single channel.
*
* @param[in] freqdata Frequency domain input data, to be iFft'th. Should
* have size nfft/2+1
* @returns timedata: iFft't data, size nfft.
*/
vd ifft(const vc& freqdata);
/**
* Perform inverse FFT
*
* @param freqdata Frequency domain data
* @return timedata Time domain result
*/
dmat ifft(const cmat& freqdata);
/**
* @brief Load FFT wisdom from a wisdom string. Function does nothing if
* FFT backend is not FFTW
*
* @param wisdom Wisdom string content.
*/
static void load_fft_wisdom(const std::string& wisdom);
/**
* @brief Return a string containing FFT wisdom storage. String is empty
* for backend != FFTW
*
* @return FFT wisdom string
*/
static std::string store_fft_wisdom();
};
/** @} */