PIFFTW now save all 3 plans, with fast flag PIFFTBase::calcHibert now normalized add -fexception for pifft.cpp
201 lines
6.7 KiB
C++
201 lines
6.7 KiB
C++
//! \~\file pifft.h
|
|
//! \~\ingroup Math
|
|
//! \~\ingroup FFTW
|
|
//! \~\brief
|
|
//! \~english FFT, IFFT and Hilbert transformations
|
|
//! \~russian БПФ, ОБПФ и преобразования Гильберта
|
|
/*
|
|
PIP - Platform Independent Primitives
|
|
Class for FFT, IFFT and Hilbert transformations
|
|
Andrey Bychkov work.a.b@yandex.ru, Ivan Pelipenko peri4ko@yandex.ru
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
//! \defgroup FFTW FFTW
|
|
//! \~\brief
|
|
//! \~english Optimized FFT support via libfftw3
|
|
//! \~russian Оптимизированный БПФ с помощью libfftw3
|
|
//!
|
|
//! \~\details
|
|
//! \~english \section cmake_module_FFTW Building with CMake
|
|
//! \~russian \section cmake_module_FFTW Сборка с использованием CMake
|
|
//!
|
|
//! \~\code
|
|
//! find_package(PIP REQUIRED)
|
|
//! target_link_libraries([target] PIP::FFTW)
|
|
//! \endcode
|
|
//!
|
|
//! \~english \par Common
|
|
//! \~russian \par Общее
|
|
//!
|
|
//! \~english
|
|
//! These files provides FFT using [libfftw3](https://fftw.org/)
|
|
//!
|
|
//! \~russian
|
|
//! Эти файлы обеспечивают БПФ с использованием [libfftw3](https://fftw.org/)
|
|
//!
|
|
//! \~\authors
|
|
//! \~english
|
|
//! Ivan Pelipenko peri4ko@yandex.ru;
|
|
//! Andrey Bychkov work.a.b@yandex.ru;
|
|
//! \~russian
|
|
//! Иван Пелипенко peri4ko@yandex.ru;
|
|
//! Андрей Бычков work.a.b@yandex.ru;
|
|
//!
|
|
|
|
#ifndef PIFFT_H
|
|
#define PIFFT_H
|
|
|
|
#include "pifftbase.h"
|
|
#include "pip_export.h"
|
|
#include "pip_fftw_export.h"
|
|
|
|
#ifdef PIP_HAS_FFT
|
|
|
|
|
|
//! \~\ingroup Math
|
|
//! \~\brief
|
|
//! \~english Thin wrapper over PocketFFT library for a selected scalar type.
|
|
//! \~russian Тонкая обертка над библиотекой PocketFFT для выбранного скалярного типа.
|
|
template<typename T>
|
|
class PIP_EXPORT PIFFT: public PIFFTBase<T> {
|
|
public:
|
|
const PIVector<complex<T>> & calcFFT(const PIVector<complex<T>> & in) override;
|
|
const PIVector<complex<T>> & calcFFT(const PIVector<T> & in) override;
|
|
const PIVector<complex<T>> & calcFFTinverse(const PIVector<complex<T>> & in) override;
|
|
};
|
|
|
|
|
|
template<>
|
|
class PIP_EXPORT PIFFT<float>: public PIFFTBase<float> {
|
|
public:
|
|
const PIVector<complex<float>> & calcFFT(const PIVector<complex<float>> & in) override;
|
|
const PIVector<complex<float>> & calcFFT(const PIVector<float> & in) override;
|
|
const PIVector<complex<float>> & calcFFTinverse(const PIVector<complex<float>> & in) override;
|
|
|
|
private:
|
|
PRIVATE_DECLARATION(PIP_EXPORT)
|
|
};
|
|
|
|
|
|
template<>
|
|
class PIP_EXPORT PIFFT<double>: public PIFFTBase<double> {
|
|
public:
|
|
const PIVector<complex<double>> & calcFFT(const PIVector<complex<double>> & in) override;
|
|
const PIVector<complex<double>> & calcFFT(const PIVector<double> & in) override;
|
|
const PIVector<complex<double>> & calcFFTinverse(const PIVector<complex<double>> & in) override;
|
|
|
|
private:
|
|
PRIVATE_DECLARATION(PIP_EXPORT)
|
|
};
|
|
|
|
|
|
template<>
|
|
class PIP_EXPORT PIFFT<ldouble>: public PIFFTBase<ldouble> {
|
|
public:
|
|
const PIVector<complex<ldouble>> & calcFFT(const PIVector<complex<ldouble>> & in) override;
|
|
const PIVector<complex<ldouble>> & calcFFT(const PIVector<ldouble> & in) override;
|
|
const PIVector<complex<ldouble>> & calcFFTinverse(const PIVector<complex<ldouble>> & in) override;
|
|
|
|
private:
|
|
PRIVATE_DECLARATION(PIP_EXPORT)
|
|
};
|
|
|
|
|
|
//! \~english Single-precision FFT wrapper.
|
|
//! \~russian Обертка FFT одинарной точности.
|
|
typedef PIFFT<float> PIFFTf;
|
|
|
|
//! \~english Double-precision FFT wrapper.
|
|
//! \~russian Обертка FFT двойной точности.
|
|
typedef PIFFT<double> PIFFTd;
|
|
|
|
//! \~english Extended-precision FFT wrapper.
|
|
//! \~russian Обертка FFT расширенной точности.
|
|
typedef PIFFT<ldouble> PIFFTld;
|
|
|
|
|
|
//! \~\ingroup Math
|
|
//! \~\ingroup FFTW
|
|
//! \~\brief
|
|
//! \~english Thin wrapper over libfftw3 plans for a selected scalar type.
|
|
//! \~russian Тонкая обертка над планами libfftw3 для выбранного скалярного типа.
|
|
template<typename T>
|
|
class PIP_FFTW_EXPORT PIFFTW: public PIFFTBase<T> {
|
|
public:
|
|
const PIVector<complex<T>> & calcFFT(const PIVector<complex<T>> & in) override;
|
|
const PIVector<complex<T>> & calcFFT(const PIVector<T> & in) override;
|
|
const PIVector<complex<T>> & calcFFTinverse(const PIVector<complex<T>> & in) override;
|
|
bool prepareForSize(size_t count) override;
|
|
|
|
private:
|
|
};
|
|
|
|
|
|
template<>
|
|
class PIP_FFTW_EXPORT PIFFTW<float>: public PIFFTBase<float> {
|
|
public:
|
|
const PIVector<complex<float>> & calcFFT(const PIVector<complex<float>> & in) override;
|
|
const PIVector<complex<float>> & calcFFT(const PIVector<float> & in) override;
|
|
const PIVector<complex<float>> & calcFFTinverse(const PIVector<complex<float>> & in) override;
|
|
bool prepareForSize(size_t count) override;
|
|
|
|
private:
|
|
PRIVATE_DECLARATION(PIP_FFTW_EXPORT)
|
|
};
|
|
|
|
|
|
template<>
|
|
class PIP_FFTW_EXPORT PIFFTW<double>: public PIFFTBase<double> {
|
|
public:
|
|
const PIVector<complex<double>> & calcFFT(const PIVector<complex<double>> & in) override;
|
|
const PIVector<complex<double>> & calcFFT(const PIVector<double> & in) override;
|
|
const PIVector<complex<double>> & calcFFTinverse(const PIVector<complex<double>> & in) override;
|
|
bool prepareForSize(size_t count) override;
|
|
|
|
private:
|
|
PRIVATE_DECLARATION(PIP_FFTW_EXPORT)
|
|
};
|
|
|
|
|
|
template<>
|
|
class PIP_FFTW_EXPORT PIFFTW<ldouble>: public PIFFTBase<ldouble> {
|
|
public:
|
|
const PIVector<complex<ldouble>> & calcFFT(const PIVector<complex<ldouble>> & in) override;
|
|
const PIVector<complex<ldouble>> & calcFFT(const PIVector<ldouble> & in) override;
|
|
const PIVector<complex<ldouble>> & calcFFTinverse(const PIVector<complex<ldouble>> & in) override;
|
|
bool prepareForSize(size_t count) override;
|
|
|
|
private:
|
|
PRIVATE_DECLARATION(PIP_FFTW_EXPORT)
|
|
};
|
|
|
|
|
|
//! \~english Single-precision FFTW wrapper.
|
|
//! \~russian Обертка FFTW одинарной точности.
|
|
typedef PIFFTW<float> PIFFTWf;
|
|
|
|
//! \~english Double-precision FFTW wrapper.
|
|
//! \~russian Обертка FFTW двойной точности.
|
|
typedef PIFFTW<double> PIFFTWd;
|
|
|
|
//! \~english Extended-precision FFTW wrapper.
|
|
//! \~russian Обертка FFTW расширенной точности.
|
|
typedef PIFFTW<ldouble> PIFFTWld;
|
|
|
|
|
|
#endif // PIP_HAS_FFT
|
|
|
|
#endif // PIFFT_H
|