/*! \file pifft.h * \brief Class for FFT, IFFT and Hilbert transformations */ /* PIP - Platform Independent Primitives Class for FFT, IFFT and Hilbert transformations Copyright (C) 2016 Ivan Pelipenko peri4ko@gmail.com, Andrey Bychkov work.a.b@yandex.ru This program is free software: you can redistribute it and/or modify it under the terms of the GNU 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #ifndef PIFFT_H #define PIFFT_H #include "pimathbase.h" class PIP_EXPORT PIFFT_double { public: PIFFT_double(); PIVector * calcFFT(const PIVector &val); PIVector * calcFFT(const PIVector &val); PIVector * calcFFTinverse(const PIVector &val); PIVector * calcHilbert(const PIVector &val); PIVector getAmplitude(); private: PIVector result; typedef ptrdiff_t ae_int_t; struct ftplan { PIVector plan; PIVector precomputed; PIVector tmpbuf; PIVector stackbuf; }; ftplan curplan; void fftc1d(const PIVector &a, uint n); void fftc1r(const PIVector &a, uint n); void fftc1dinv(const PIVector &a, uint n); void createPlan(uint n); void ftbasegeneratecomplexfftplan(uint n, ftplan *plan); void ftbase_ftbasegenerateplanrec(int n, int tasktype, ftplan *plan, int *plansize, int *precomputedsize, int *planarraysize, int *tmpmemsize, int *stackmemsize, ae_int_t stackptr, int debugi=0); void ftbase_ftbaseprecomputeplanrec(ftplan *plan, int entryoffset, ae_int_t stackptr); void ftbasefactorize(int n, int *n1, int *n2); void ftbase_ftbasefindsmoothrec(int n, int seed, int leastfactor, int *best); int ftbasefindsmooth(int n); void ftbaseexecuteplan(PIVector *a, int aoffset, int n, ftplan *plan); void ftbaseexecuteplanrec(PIVector *a, int aoffset, ftplan *plan, int entryoffset, ae_int_t stackptr); void ftbase_internalcomplexlintranspose(PIVector *a, int m, int n, int astart, PIVector *buf); void ftbase_ffticltrec(PIVector *a, int astart, int astride, PIVector *b, int bstart, int bstride, int m, int n); void ftbase_internalreallintranspose(PIVector *a, int m, int n, int astart, PIVector *buf); void ftbase_fftirltrec(PIVector *a, int astart, int astride, PIVector *b, int bstart, int bstride, int m, int n); void ftbase_ffttwcalc(PIVector *a, int aoffset, int n1, int n2); }; class PIP_EXPORT PIFFT_float { public: PIFFT_float(); PIVector * calcFFT(const PIVector &val); PIVector * calcFFT(const PIVector &val); PIVector * calcFFTinverse(const PIVector &val); PIVector * calcHilbert(const PIVector &val); PIVector getAmplitude(); private: PIVector result; typedef ptrdiff_t ae_int_t; struct ftplan { PIVector plan; PIVector precomputed; PIVector tmpbuf; PIVector stackbuf; }; ftplan curplan; void fftc1d(const PIVector &a, uint n); void fftc1r(const PIVector &a, uint n); void fftc1dinv(const PIVector &a, uint n); void createPlan(uint n); void ftbasegeneratecomplexfftplan(uint n, ftplan *plan); void ftbase_ftbasegenerateplanrec(int n, int tasktype, ftplan *plan, int *plansize, int *precomputedsize, int *planarraysize, int *tmpmemsize, int *stackmemsize, ae_int_t stackptr, int debugi=0); void ftbase_ftbaseprecomputeplanrec(ftplan *plan, int entryoffset, ae_int_t stackptr); void ftbasefactorize(int n, int *n1, int *n2); void ftbase_ftbasefindsmoothrec(int n, int seed, int leastfactor, int *best); int ftbasefindsmooth(int n); void ftbaseexecuteplan(PIVector *a, int aoffset, int n, ftplan *plan); void ftbaseexecuteplanrec(PIVector *a, int aoffset, ftplan *plan, int entryoffset, ae_int_t stackptr); void ftbase_internalcomplexlintranspose(PIVector *a, int m, int n, int astart, PIVector *buf); void ftbase_ffticltrec(PIVector *a, int astart, int astride, PIVector *b, int bstart, int bstride, int m, int n); void ftbase_internalreallintranspose(PIVector *a, int m, int n, int astart, PIVector *buf); void ftbase_fftirltrec(PIVector *a, int astart, int astride, PIVector *b, int bstart, int bstride, int m, int n); void ftbase_ffttwcalc(PIVector *a, int aoffset, int n1, int n2); }; typedef PIFFT_double PIFFT; typedef PIFFT_double PIFFTd; typedef PIFFT_float PIFFTf; #endif // PIFFT_H