Ensign
Low-rank framework for multi-core CPUs and GPUs
Loading...
Searching...
No Matches
fft.hpp
Go to the documentation of this file.
1
6#pragma once
7
8#include <generic/common.hpp>
9#include <generic/storage.hpp>
10
11namespace Ensign {
12
13/* FFT for arbitrary dimensional data, specified by dim.
14 The class can also be used to e.g. perform multiple 1d FFTS on a 2d array (in this case dim=1 and d=2).
15*/
16template<size_t d, size_t dim>
17struct fft {
18
22
24 void forward(double* real, complex<double>* freq, stloc sl);
25 // Note that the backward transform overwrites the input data. This is a limitation of FFTW.
27 void backward(complex<double>* freq, double* real, stloc sl);
28
29private:
30 array<fftw_plan,2> plans;
31 #ifdef __CUDA__
33 #endif
34
35 void set_null() {
36 plans[0] = 0;
37 plans[1] = 0;
38 #ifdef __CUDA__
39 cuda_plans[0] = 0;
40 cuda_plans[1] = 0;
41 #endif
42 }
43};
44
45template<size_t d>
47
48template<size_t d>
50
51template<size_t d>
53
54
55/* Helper routines to create FFTW plans for 1d transforms
56*/
57array<fftw_plan,2> create_plans_1d(Index dims_, multi_array<double,2>& real, multi_array<complex<double>,2>& freq);
58array<fftw_plan,2> create_plans_1d(Index dims_, multi_array<double,1>& real, multi_array<complex<double>,1>& freq);
59
60/* Helper routines to create FFTW plans for 2d transforms
61*/
62array<fftw_plan,2> create_plans_2d(array<Index,2> dims_, multi_array<double,1>& real, multi_array<complex<double>,1>& freq);
63array<fftw_plan,2> create_plans_2d(array<Index,2> dims_, multi_array<double,2>& real, multi_array<complex<double>,2>& freq);
64
65/* Helper routines to create FFTW plans for 3d transforms
66*/
67array<fftw_plan,2> create_plans_3d(array<Index,3> dims_, multi_array<double,2>& real, multi_array<complex<double>,2>& freq);
68array<fftw_plan,2> create_plans_3d(array<Index,3> dims_, multi_array<double,1>& real, multi_array<complex<double>,1>& freq);
69array<fftw_plan,2> create_plans_3d_adapt(array<Index,3> dims_, multi_array<double,2>& real, multi_array<complex<double>,2>& freq);
70
71/* Helper function to destroy FFTW plans
72*/
73void destroy_plans(array<fftw_plan,2>& plans);
74
75
76#ifdef __CUDA__
77/* Helper routines to create cuFFT plans for 1d transforms.
78*/
79array<cufftHandle,2> create_plans_1d(Index dims_, int howmany);
80
81/* Helper routines to create cuFFT plans for 2d transforms.
82*/
83array<cufftHandle,2> create_plans_2d(array<Index,2> dims_, int howmany);
84
85/* Helper routines to create cuFFT plans for 3d transforms.
86*/
87array<cufftHandle,2> create_plans_3d(array<Index,3> dims_, int howmany);
88
89array<cufftHandle,2> create_plans_3d_adapt(array<Index,3> dims_);
90
91/* Helper function to destroy cuFFT plans
92*/
93void destroy_plans(array<cufftHandle,2>& plans);
94#endif
95
96} // namespace Ensign
Provides shared types, platform headers, and basic definitions.
ptrdiff_t Index
Definition common.hpp:83
stloc
Definition common.hpp:84
Core namespace for Ensign's numerical algorithms and data structures.
Definition common.hpp:96
array< fftw_plan, 2 > create_plans_2d(array< Index, 2 > dims_, multi_array< double, 1 > &real, multi_array< complex< double >, 1 > &freq)
Helper routines to create FFTW plans for 2d transforms.
array< fftw_plan, 2 > create_plans_3d(array< Index, 3 > dims_, multi_array< double, 2 > &real, multi_array< complex< double >, 2 > &freq)
Helper routines to create FFTW plans for 3d transforms.
array< fftw_plan, 2 > create_plans_1d(Index dims_, multi_array< double, 2 > &real, multi_array< complex< double >, 2 > &freq)
Helper routines to create FFTW plans for 1d transforms.
void destroy_plans(array< fftw_plan, 2 > &plans)
Helper function to destroy FFTW plans.
array< fftw_plan, 2 > create_plans_3d_adapt(array< Index, 3 > dims_, multi_array< double, 2 > &real, multi_array< complex< double >, 2 > &freq)
Provides contiguous multidimensional arrays for CPU and GPU storage.
FFT for arbitrary dimensional data, specified by dim.
Definition fft.hpp:17
void forward(double *real, complex< double > *freq, stloc sl)
void forward(multi_array< double, d > &real, multi_array< complex< double >, d > &freq)
fft(array< Index, dim > dims_, multi_array< double, d > &real, multi_array< complex< double >, d > &freq, bool adapt)
void backward(multi_array< complex< double >, d > &freq, multi_array< double, d > &real)
fft(array< Index, dim > dims_, multi_array< double, d > &real, multi_array< complex< double >, d > &freq)
void backward(complex< double > *freq, double *real, stloc sl)
Dense d-dimensional array stored contiguously in column-major order (i.e.
Definition storage.hpp:24