ndarray
NumPy-friendly multidimensional arrays in C++
Loading...
Searching...
No Matches
FourierTransform.h
Go to the documentation of this file.
1// -*- c++ -*-
2/*
3 * Copyright (c) 2010-2012, Jim Bosch
4 * All rights reserved.
5 *
6 * ndarray is distributed under a simple BSD-like license;
7 * see the LICENSE file that should be present in the root
8 * of the source distribution, or alternately available at:
9 * https://github.com/ndarray/ndarray
10 */
11#ifndef NDARRAY_FFT_FourierTransform_h_INCLUDED
12#define NDARRAY_FFT_FourierTransform_h_INCLUDED
13
20#include <boost/noncopyable.hpp>
21
22#include "ndarray.h"
24
25namespace ndarray {
26
41template <typename T, int N>
42class FourierTransform : private boost::noncopyable {
43 BOOST_STATIC_ASSERT((!boost::is_const<T>::value));
44public:
45
46 typedef boost::shared_ptr<FourierTransform> Ptr;
47
50
57
64 static Ptr planForward(
65 Index const & shape,
66 ArrayX & x,
67 ArrayK & k
68 );
69
76 static Ptr planInverse(
77 Index const & shape,
78 ArrayK & k,
79 ArrayX & x
80 );
81
89 MultiplexIndex const & shape,
90 MultiplexArrayX & x,
92 );
93
101 MultiplexIndex const & shape,
102 MultiplexArrayK & k,
103 MultiplexArrayX & x
104 );
105
107 template <int M>
109
111 template <int M>
113
119 template <int M>
121
123 void execute();
124
126
127private:
128 typedef boost::shared_ptr<ElementX> OwnerX;
129 typedef boost::shared_ptr<ElementK> OwnerK;
130
131 FourierTransform(void * plan, Manager::Ptr const & x, Manager::Ptr const & k)
132 : _plan(plan), _x(x), _k(k) {}
133
134 void * _plan; // 'void' so we don't have to include fftw3.h in the header file
135 Manager::Ptr _x;
136 Manager::Ptr _k;
137};
138
139} // namespace ndarray
140
141#endif // !NDARRAY_FFT_FourierTransform_h_INCLUDED
Traits classes to handle real-data and complex-data FFTs in a template-friendly way.
A multidimensional strided array.
Definition Array.h:35
A wrapper for FFTW plans for fast Fourier transforms.
Definition FourierTransform.h:42
static Ptr planForward(Index const &shape, ArrayX &x, ArrayK &k)
Create a plan for forward-transforming a single N-dimensional array.
detail::FourierTraits< T >::ElementX ElementX
Real-space array data type;.
Definition FourierTransform.h:48
static void initialize(Vector< Size, M > const &shape, Array< ElementX, M, M > &x, Array< ElementK, M, M > &k)
Initialize, as necessary, a pair of arrays with the given real-space shape.
Vector< Size, N > Index
Shape type for arrays.
Definition FourierTransform.h:51
void execute()
Execute the FFTW plan.
static Array< ElementX, M, M > initializeX(Vector< Size, M > const &shape)
Create a new real-space array with the given real-space shape.
static Ptr planInverse(Index const &shape, ArrayK &k, ArrayX &x)
Create a plan for inverse-transforming a single N-dimensional array.
Array< ElementK, N+1, N+1 > MultiplexArrayK
Fourier-space multiplexed array type.
Definition FourierTransform.h:56
static Ptr planMultiplexForward(MultiplexIndex const &shape, MultiplexArrayX &x, MultiplexArrayK &k)
Create a plan for forward-transforming a sequence of nested N-dimensional arrays.
Array< ElementX, N, N > ArrayX
Real-space array type.
Definition FourierTransform.h:52
Array< ElementX, N+1, N+1 > MultiplexArrayX
Real-space multiplexed array type.
Definition FourierTransform.h:55
static Array< ElementK, M, M > initializeK(Vector< Size, M > const &shape)
Create a new Fourier-space array with the given real-space shape.
static Ptr planMultiplexInverse(MultiplexIndex const &shape, MultiplexArrayK &k, MultiplexArrayX &x)
Create a plan for inverse-transforming a sequence of nested N-dimensional arrays.
detail::FourierTraits< T >::ElementK ElementK
Fourier-space array data type;.
Definition FourierTransform.h:49
Array< ElementK, N, N > ArrayK
Fourier-space array type.
Definition FourierTransform.h:53
Vector< Size, N+1 > MultiplexIndex
Shape type for multiplexed arrays.
Definition FourierTransform.h:54
Main public header file for ndarray.
A fixed-size 1D array class.
Definition Vector.h:82
Definition fft_fwd.h:35