diff --git a/pocketfft_hdronly.h b/pocketfft_hdronly.h index 1a193939e1fa3cca93facdaeab21ef663853d939..4f7e02cc1d9d2e964b1ae468ff98d585fbce7f39 100644 --- a/pocketfft_hdronly.h +++ b/pocketfft_hdronly.h @@ -438,6 +438,7 @@ template class sincos_2pibyn { private: using Thigh = typename conditional<(sizeof(T)>sizeof(double)), T, double>::type; + size_t sz; arr> data; POCKETFFT_NOINLINE void calc_first_octant(size_t den, @@ -474,8 +475,8 @@ template class sincos_2pibyn void calc_first_quadrant(size_t n, cmplx * POCKETFFT_RESTRICT res) { - cmplx * POCKETFFT_RESTRICT p = res+n/2; // n is always even here - calc_first_octant(n<<1, p); + arr> p(n/2); // n is always even here + calc_first_octant(n<<1, p.data()); size_t ndone=(n+2)>>2; size_t i=0, idx1=0, idx2=ndone-1; for (; i+1 class sincos_2pibyn void calc_first_half(size_t n, cmplx * POCKETFFT_RESTRICT res) { int ndone=int(n+1)>>1; - cmplx * p = res+(n-1)/2; // n is always odd here - calc_first_octant(n<<2, p); + arr> p((n+1)/2); // n is always odd here + calc_first_octant(n<<2, p.data()); int i4=0, in=int(n), i=0; for (; i4<=in-i4; ++i, i4+=4) // octant 0 res[i] = p[i4]; @@ -522,16 +523,7 @@ template class sincos_2pibyn else for (size_t i=1, j=half-1; 2*i * POCKETFFT_RESTRICT res) - { - if ((n&1)==0) - for (size_t i=0; i * POCKETFFT_RESTRICT res) @@ -552,14 +544,18 @@ template class sincos_2pibyn } public: - POCKETFFT_NOINLINE sincos_2pibyn(size_t n, bool half) - : data(n) + POCKETFFT_NOINLINE sincos_2pibyn(size_t n) + : sz(n), data(n/2+1) + { sincos_2pibyn_half(n, data.data()); } + + cmplx operator[](size_t idx) const { - sincos_2pibyn_half(n, data.data()); - if (!half) fill_second_half(n, data.data()); + if (idx operator[](size_t idx) const { return data[idx]; } }; struct util // hack to avoid duplicate symbols @@ -1613,7 +1609,7 @@ template void pass_all(T c[], T0 fct) const void comp_twiddle() { - sincos_2pibyn twiddle(length, false); + sincos_2pibyn twiddle(length); size_t l1=1; size_t memofs=0; for (size_t k=0; k void radbg(size_t ido, size_t ip, size_t l1, void comp_twiddle() { - sincos_2pibyn twid(length, true); + sincos_2pibyn twid(length); size_t l1=1; T0 *ptr=mem.data(); for (size_t k=0; k class fftblue bk(mem.data()), bkf(mem.data()+n) { /* initialize b_k */ - sincos_2pibyn tmp(2*n, false); + sincos_2pibyn tmp(2*n); bk[0].Set(1, 0); size_t coeff=0;