1 #ifndef jb_fftw_traits_hpp 2 #define jb_fftw_traits_hpp 21 template <
typename precision_t>
50 return ::fftw_malloc(n);
73 fftw_plan_type
const p, fftw_complex_type
const* in,
74 fftw_complex_type* out) {
75 ::fftw_execute_dft(p, const_cast<fftw_complex_type*>(in), out);
89 fftw_plan_type
const p, precision_type
const* in,
90 fftw_complex_type* out) {
91 ::fftw_execute_dft_r2c(p, const_cast<precision_type*>(in), out);
105 fftw_plan_type
const p, fftw_complex_type
const* in,
106 precision_type* out) {
107 ::fftw_execute_dft_c2r(p, const_cast<fftw_complex_type*>(in), out);
121 std::size_t
size, fftw_complex_type
const* in, fftw_complex_type* out,
123 return ::fftw_plan_dft_1d(
124 size, const_cast<fftw_complex_type*>(in), out, FFTW_FORWARD, flags);
138 std::size_t
size, fftw_complex_type
const* in, fftw_complex_type* out,
140 return ::fftw_plan_dft_1d(
141 size, const_cast<fftw_complex_type*>(in), out, FFTW_BACKWARD, flags);
155 std::size_t
size, precision_type
const* in, fftw_complex_type* out,
157 return ::fftw_plan_dft_r2c_1d(
158 size, const_cast<precision_type*>(in), out, flags);
172 std::size_t
size, fftw_complex_type
const* in, precision_type* out,
174 return ::fftw_plan_dft_c2r_1d(
175 size, const_cast<fftw_complex_type*>(in), out, flags);
190 int howmany, std::size_t
size, fftw_complex_type
const* in,
191 fftw_complex_type* out,
int flags) {
193 int const n[rank] = {
static_cast<int>(
size)};
194 int const istride = 1;
195 int const ostride = 1;
196 int const* inembed =
nullptr;
197 int const* onembed =
nullptr;
198 int const idist = n[0];
199 int const odist = n[0];
200 return ::fftw_plan_many_dft(
201 rank, n, howmany, const_cast<fftw_complex_type*>(in), inembed, istride,
202 idist, out, onembed, ostride, odist, FFTW_FORWARD, flags);
217 int howmany, std::size_t
size, fftw_complex_type
const* in,
218 fftw_complex_type* out,
int flags) {
220 int const n[rank] = {
static_cast<int>(
size)};
221 int const istride = 1;
222 int const ostride = 1;
223 int const* inembed =
nullptr;
224 int const* onembed =
nullptr;
225 int const idist = n[0];
226 int const odist = n[0];
227 return ::fftw_plan_many_dft(
228 rank, n, howmany, const_cast<fftw_complex_type*>(in), inembed, istride,
229 idist, out, onembed, ostride, odist, FFTW_BACKWARD, flags);
244 int howmany, std::size_t
size, precision_type
const* in,
245 fftw_complex_type* out,
unsigned flags) {
247 int const n[rank] = {
static_cast<int>(
size)};
248 int const istride = 1;
249 int const ostride = 1;
250 int const* inembed =
nullptr;
251 int const* onembed =
nullptr;
252 int const idist = n[0];
253 int const odist = n[0];
254 return ::fftw_plan_many_dft_r2c(
255 rank, n, howmany, const_cast<precision_type*>(in), inembed, istride,
256 idist, out, onembed, ostride, odist, flags);
271 int howmany, std::size_t
size, fftw_complex_type
const* in,
272 precision_type* out,
int flags) {
274 int const n[rank] = {
static_cast<int>(
size)};
275 int const istride = 1;
276 int const ostride = 1;
277 int const* inembed =
nullptr;
278 int const* onembed =
nullptr;
279 int const idist = n[0];
280 int const odist = n[0];
281 return ::fftw_plan_many_dft_c2r(
282 rank, n, howmany, const_cast<fftw_complex_type*>(in), inembed, istride,
283 idist, out, onembed, ostride, odist, flags);
292 ::fftw_destroy_plan(p);
322 return ::fftwf_malloc(n);
331 ::fftwf_free(buffer);
345 fftw_plan_type
const p, fftw_complex_type
const* in,
346 fftw_complex_type* out) {
347 ::fftwf_execute_dft(p, const_cast<fftw_complex_type*>(in), out);
361 fftw_plan_type
const p, precision_type
const* in,
362 fftw_complex_type* out) {
363 ::fftwf_execute_dft_r2c(p, const_cast<precision_type*>(in), out);
377 fftw_plan_type
const p, fftw_complex_type
const* in,
378 precision_type* out) {
379 ::fftwf_execute_dft_c2r(p, const_cast<fftw_complex_type*>(in), out);
393 std::size_t
size, fftw_complex_type
const* in, fftw_complex_type* out,
395 return ::fftwf_plan_dft_1d(
396 size, const_cast<fftw_complex_type*>(in), out, FFTW_FORWARD, flags);
410 std::size_t
size, fftw_complex_type
const* in, fftw_complex_type* out,
412 return ::fftwf_plan_dft_1d(
413 size, const_cast<fftw_complex_type*>(in), out, FFTW_BACKWARD, flags);
427 std::size_t
size, precision_type
const* in, fftw_complex_type* out,
429 return ::fftwf_plan_dft_r2c_1d(
430 size, const_cast<precision_type*>(in), out, flags);
444 std::size_t
size, fftw_complex_type
const* in, precision_type* out,
446 return ::fftwf_plan_dft_c2r_1d(
447 size, const_cast<fftw_complex_type*>(in), out, flags);
462 int howmany, std::size_t
size, fftw_complex_type
const* in,
463 fftw_complex_type* out,
int flags) {
465 int const n[rank] = {
static_cast<int>(
size)};
466 int const istride = 1;
467 int const ostride = 1;
468 int const* inembed =
nullptr;
469 int const* onembed =
nullptr;
470 int const idist = n[0];
471 int const odist = n[0];
472 return ::fftwf_plan_many_dft(
473 rank, n, howmany, const_cast<fftw_complex_type*>(in), inembed, istride,
474 idist, out, onembed, ostride, odist, FFTW_FORWARD, flags);
489 int howmany, std::size_t
size, fftw_complex_type
const* in,
490 fftw_complex_type* out,
int flags) {
492 int const n[rank] = {
static_cast<int>(
size)};
493 int const istride = 1;
494 int const ostride = 1;
495 int const* inembed =
nullptr;
496 int const* onembed =
nullptr;
497 int const idist = n[0];
498 int const odist = n[0];
499 return ::fftwf_plan_many_dft(
500 rank, n, howmany, const_cast<fftw_complex_type*>(in), inembed, istride,
501 idist, out, onembed, ostride, odist, FFTW_BACKWARD, flags);
516 int howmany, std::size_t
size, precision_type
const* in,
517 fftw_complex_type* out,
unsigned flags) {
519 int const n[rank] = {
static_cast<int>(
size)};
520 int const istride = 1;
521 int const ostride = 1;
522 int const* inembed =
nullptr;
523 int const* onembed =
nullptr;
524 int const idist = n[0];
525 int const odist = n[0];
526 return ::fftwf_plan_many_dft_r2c(
527 rank, n, howmany, const_cast<precision_type*>(in), inembed, istride,
528 idist, out, onembed, ostride, odist, flags);
543 int howmany, std::size_t
size, fftw_complex_type
const* in,
544 precision_type* out,
int flags) {
546 int const n[rank] = {
static_cast<int>(
size)};
547 int const istride = 1;
548 int const ostride = 1;
549 int const* inembed =
nullptr;
550 int const* onembed =
nullptr;
551 int const idist = n[0];
552 int const odist = n[0];
553 return ::fftwf_plan_many_dft_c2r(
554 rank, n, howmany, const_cast<fftw_complex_type*>(in), inembed, istride,
555 idist, out, onembed, ostride, odist, flags);
564 ::fftwf_destroy_plan(p);
595 return ::fftwl_malloc(n);
604 ::fftwl_free(buffer);
618 fftw_plan_type
const p, fftw_complex_type
const* in,
619 fftw_complex_type* out) {
620 ::fftwl_execute_dft(p, const_cast<fftw_complex_type*>(in), out);
634 fftw_plan_type
const p, precision_type
const* in,
635 fftw_complex_type* out) {
636 ::fftwl_execute_dft_r2c(p, const_cast<precision_type*>(in), out);
650 fftw_plan_type
const p, fftw_complex_type
const* in,
651 precision_type* out) {
652 ::fftwl_execute_dft_c2r(p, const_cast<fftw_complex_type*>(in), out);
666 std::size_t
size, fftw_complex_type
const* in, fftw_complex_type* out,
668 return ::fftwl_plan_dft_1d(
669 size, const_cast<fftw_complex_type*>(in), out, FFTW_FORWARD, flags);
683 std::size_t
size, fftw_complex_type
const* in, fftw_complex_type* out,
685 return ::fftwl_plan_dft_1d(
686 size, const_cast<fftw_complex_type*>(in), out, FFTW_BACKWARD, flags);
700 std::size_t
size, precision_type
const* in, fftw_complex_type* out,
702 return ::fftwl_plan_dft_r2c_1d(
703 size, const_cast<precision_type*>(in), out, flags);
717 std::size_t
size, fftw_complex_type
const* in, precision_type* out,
719 return ::fftwl_plan_dft_c2r_1d(
720 size, const_cast<fftw_complex_type*>(in), out, flags);
735 int howmany, std::size_t
size, fftw_complex_type
const* in,
736 fftw_complex_type* out,
int flags) {
738 int const n[rank] = {
static_cast<int>(
size)};
739 int const istride = 1;
740 int const ostride = 1;
741 int const* inembed =
nullptr;
742 int const* onembed =
nullptr;
743 int const idist = n[0];
744 int const odist = n[0];
745 return ::fftwl_plan_many_dft(
746 rank, n, howmany, const_cast<fftw_complex_type*>(in), inembed, istride,
747 idist, out, onembed, ostride, odist, FFTW_FORWARD, flags);
762 int howmany, std::size_t
size, fftw_complex_type
const* in,
763 fftw_complex_type* out,
int flags) {
765 int const n[rank] = {
static_cast<int>(
size)};
766 int const istride = 1;
767 int const ostride = 1;
768 int const* inembed =
nullptr;
769 int const* onembed =
nullptr;
770 int const idist = n[0];
771 int const odist = n[0];
772 return ::fftwl_plan_many_dft(
773 rank, n, howmany, const_cast<fftw_complex_type*>(in), inembed, istride,
774 idist, out, onembed, ostride, odist, FFTW_BACKWARD, flags);
789 int howmany, std::size_t
size, precision_type
const* in,
790 fftw_complex_type* out,
unsigned flags) {
792 int const n[rank] = {
static_cast<int>(
size)};
793 int const istride = 1;
794 int const ostride = 1;
795 int const* inembed =
nullptr;
796 int const* onembed =
nullptr;
797 int const idist = n[0];
798 int const odist = n[0];
799 return ::fftwl_plan_many_dft_r2c(
800 rank, n, howmany, const_cast<precision_type*>(in), inembed, istride,
801 idist, out, onembed, ostride, odist, flags);
816 int howmany, std::size_t
size, fftw_complex_type
const* in,
817 precision_type* out,
int flags) {
819 int const n[rank] = {
static_cast<int>(
size)};
820 int const istride = 1;
821 int const ostride = 1;
822 int const* inembed =
nullptr;
823 int const* onembed =
nullptr;
824 int const idist = n[0];
825 int const odist = n[0];
826 return ::fftwl_plan_many_dft_c2r(
827 rank, n, howmany, const_cast<fftw_complex_type*>(in), inembed, istride,
828 idist, out, onembed, ostride, odist, flags);
837 ::fftwl_destroy_plan(p);
849 template <
typename T>
855 #endif // jb_fftw_traits_hpp static void * allocate(std::size_t n)
Allocate a properly aligned (for SIMD acceleration) block of memory.
static fftw_plan_type create_backward_plan_many(int howmany, std::size_t size, fftw_complex_type const *in, fftw_complex_type *out, int flags)
Create an execution to compute the inverse DFT of many vectors based on the input and output exemplar...
static void * allocate(std::size_t n)
Allocate a properly aligned (for SIMD acceleration) block of memory.
Wrap fftw_* types and operations to treat floating point values generically.
static fftw_plan_type create_backward_plan_many(int howmany, std::size_t size, fftw_complex_type const *in, fftw_complex_type *out, int flags)
Create an execution to compute the inverse DFT of many vectors based on the input and output exemplar...
static void destroy_plan(fftw_plan_type p)
Destroy an execution plan.
static fftw_plan_type create_forward_plan(std::size_t size, fftw_complex_type const *in, fftw_complex_type *out, int flags)
Create an execution plan to compute the DFT based on the input and output exemplars.
static fftw_plan_type create_plan_many(int howmany, std::size_t size, precision_type const *in, fftw_complex_type *out, unsigned flags)
Create an execution to compute the DFT of many vectors based on the input and output exemplars...
static fftw_plan_type create_plan_many(int howmany, std::size_t size, fftw_complex_type const *in, precision_type *out, int flags)
Create an execution to compute the inverse DFT of many vectors based on the input and output exemplar...
static fftw_plan_type create_forward_plan_many(int howmany, std::size_t size, fftw_complex_type const *in, fftw_complex_type *out, int flags)
Create an execution to compute the DFT of many vectors based on the input and output exemplars...
static void destroy_plan(fftw_plan_type p)
Destroy an execution plan.
static fftw_plan_type create_plan(std::size_t size, precision_type const *in, fftw_complex_type *out, int flags)
Create an execution to compute the DFT based on the input and output exemplars.
static fftw_plan_type create_backward_plan(std::size_t size, fftw_complex_type const *in, fftw_complex_type *out, int flags)
Create an execution to compute the inverse DFT based on the input and output exemplars.
long double precision_type
The type used to represent floating point numbers.
static fftw_plan_type create_forward_plan_many(int howmany, std::size_t size, fftw_complex_type const *in, fftw_complex_type *out, int flags)
Create an execution to compute the DFT of many vectors based on the input and output exemplars...
static void execute_plan(fftw_plan_type const p, fftw_complex_type const *in, fftw_complex_type *out)
Execute an existing plan for a given input and output.
static fftw_plan_type create_forward_plan_many(int howmany, std::size_t size, fftw_complex_type const *in, fftw_complex_type *out, int flags)
Create an execution to compute the DFT of many vectors based on the input and output exemplars...
static fftw_plan_type create_forward_plan(std::size_t size, fftw_complex_type const *in, fftw_complex_type *out, int flags)
Create an execution plan to compute the DFT based on the input and output exemplars.
static fftw_plan_type create_plan_many(int howmany, std::size_t size, precision_type const *in, fftw_complex_type *out, unsigned flags)
Create an execution to compute the DFT of many vectors based on the input and output exemplars...
static void execute_plan(fftw_plan_type const p, fftw_complex_type const *in, precision_type *out)
Execute an existing plan for a given input and output.
static fftw_plan_type create_backward_plan_many(int howmany, std::size_t size, fftw_complex_type const *in, fftw_complex_type *out, int flags)
Create an execution to compute the inverse DFT of many vectors based on the input and output exemplar...
static fftw_plan_type create_plan_many(int howmany, std::size_t size, fftw_complex_type const *in, precision_type *out, int flags)
Create an execution to compute the inverse DFT of many vectors based on the input and output exemplar...
double precision_type
The type used to represent floating point numbers.
::fftw_plan fftw_plan_type
The type used to represent execution plans in FFTW.
static fftw_plan_type create_forward_plan(std::size_t size, fftw_complex_type const *in, fftw_complex_type *out, int flags)
Create an execution plan to compute the DFT based on the input and output exemplars.
::fftw_complex fftw_complex_type
The type used to represent complex numbers in FFTW.
static void execute_plan(fftw_plan_type const p, fftw_complex_type const *in, fftw_complex_type *out)
Execute an existing plan for a given input and output.
static void execute_plan(fftw_plan_type const p, precision_type const *in, fftw_complex_type *out)
Execute an existing plan for a given input and output.
static fftw_plan_type create_plan(std::size_t size, fftw_complex_type const *in, precision_type *out, int flags)
Create an execution to compute the inverse DFT based on the input and output exemplars.
static void release(void *buffer)
Release a block of memory allocated with allocate()
static void release(void *buffer)
Release a block of memory allocated with allocate()
::fftwf_plan fftw_plan_type
The type used to represent execution plans in FFTW.
static void release(void *buffer)
Release a block of memory allocated with allocate()
static void execute_plan(fftw_plan_type const p, precision_type const *in, fftw_complex_type *out)
Execute an existing plan for a given input and output.
static void execute_plan(fftw_plan_type const p, precision_type const *in, fftw_complex_type *out)
Execute an existing plan for a given input and output.
static fftw_plan_type create_plan(std::size_t size, fftw_complex_type const *in, precision_type *out, int flags)
Create an execution to compute the inverse DFT based on the input and output exemplars.
::fftwl_complex fftw_complex_type
The type used to represent complex numbers in FFTW.
static fftw_plan_type create_plan(std::size_t size, precision_type const *in, fftw_complex_type *out, int flags)
Create an execution to compute the DFT based on the input and output exemplars.
::fftwl_plan fftw_plan_type
The type used to represent execution plans in FFTW.
static fftw_plan_type create_plan(std::size_t size, fftw_complex_type const *in, precision_type *out, int flags)
Create an execution to compute the inverse DFT based on the input and output exemplars.
static fftw_plan_type create_plan_many(int howmany, std::size_t size, fftw_complex_type const *in, precision_type *out, int flags)
Create an execution to compute the inverse DFT of many vectors based on the input and output exemplar...
static fftw_plan_type create_plan_many(int howmany, std::size_t size, precision_type const *in, fftw_complex_type *out, unsigned flags)
Create an execution to compute the DFT of many vectors based on the input and output exemplars...
static void destroy_plan(fftw_plan_type p)
Destroy an execution plan.
static fftw_plan_type create_backward_plan(std::size_t size, fftw_complex_type const *in, fftw_complex_type *out, int flags)
Create an execution to compute the inverse DFT based on the input and output exemplars.
::std::complex< double > std_complex_type
The type used to represent complex numbers in the C++ standard library.
static void execute_plan(fftw_plan_type const p, fftw_complex_type const *in, precision_type *out)
Execute an existing plan for a given input and output.
static void execute_plan(fftw_plan_type const p, fftw_complex_type const *in, precision_type *out)
Execute an existing plan for a given input and output.
static void execute_plan(fftw_plan_type const p, fftw_complex_type const *in, fftw_complex_type *out)
Execute an existing plan for a given input and output.
std::complex< float > std_complex_type
The type used to represent complex numbers in the C++ standard library.
static void * allocate(std::size_t n)
Allocate a properly aligned (for SIMD acceleration) block of memory.
float precision_type
The type used to represent floating point numbers.
static fftw_plan_type create_plan(std::size_t size, precision_type const *in, fftw_complex_type *out, int flags)
Create an execution to compute the DFT based on the input and output exemplars.
::fftwf_complex fftw_complex_type
The type used to represent complex numbers in FFTW.
::std::complex< double > std_complex_type
The type used to represent complex numbers in the C++ standard library.
static fftw_plan_type create_backward_plan(std::size_t size, fftw_complex_type const *in, fftw_complex_type *out, int flags)
Create an execution to compute the inverse DFT based on the input and output exemplars.
The top-level namespace for the JayBeams library.