git-svn-id: svn://db.shs.com.ru/pip@326 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -35,6 +35,7 @@ option(ICU "Unicode support" 1)
|
|||||||
option(USB "USB support" 0)
|
option(USB "USB support" 0)
|
||||||
option(STL "Building with STL containers" 0)
|
option(STL "Building with STL containers" 0)
|
||||||
option(CRYPT "Crypt support" 0)
|
option(CRYPT "Crypt support" 0)
|
||||||
|
option(FFTW "fftw3 support for PIFFT" 1)
|
||||||
option(INTROSPECTION_CONTAINERS "Build with containers introspection" 0)
|
option(INTROSPECTION_CONTAINERS "Build with containers introspection" 0)
|
||||||
option(INTROSPECTION_THREADS "Build with threads introspection" 0)
|
option(INTROSPECTION_THREADS "Build with threads introspection" 0)
|
||||||
option(LIB "System install" 1)
|
option(LIB "System install" 1)
|
||||||
@@ -142,6 +143,16 @@ else ()
|
|||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
|
||||||
|
# Check if PIP support fftw3 for PIFFT using in math module
|
||||||
|
if (FFTW)
|
||||||
|
message(STATUS "Building with fftw3 support")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPIP_FFTW")
|
||||||
|
list(APPEND LIBS fftw3-3 fftw3f-3 fftw3l-3)
|
||||||
|
else ()
|
||||||
|
message(STATUS "Building without fftw3 support")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
|
||||||
# Check if PIP should be built with containers introspection
|
# Check if PIP should be built with containers introspection
|
||||||
if (INTROSPECTION_CONTAINERS)
|
if (INTROSPECTION_CONTAINERS)
|
||||||
message(STATUS "Building with containers introspection")
|
message(STATUS "Building with containers introspection")
|
||||||
|
|||||||
@@ -121,4 +121,64 @@ typedef PIFFT_double PIFFT;
|
|||||||
typedef PIFFT_double PIFFTd;
|
typedef PIFFT_double PIFFTd;
|
||||||
typedef PIFFT_float PIFFTf;
|
typedef PIFFT_float PIFFTf;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// fftw3 realisation
|
||||||
|
#ifdef PIP_FFTW
|
||||||
|
#include <complex.h>
|
||||||
|
#include "fftw3.h"
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
class PIP_EXPORT PIFFTW
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const PIVector<complex<T> > & calcFFT(const PIVector<complex<T> > &in) {
|
||||||
|
result.resize(in.size());
|
||||||
|
p = fftw_plan_dft_1d(in.size_s(), (fftw_complex *)in.data(), (fftw_complex *)result.data(), FFTW_FORWARD, FFTW_ESTIMATE);
|
||||||
|
fftw_execute(p);
|
||||||
|
fftw_destroy_plan(p);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
const PIVector<complex<T> > & calcFFT(const PIVector<T> &in) {
|
||||||
|
result.resize(in.size());
|
||||||
|
p = fftw_plan_dft_r2c_1d(in.size_s(), (double *)in.data(), (fftw_complex *)result.data(), FFTW_ESTIMATE);
|
||||||
|
fftw_execute(p);
|
||||||
|
fftw_destroy_plan(p);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
const PIVector<complex<T> > & calcFFTinverse(const PIVector<complex<T> > &in) {
|
||||||
|
result.resize(in.size());
|
||||||
|
p = fftw_plan_dft_1d(in.size_s(), (fftw_complex *)in.data(), (fftw_complex *)result.data(), FFTW_BACKWARD, FFTW_ESTIMATE);
|
||||||
|
fftw_execute(p);
|
||||||
|
fftw_destroy_plan(p);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum FFT_Operation {fo_real, fo_complex, fo_inverse};
|
||||||
|
|
||||||
|
void preparePlan(int size, FFT_Operation op) {
|
||||||
|
PIVector<complex<T> > in(size), out(size);
|
||||||
|
PIVector<T> inr(size);
|
||||||
|
switch (op) {
|
||||||
|
case fo_real:
|
||||||
|
p = fftw_plan_dft_r2c_1d(in.size_s(), (double *)inr.data(), (fftw_complex *)out.data(), FFTW_MEASURE);
|
||||||
|
break;
|
||||||
|
case fo_complex:
|
||||||
|
p = fftw_plan_dft_1d(in.size_s(), (fftw_complex *)in.data(), (fftw_complex *)out.data(), FFTW_FORWARD, FFTW_MEASURE);
|
||||||
|
break;
|
||||||
|
case fo_inverse:
|
||||||
|
p = fftw_plan_dft_1d(in.size_s(), (fftw_complex *)in.data(), (fftw_complex *)out.data(), FFTW_BACKWARD, FFTW_MEASURE);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
PIVector<complex<T> > result;
|
||||||
|
fftw_plan p;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef PIFFTW<double> PIFFTWd;
|
||||||
|
|
||||||
|
#endif // PIP_FFTW
|
||||||
|
|
||||||
#endif // PIFFT_H
|
#endif // PIFFT_H
|
||||||
|
|||||||
Reference in New Issue
Block a user