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

portability fixes and minor tweaks

parent de0d1311
......@@ -4,6 +4,9 @@ pypocketfft
This package provides Fast Fourier and Hartley transforms with a simple
Python interface.
The central algorithms are derived from Paul Swarztrauber's FFTPACK code
(http://www.netlib.org/fftpack).
Features
--------
- supports fully complex and half-complex (i.e. complex-to-real and
......
......@@ -12,6 +12,7 @@
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <memory>
......@@ -28,10 +29,10 @@
#define restrict
#endif
using namespace std;
namespace pocketfft_private {
using namespace std;
template<typename T> struct arr
{
private:
......@@ -39,7 +40,17 @@ template<typename T> struct arr
size_t sz;
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)
{ free(ptr); }
......@@ -877,10 +888,10 @@ template<bool bwd, typename T> NOINLINE void pass_all(T c[], T0 fact)
#undef CH
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); }
template<typename T> NOINLINE void backward(T c[], T0 fct)
template<typename T> void backward(T c[], T0 fct)
{ pass_all<true>(c, fct); }
private:
......@@ -1831,10 +1842,10 @@ template<typename T0> class fftblue
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); }
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); }
template<typename T> NOINLINE void backward_r(T c[], T0 fct)
......@@ -1891,13 +1902,13 @@ template<typename T0> class pocketfft_c
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)
: 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)
: blueplan->forward((cmplx<T> *)c,fct);
......@@ -1936,13 +1947,13 @@ template<typename T0> class pocketfft_r
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)
: 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)
: 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