18#ifndef itkFFTWCommon_h
19#define itkFFTWCommon_h
21#if defined(ITK_USE_FFTWF) || defined(ITK_USE_FFTWD)
22# if defined(ITK_USE_CUFFTW)
28# if !defined(FFTW_WISDOM_ONLY)
31# error "FFTW 3.3.2 or later is required so that FFTW_WISDOM_ONLY is defined."
53template <
typename TPixel>
63#if defined(ITK_USE_FFTWF)
87 bool canDestroyInput =
false)
89 return Plan_dft_c2r(1, &n, in, out, flags, threads, canDestroyInput);
99 bool canDestroyInput =
false)
104 PlanType plan = Plan_dft_c2r(2, sizes, in, out, flags, threads, canDestroyInput);
116 bool canDestroyInput =
false)
122 PlanType plan = Plan_dft_c2r(3, sizes, in, out, flags, threads, canDestroyInput);
133 bool canDestroyInput =
false)
135# ifndef ITK_USE_CUFFTW
137 fftwf_plan_with_nthreads(threads);
143 unsigned int roflags = flags;
144 if (!(flags & FFTW_ESTIMATE))
146 roflags = flags | FFTW_WISDOM_ONLY;
148 PlanType plan = fftwf_plan_dft_c2r(rank, n, in, out, roflags);
155 plan = fftwf_plan_dft_c2r(rank, n, in, out, flags);
161 for (
int i = 0; i < rank; ++i)
166 fftwf_plan_dft_c2r(rank, n, din, out, flags);
169 plan = fftwf_plan_dft_c2r(rank, n, in, out, roflags);
171# ifndef ITK_USE_CUFFTW
175 itkAssertOrThrowMacro(plan !=
nullptr,
"PLAN_CREATION_FAILED ");
186 bool canDestroyInput =
false)
188 return Plan_dft_r2c(1, &n, in, out, flags, threads, canDestroyInput);
198 bool canDestroyInput =
false)
203 PlanType plan = Plan_dft_r2c(2, sizes, in, out, flags, threads, canDestroyInput);
215 bool canDestroyInput =
false)
221 PlanType plan = Plan_dft_r2c(3, sizes, in, out, flags, threads, canDestroyInput);
232 bool canDestroyInput =
false)
235# ifndef ITK_USE_CUFFTW
237 fftwf_plan_with_nthreads(threads);
243 unsigned int roflags = flags;
244 if (!(flags & FFTW_ESTIMATE))
246 roflags = flags | FFTW_WISDOM_ONLY;
248 PlanType plan = fftwf_plan_dft_r2c(rank, n, in, out, roflags);
255 plan = fftwf_plan_dft_r2c(rank, n, in, out, flags);
261 for (
int i = 0; i < rank; ++i)
266 fftwf_plan_dft_r2c(rank, n, din, out, flags);
269 plan = fftwf_plan_dft_r2c(rank, n, in, out, roflags);
271# ifndef ITK_USE_CUFFTW
275 itkAssertOrThrowMacro(plan !=
nullptr,
"PLAN_CREATION_FAILED ");
286 bool canDestroyInput =
false)
288 return Plan_dft(1, &n, in, out, sign, flags, threads, canDestroyInput);
299 bool canDestroyInput =
false)
304 PlanType plan = Plan_dft(2, sizes, in, out, sign, flags, threads, canDestroyInput);
317 bool canDestroyInput =
false)
323 PlanType plan = Plan_dft(3, sizes, in, out, sign, flags, threads, canDestroyInput);
335 bool canDestroyInput =
false)
337# ifndef ITK_USE_CUFFTW
339 fftwf_plan_with_nthreads(threads);
345 unsigned int roflags = flags;
346 if (!(flags & FFTW_ESTIMATE))
348 roflags = flags | FFTW_WISDOM_ONLY;
350 PlanType plan = fftwf_plan_dft(rank, n, in, out, sign, roflags);
357 plan = fftwf_plan_dft(rank, n, in, out, sign, flags);
363 for (
int i = 0; i < rank; ++i)
368 fftwf_plan_dft(rank, n, din, out, sign, flags);
371 plan = fftwf_plan_dft(rank, n, in, out, sign, roflags);
373# ifndef ITK_USE_CUFFTW
377 itkAssertOrThrowMacro(plan !=
nullptr,
"PLAN_CREATION_FAILED ");
390# ifndef ITK_USE_CUFFTW
393 fftwf_destroy_plan(p);
400#if defined(ITK_USE_FFTWD)
411# ifdef ITK_USE_CUFFTW
423 bool canDestroyInput =
false)
425 return Plan_dft_c2r(1, &n, in, out, flags, threads, canDestroyInput);
435 bool canDestroyInput =
false)
440 PlanType plan = Plan_dft_c2r(2, sizes, in, out, flags, threads, canDestroyInput);
452 bool canDestroyInput =
false)
458 PlanType plan = Plan_dft_c2r(3, sizes, in, out, flags, threads, canDestroyInput);
469 bool canDestroyInput =
false)
471# ifndef ITK_USE_CUFFTW
473 fftw_plan_with_nthreads(threads);
479 unsigned int roflags = flags;
480 if (!(flags & FFTW_ESTIMATE))
482 roflags = flags | FFTW_WISDOM_ONLY;
484 PlanType plan = fftw_plan_dft_c2r(rank, n, in, out, roflags);
491 plan = fftw_plan_dft_c2r(rank, n, in, out, flags);
497 for (
int i = 0; i < rank; ++i)
502 fftw_plan_dft_c2r(rank, n, din, out, flags);
505 plan = fftw_plan_dft_c2r(rank, n, in, out, roflags);
507# ifndef ITK_USE_CUFFTW
511 itkAssertOrThrowMacro(plan !=
nullptr,
"PLAN_CREATION_FAILED ");
522 bool canDestroyInput =
false)
524 return Plan_dft_r2c(1, &n, in, out, flags, threads, canDestroyInput);
534 bool canDestroyInput =
false)
539 PlanType plan = Plan_dft_r2c(2, sizes, in, out, flags, threads, canDestroyInput);
551 bool canDestroyInput =
false)
557 PlanType plan = Plan_dft_r2c(3, sizes, in, out, flags, threads, canDestroyInput);
568 bool canDestroyInput =
false)
570# ifndef ITK_USE_CUFFTW
572 fftw_plan_with_nthreads(threads);
578 unsigned int roflags = flags;
579 if (!(flags & FFTW_ESTIMATE))
581 roflags = flags | FFTW_WISDOM_ONLY;
583 PlanType plan = fftw_plan_dft_r2c(rank, n, in, out, roflags);
590 plan = fftw_plan_dft_r2c(rank, n, in, out, flags);
596 for (
int i = 0; i < rank; ++i)
601 fftw_plan_dft_r2c(rank, n, din, out, flags);
604 plan = fftw_plan_dft_r2c(rank, n, in, out, roflags);
606# ifndef ITK_USE_CUFFTW
610 itkAssertOrThrowMacro(plan !=
nullptr,
"PLAN_CREATION_FAILED ");
621 bool canDestroyInput =
false)
623 return Plan_dft(1, &n, in, out, sign, flags, threads, canDestroyInput);
634 bool canDestroyInput =
false)
639 PlanType plan = Plan_dft(2, sizes, in, out, sign, flags, threads, canDestroyInput);
652 bool canDestroyInput =
false)
658 PlanType plan = Plan_dft(3, sizes, in, out, sign, flags, threads, canDestroyInput);
670 bool canDestroyInput =
false)
672# ifndef ITK_USE_CUFFTW
674 fftw_plan_with_nthreads(threads);
680 unsigned int roflags = flags;
681 if (!(flags & FFTW_ESTIMATE))
683 roflags = flags | FFTW_WISDOM_ONLY;
685 PlanType plan = fftw_plan_dft(rank, n, in, out, sign, roflags);
692 plan = fftw_plan_dft(rank, n, in, out, sign, flags);
698 for (
int i = 0; i < rank; ++i)
703 fftw_plan_dft(rank, n, din, out, sign, flags);
706 plan = fftw_plan_dft(rank, n, in, out, sign, roflags);
708# ifndef ITK_USE_CUFFTW
712 itkAssertOrThrowMacro(plan !=
nullptr,
"PLAN_CREATION_FAILED ");
725# ifndef ITK_USE_CUFFTW
728 fftw_destroy_plan(p);
static std::mutex & GetLockMutex()
static void SetNewWisdomAvailable(const bool v)
static PlanType Plan_dft_c2r(int rank, const int *n, ComplexType *in, PixelType *out, unsigned int flags, int threads=1, bool canDestroyInput=false)
static void Execute(PlanType p)
static PlanType Plan_dft_2d(int nx, int ny, ComplexType *in, ComplexType *out, int sign, unsigned int flags, int threads=1, bool canDestroyInput=false)
static PlanType Plan_dft_3d(int nx, int ny, int nz, ComplexType *in, ComplexType *out, int sign, unsigned int flags, int threads=1, bool canDestroyInput=false)
static PlanType Plan_dft_r2c_2d(int nx, int ny, PixelType *in, ComplexType *out, unsigned int flags, int threads=1, bool canDestroyInput=false)
static PlanType Plan_dft_1d(int n, ComplexType *in, ComplexType *out, int sign, unsigned int flags, int threads=1, bool canDestroyInput=false)
static PlanType Plan_dft_c2r_1d(int n, ComplexType *in, PixelType *out, unsigned int flags, int threads=1, bool canDestroyInput=false)
static PlanType Plan_dft_r2c_3d(int nx, int ny, int nz, PixelType *in, ComplexType *out, unsigned int flags, int threads=1, bool canDestroyInput=false)
static void DestroyPlan(PlanType p)
static PlanType Plan_dft_c2r_2d(int nx, int ny, ComplexType *in, PixelType *out, unsigned int flags, int threads=1, bool canDestroyInput=false)
static PlanType Plan_dft(int rank, const int *n, ComplexType *in, ComplexType *out, int sign, unsigned int flags, int threads=1, bool canDestroyInput=false)
static PlanType Plan_dft_r2c_1d(int n, PixelType *in, ComplexType *out, unsigned int flags, int threads=1, bool canDestroyInput=false)
static PlanType Plan_dft_r2c(int rank, const int *n, PixelType *in, ComplexType *out, unsigned int flags, int threads=1, bool canDestroyInput=false)
static PlanType Plan_dft_c2r_3d(int nx, int ny, int nz, ComplexType *in, PixelType *out, unsigned int flags, int threads=1, bool canDestroyInput=false)
static PlanType Plan_dft_r2c_2d(int nx, int ny, PixelType *in, ComplexType *out, unsigned int flags, int threads=1, bool canDestroyInput=false)
static PlanType Plan_dft_c2r_2d(int nx, int ny, ComplexType *in, PixelType *out, unsigned int flags, int threads=1, bool canDestroyInput=false)
static PlanType Plan_dft_1d(int n, ComplexType *in, ComplexType *out, int sign, unsigned int flags, int threads=1, bool canDestroyInput=false)
fftwf_complex ComplexType
static PlanType Plan_dft(int rank, const int *n, ComplexType *in, ComplexType *out, int sign, unsigned int flags, int threads=1, bool canDestroyInput=false)
static PlanType Plan_dft_2d(int nx, int ny, ComplexType *in, ComplexType *out, int sign, unsigned int flags, int threads=1, bool canDestroyInput=false)
static PlanType Plan_dft_c2r(int rank, const int *n, ComplexType *in, PixelType *out, unsigned int flags, int threads=1, bool canDestroyInput=false)
static PlanType Plan_dft_c2r_3d(int nx, int ny, int nz, ComplexType *in, PixelType *out, unsigned int flags, int threads=1, bool canDestroyInput=false)
static PlanType Plan_dft_r2c_3d(int nx, int ny, int nz, PixelType *in, ComplexType *out, unsigned int flags, int threads=1, bool canDestroyInput=false)
static PlanType Plan_dft_c2r_1d(int n, ComplexType *in, PixelType *out, unsigned int flags, int threads=1, bool canDestroyInput=false)
static PlanType Plan_dft_3d(int nx, int ny, int nz, ComplexType *in, ComplexType *out, int sign, unsigned int flags, int threads=1, bool canDestroyInput=false)
static void DestroyPlan(PlanType p)
static void Execute(PlanType p)
static PlanType Plan_dft_r2c_1d(int n, PixelType *in, ComplexType *out, unsigned int flags, int threads=1, bool canDestroyInput=false)
static PlanType Plan_dft_r2c(int rank, const int *n, PixelType *in, ComplexType *out, unsigned int flags, int threads=1, bool canDestroyInput=false)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
unsigned long SizeValueType