LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
FourierTransform.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 /*
3  * LSST Data Management System
4  * Copyright 2008, 2009, 2010, 2011 LSST Corporation.
5  *
6  * This product includes software developed by the
7  * LSST Project (http://www.lsst.org/).
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the LSST License Statement and
20  * the GNU General Public License along with this program. If not,
21  * see <http://www.lsstcorp.org/LegalNotices/>.
22  */
23 #ifndef NDARRAY_FFT_FourierTransform_h_INCLUDED
24 #define NDARRAY_FFT_FourierTransform_h_INCLUDED
25 
32 #include <boost/noncopyable.hpp>
33 
34 #include "ndarray.h"
36 
37 namespace ndarray {
38 
53 template <typename T, int N>
54 class FourierTransform : private boost::noncopyable {
55  BOOST_STATIC_ASSERT((!boost::is_const<T>::value));
56 public:
57 
58  typedef boost::shared_ptr<FourierTransform> Ptr;
59 
62 
63  typedef Vector<int,N> Index;
69 
76  static Ptr planForward(
77  Index const & shape,
78  ArrayX & x,
79  ArrayK & k
80  );
81 
88  static Ptr planInverse(
89  Index const & shape,
90  ArrayK & k,
91  ArrayX & x
92  );
93 
100  static Ptr planMultiplexForward(
101  MultiplexIndex const & shape,
102  MultiplexArrayX & x,
103  MultiplexArrayK & k
104  );
105 
112  static Ptr planMultiplexInverse(
113  MultiplexIndex const & shape,
114  MultiplexArrayK & k,
115  MultiplexArrayX & x
116  );
117 
119  template <int M>
120  static Array<ElementX,M,M> initializeX(Vector<int,M> const & shape);
121 
123  template <int M>
124  static Array<ElementK,M,M> initializeK(Vector<int,M> const & shape);
125 
131  template <int M>
132  static void initialize(Vector<int,M> const & shape, Array<ElementX,M,M> & x, Array<ElementK,M,M> & k);
133 
135  void execute();
136 
138 
139 private:
140  typedef boost::shared_ptr<ElementX> OwnerX;
141  typedef boost::shared_ptr<ElementK> OwnerK;
142 
143  FourierTransform(void * plan, Manager::Ptr const & x, Manager::Ptr const & k)
144  : _plan(plan), _x(x), _k(k) {}
145 
146  void * _plan; // 'void' so we don't have to include fftw3.h in the header file
149 };
150 
151 } // namespace ndarray
152 
153 #endif // !NDARRAY_FFT_FourierTransform_h_INCLUDED
detail::FourierTraits< T >::ElementX ElementX
Real-space array data type;.
static Array< ElementX, M, M > initializeX(Vector< int, M > const &shape)
Create a new real-space array with the given real-space shape.
Array< ElementX, N, N > ArrayX
Real-space array type.
static void initialize(Vector< int, 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.
static Ptr planMultiplexForward(MultiplexIndex const &shape, MultiplexArrayX &x, MultiplexArrayK &k)
Create a plan for forward-transforming a sequence of nested N-dimensional arrays. ...
static Ptr planMultiplexInverse(MultiplexIndex const &shape, MultiplexArrayK &k, MultiplexArrayX &x)
Create a plan for inverse-transforming a sequence of nested N-dimensional arrays. ...
boost::shared_ptr< ElementX > OwnerX
detail::FourierTraits< T >::ElementK ElementK
Fourier-space array data type;.
FourierTransform(void *plan, Manager::Ptr const &x, Manager::Ptr const &k)
Array< ElementK, N+1, N+1 > MultiplexArrayK
Fourier-space multiplexed array type.
boost::intrusive_ptr< Manager > Ptr
Definition: Manager.h:42
static Array< ElementK, M, M > initializeK(Vector< int, M > const &shape)
Create a new Fourier-space array with the given real-space shape.
Vector< int, N > Index
Shape type for arrays.
double x
void execute()
Execute the FFTW plan.
BOOST_STATIC_ASSERT((!boost::is_const< T >::value))
boost::shared_ptr< FourierTransform > Ptr
Array< ElementX, N+1, N+1 > MultiplexArrayX
Real-space multiplexed array type.
A multidimensional strided array.
Definition: Array.h:47
static Ptr planForward(Index const &shape, ArrayX &x, ArrayK &k)
Create a plan for forward-transforming a single N-dimensional array.
static Ptr planInverse(Index const &shape, ArrayK &k, ArrayX &x)
Create a plan for inverse-transforming a single N-dimensional array.
Array< ElementK, N, N > ArrayK
Fourier-space array type.
Traits classes to handle real-data and complex-data FFTs in a template-friendly way.
Vector< int, N+1 > MultiplexIndex
Shape type for multiplexed arrays.
boost::shared_ptr< ElementK > OwnerK
A wrapper for FFTW plans for fast Fourier transforms.