2022-08-07 19:13:45 +00:00
|
|
|
// 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"
|
|
|
|
|
|
|
|
/**
|
2022-10-04 07:27:27 +00:00
|
|
|
* \addtogroup dsp
|
|
|
|
* @{
|
2022-08-07 19:13:45 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
class Fft_impl;
|
|
|
|
|
|
|
|
/**
|
2022-10-04 07:48:32 +00:00
|
|
|
* @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.
|
2022-08-07 19:13:45 +00:00
|
|
|
*/
|
|
|
|
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
|
|
|
|
*
|
2022-09-03 18:59:14 +00:00
|
|
|
* @return nfft NFFT (lenght of the DFT transform)
|
2022-08-07 19:13:45 +00:00
|
|
|
*/
|
|
|
|
us nfft() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Compute the fft for a single channel of data.
|
|
|
|
*
|
|
|
|
* @param[in] timedata Input time data, should have size nfft
|
2022-09-03 18:59:14 +00:00
|
|
|
* @return Result complex vector
|
2022-08-07 19:13:45 +00:00
|
|
|
* */
|
|
|
|
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
|
|
|
|
*
|
2022-09-03 18:59:14 +00:00
|
|
|
* @param freqdata Frequency domain data
|
|
|
|
* @return timedata Time domain result
|
2022-08-07 19:13:45 +00:00
|
|
|
*/
|
|
|
|
dmat ifft(const cmat& freqdata);
|
|
|
|
|
2022-09-22 08:18:38 +00:00
|
|
|
/**
|
|
|
|
* @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();
|
|
|
|
|
2022-08-07 19:13:45 +00:00
|
|
|
};
|
2022-10-04 07:27:27 +00:00
|
|
|
|
|
|
|
/** @} */
|