Commit 1307970b authored by Martin Reinecke's avatar Martin Reinecke
Browse files

portability fixes and minor tweaks

parent de0d1311
...@@ -4,6 +4,9 @@ pypocketfft ...@@ -4,6 +4,9 @@ pypocketfft
This package provides Fast Fourier and Hartley transforms with a simple This package provides Fast Fourier and Hartley transforms with a simple
Python interface. Python interface.
The central algorithms are derived from Paul Swarztrauber's FFTPACK code
(http://www.netlib.org/fftpack).
Features Features
-------- --------
- supports fully complex and half-complex (i.e. complex-to-real and - supports fully complex and half-complex (i.e. complex-to-real and
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <cmath> #include <cmath>
#include <cstring> #include <cstring>
#include <cstdlib>
#include <algorithm> #include <algorithm>
#include <iostream> #include <iostream>
#include <memory> #include <memory>
...@@ -28,10 +29,10 @@ ...@@ -28,10 +29,10 @@
#define restrict #define restrict
#endif #endif
using namespace std;
namespace pocketfft_private { namespace pocketfft_private {
using namespace std;
template<typename T> struct arr template<typename T> struct arr
{ {
private: private:
...@@ -39,7 +40,17 @@ template<typename T> struct arr ...@@ -39,7 +40,17 @@ template<typename T> struct arr
size_t sz; size_t sz;
static T *ralloc(size_t num) static T *ralloc(size_t num)
{ return (T *)aligned_alloc(64,num*sizeof(T)); } {
#if 0
return (T *)aligned_alloc(64,num*sizeof(T));
#else
void *res(nullptr);
if (num>0)
if (posix_memalign(&res, 64, num*sizeof(T))!=0)
throw bad_alloc();
return reinterpret_cast<T *>(res);
#endif
}
static void dealloc(T *ptr) static void dealloc(T *ptr)
{ free(ptr); } { free(ptr); }
...@@ -877,10 +888,10 @@ template<bool bwd, typename T> NOINLINE void pass_all(T c[], T0 fact) ...@@ -877,10 +888,10 @@ template<bool bwd, typename T> NOINLINE void pass_all(T c[], T0 fact)
#undef CH #undef CH
public: public:
template<typename T> NOINLINE void forward(T c[], T0 fct) template<typename T> void forward(T c[], T0 fct)
{ pass_all<false>(c, fct); } { pass_all<false>(c, fct); }
template<typename T> NOINLINE void backward(T c[], T0 fct) template<typename T> void backward(T c[], T0 fct)
{ pass_all<true>(c, fct); } { pass_all<true>(c, fct); }
private: private:
...@@ -1831,10 +1842,10 @@ template<typename T0> class fftblue ...@@ -1831,10 +1842,10 @@ template<typename T0> class fftblue
plan.forward(bkf,1.); plan.forward(bkf,1.);
} }
template<typename T> NOINLINE void backward(cmplx<T> c[], T0 fct) template<typename T> void backward(cmplx<T> c[], T0 fct)
{ fft<true>(c,fct); } { fft<true>(c,fct); }
template<typename T> NOINLINE void forward(cmplx<T> c[], T0 fct) template<typename T> void forward(cmplx<T> c[], T0 fct)
{ fft<false>(c,fct); } { fft<false>(c,fct); }
template<typename T> NOINLINE void backward_r(T c[], T0 fct) template<typename T> NOINLINE void backward_r(T c[], T0 fct)
...@@ -1891,13 +1902,13 @@ template<typename T0> class pocketfft_c ...@@ -1891,13 +1902,13 @@ template<typename T0> class pocketfft_c
packplan=unique_ptr<cfftp<T0>>(new cfftp<T0>(length)); packplan=unique_ptr<cfftp<T0>>(new cfftp<T0>(length));
} }
template<typename T> NOINLINE void backward(T c[], T0 fct) template<typename T> void backward(T c[], T0 fct)
{ {
packplan ? packplan->backward((cmplx<T> *)c,fct) packplan ? packplan->backward((cmplx<T> *)c,fct)
: blueplan->backward((cmplx<T> *)c,fct); : blueplan->backward((cmplx<T> *)c,fct);
} }
template<typename T> NOINLINE void forward(T c[], T0 fct) template<typename T> void forward(T c[], T0 fct)
{ {
packplan ? packplan->forward((cmplx<T> *)c,fct) packplan ? packplan->forward((cmplx<T> *)c,fct)
: blueplan->forward((cmplx<T> *)c,fct); : blueplan->forward((cmplx<T> *)c,fct);
...@@ -1936,13 +1947,13 @@ template<typename T0> class pocketfft_r ...@@ -1936,13 +1947,13 @@ template<typename T0> class pocketfft_r
packplan=unique_ptr<rfftp<T0>>(new rfftp<T0>(length)); packplan=unique_ptr<rfftp<T0>>(new rfftp<T0>(length));
} }
template<typename T> NOINLINE void backward(T c[], T0 fct) template<typename T> void backward(T c[], T0 fct)
{ {
packplan ? packplan->backward(c,fct) packplan ? packplan->backward(c,fct)
: blueplan->backward_r(c,fct); : blueplan->backward_r(c,fct);
} }
template<typename T> NOINLINE void forward(T c[], T0 fct) template<typename T> void forward(T c[], T0 fct)
{ {
packplan ? packplan->forward(c,fct) packplan ? packplan->forward(c,fct)
: blueplan->forward_r(c,fct); : blueplan->forward_r(c,fct);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment