30 return const_cast<T*
>(
p);
34 fftw_complex *
fftw_cast(
const std::complex<double> * p)
36 return const_cast<fftw_complex*
>(
reinterpret_cast<const fftw_complex*
>(
p) );
40 fftwf_complex *
fftw_cast(
const std::complex<float> * p)
42 return const_cast<fftwf_complex*
>(
reinterpret_cast<const fftwf_complex*
>(
p) );
46 fftwl_complex *
fftw_cast(
const std::complex<long double> * p)
48 return const_cast<fftwl_complex*
>(
reinterpret_cast<const fftwl_complex*
>(
p) );
55 struct fftw_plan<float>
57 typedef float scalar_type;
58 typedef fftwf_complex complex_type;
59 std::shared_ptr<fftwf_plan_s> m_plan;
60 fftw_plan() =
default;
62 void set_plan(fftwf_plan p) { m_plan.reset(p, fftwf_destroy_plan); }
64 void fwd(complex_type * dst,complex_type * src,
int nfft) {
65 if (m_plan==NULL) set_plan(fftwf_plan_dft_1d(nfft,src,dst, FFTW_FORWARD, FFTW_ESTIMATE|FFTW_PRESERVE_INPUT));
66 fftwf_execute_dft( m_plan.get(), src,dst);
69 void inv(complex_type * dst,complex_type * src,
int nfft) {
70 if (m_plan==NULL) set_plan(fftwf_plan_dft_1d(nfft,src,dst, FFTW_BACKWARD , FFTW_ESTIMATE|FFTW_PRESERVE_INPUT));
71 fftwf_execute_dft( m_plan.get(), src,dst);
74 void fwd(complex_type * dst,scalar_type * src,
int nfft) {
75 if (m_plan==NULL) set_plan(fftwf_plan_dft_r2c_1d(nfft,src,dst,FFTW_ESTIMATE|FFTW_PRESERVE_INPUT));
76 fftwf_execute_dft_r2c( m_plan.get(),src,dst);
79 void inv(scalar_type * dst,complex_type * src,
int nfft) {
81 set_plan(fftwf_plan_dft_c2r_1d(nfft,src,dst,FFTW_ESTIMATE|FFTW_PRESERVE_INPUT));
82 fftwf_execute_dft_c2r( m_plan.get(), src,dst);
86 void fwd2( complex_type * dst,complex_type * src,
int n0,
int n1) {
87 if (m_plan==NULL) set_plan(fftwf_plan_dft_2d(n0,n1,src,dst,FFTW_FORWARD,FFTW_ESTIMATE|FFTW_PRESERVE_INPUT));
88 fftwf_execute_dft( m_plan.get(), src,dst);
91 void inv2( complex_type * dst,complex_type * src,
int n0,
int n1) {
92 if (m_plan==NULL) set_plan(fftwf_plan_dft_2d(n0,n1,src,dst,FFTW_BACKWARD,FFTW_ESTIMATE|FFTW_PRESERVE_INPUT));
93 fftwf_execute_dft( m_plan.get(), src,dst);
98 struct fftw_plan<double>
100 typedef double scalar_type;
101 typedef fftw_complex complex_type;
102 std::shared_ptr<fftw_plan_s> m_plan;
103 fftw_plan() =
default;
105 void set_plan(::fftw_plan p) { m_plan.reset(p, fftw_destroy_plan); }
107 void fwd(complex_type * dst,complex_type * src,
int nfft) {
108 if (m_plan==NULL) set_plan(fftw_plan_dft_1d(nfft,src,dst, FFTW_FORWARD, FFTW_ESTIMATE|FFTW_PRESERVE_INPUT));
109 fftw_execute_dft( m_plan.get(), src,dst);
112 void inv(complex_type * dst,complex_type * src,
int nfft) {
113 if (m_plan==NULL) set_plan(fftw_plan_dft_1d(nfft,src,dst, FFTW_BACKWARD , FFTW_ESTIMATE|FFTW_PRESERVE_INPUT));
114 fftw_execute_dft( m_plan.get(), src,dst);
117 void fwd(complex_type * dst,scalar_type * src,
int nfft) {
118 if (m_plan==NULL) set_plan(fftw_plan_dft_r2c_1d(nfft,src,dst,FFTW_ESTIMATE|FFTW_PRESERVE_INPUT));
119 fftw_execute_dft_r2c( m_plan.get(),src,dst);
122 void inv(scalar_type * dst,complex_type * src,
int nfft) {
124 set_plan(fftw_plan_dft_c2r_1d(nfft,src,dst,FFTW_ESTIMATE|FFTW_PRESERVE_INPUT));
125 fftw_execute_dft_c2r( m_plan.get(), src,dst);
128 void fwd2( complex_type * dst,complex_type * src,
int n0,
int n1) {
129 if (m_plan==NULL) set_plan(fftw_plan_dft_2d(n0,n1,src,dst,FFTW_FORWARD,FFTW_ESTIMATE|FFTW_PRESERVE_INPUT));
130 fftw_execute_dft( m_plan.get(), src,dst);
133 void inv2( complex_type * dst,complex_type * src,
int n0,
int n1) {
134 if (m_plan==NULL) set_plan(fftw_plan_dft_2d(n0,n1,src,dst,FFTW_BACKWARD,FFTW_ESTIMATE|FFTW_PRESERVE_INPUT));
135 fftw_execute_dft( m_plan.get(), src,dst);
139 struct fftw_plan<long double>
141 typedef long double scalar_type;
142 typedef fftwl_complex complex_type;
143 std::shared_ptr<fftwl_plan_s> m_plan;
144 fftw_plan() =
default;
146 void set_plan(fftwl_plan p) { m_plan.reset(p, fftwl_destroy_plan); }
148 void fwd(complex_type * dst,complex_type * src,
int nfft) {
149 if (m_plan==NULL) set_plan(fftwl_plan_dft_1d(nfft,src,dst, FFTW_FORWARD, FFTW_ESTIMATE|FFTW_PRESERVE_INPUT));
150 fftwl_execute_dft( m_plan.get(), src,dst);
153 void inv(complex_type * dst,complex_type * src,
int nfft) {
154 if (m_plan==NULL) set_plan(fftwl_plan_dft_1d(nfft,src,dst, FFTW_BACKWARD , FFTW_ESTIMATE|FFTW_PRESERVE_INPUT));
155 fftwl_execute_dft( m_plan.get(), src,dst);
158 void fwd(complex_type * dst,scalar_type * src,
int nfft) {
159 if (m_plan==NULL) set_plan(fftwl_plan_dft_r2c_1d(nfft,src,dst,FFTW_ESTIMATE|FFTW_PRESERVE_INPUT));
160 fftwl_execute_dft_r2c( m_plan.get(),src,dst);
163 void inv(scalar_type * dst,complex_type * src,
int nfft) {
165 set_plan(fftwl_plan_dft_c2r_1d(nfft,src,dst,FFTW_ESTIMATE|FFTW_PRESERVE_INPUT));
166 fftwl_execute_dft_c2r( m_plan.get(), src,dst);
169 void fwd2( complex_type * dst,complex_type * src,
int n0,
int n1) {
170 if (m_plan==NULL) set_plan(fftwl_plan_dft_2d(n0,n1,src,dst,FFTW_FORWARD,FFTW_ESTIMATE|FFTW_PRESERVE_INPUT));
171 fftwl_execute_dft( m_plan.get(), src,dst);
174 void inv2( complex_type * dst,complex_type * src,
int n0,
int n1) {
175 if (m_plan==NULL) set_plan(fftwl_plan_dft_2d(n0,n1,src,dst,FFTW_BACKWARD,FFTW_ESTIMATE|FFTW_PRESERVE_INPUT));
176 fftwl_execute_dft( m_plan.get(), src,dst);
180 template <
typename Scalar_>
183 typedef Scalar_ Scalar;
184 typedef std::complex<Scalar> Complex;
194 void fwd( Complex * dst,
const Complex *src,
int nfft)
201 void fwd( Complex * dst,
const Scalar * src,
int nfft)
208 void fwd2(Complex * dst,
const Complex * src,
int n0,
int n1)
215 void inv(Complex * dst,
const Complex *src,
int nfft)
222 void inv( Scalar * dst,
const Complex * src,
int nfft)
229 void inv2(Complex * dst,
const Complex * src,
int n0,
int n1)
236 typedef fftw_plan<Scalar> PlanData;
240 typedef std::map<int64_t,PlanData> PlanMap;
245 PlanData & get_plan(
int nfft,
bool inverse,
void * dst,
const void * src)
247 bool inplace = (dst==src);
248 bool aligned = ( (
reinterpret_cast<size_t>(src)&15) | (
reinterpret_cast<size_t>(dst)&15) ) == 0;
249 int64_t key = ( (nfft<<3 ) | (
inverse<<2) | (inplace<<1) | aligned ) << 1;
254 PlanData & get_plan(
int n0,
int n1,
bool inverse,
void * dst,
const void * src)
256 bool inplace = (dst==src);
257 bool aligned = ( (
reinterpret_cast<size_t>(src)&15) | (
reinterpret_cast<size_t>(dst)&15) ) == 0;
258 int64_t key = ( ( (((
int64_t)n0) << 30)|(n1<<3 ) | (
inverse<<2) | (inplace<<1) | aligned ) << 1 ) + 1;
T * fftw_cast(const T *p)
: TensorContractionSycl.h, provides various tensor contraction kernel for SYCL backend
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_inverse_op< typename Derived::Scalar >, const Derived > inverse(const Eigen::ArrayBase< Derived > &x)