casacore
LatticeFFT.h
Go to the documentation of this file.
1//# LatticeFFT.h: Definitions for Lattice FFT functions
2//# Copyright (C) 1996,1997,1998,2003
3//# Associated Universities, Inc. Washington DC, USA.
4//#
5//# This library is free software; you can redistribute it and/or modify it
6//# under the terms of the GNU Library General Public License as published by
7//# the Free Software Foundation; either version 2 of the License, or (at your
8//# option) any later version.
9//#
10//# This library is distributed in the hope that it will be useful, but WITHOUT
11//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13//# License for more details.
14//#
15//# You should have received a copy of the GNU Library General Public License
16//# along with this library; if not, write to the Free Software Foundation,
17//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18//#
19//# Correspondence concerning AIPS++ should be addressed as follows:
20//# Internet email: aips2-request@nrao.edu.
21//# Postal address: AIPS++ Project Office
22//# National Radio Astronomy Observatory
23//# 520 Edgemont Road
24//# Charlottesville, VA 22903-2475 USA
25//#
26//#
27//# $Id$
28
29#ifndef LATTICES_LATTICEFFT_H
30#define LATTICES_LATTICEFFT_H
31
32#include <casacore/casa/aips.h>
33#include <casacore/casa/BasicSL/Complex.h>
34#include <casacore/casa/Exceptions/Error.h>
35#include <casacore/scimath/Mathematics/NumericTraits.h>
36#include <casacore/casa/Arrays/ArrayFwd.h>
37
38namespace casacore { //# NAMESPACE CASACORE - BEGIN
39
40template <class T> class Lattice;
41
42// <summary>Functions for Fourier transforming Lattices</summary>
43
44// <reviewed reviewer="" date="" tests="" demos="">
45// </reviewed>
46
47// <prerequisite>
48// </prerequisite>
49
50// <etymology>
51// </etymology>
52
53// <synopsis>
54// </synopsis>
55
56// <example>
57// <srcblock>
58// </srcblock>
59// </example>
60
61// <motivation>
62// </motivation>
63
64// <todo asof="">
65// </todo>
66
68{
69
70public:
71 // 2-D in-place complex->complex FFT. Transforms over the first two
72 // dimensions and iterates over all the others. The Lattice must have two or
73 // more dimensions otherwise an AipsError is thrown.
74 template <class ComplexType> static void cfft2d(
75 Lattice<ComplexType> & cLattice, const Bool toFrequency=True
76 );
77
78 // N-D in-place complex->complex FFT. Only transform over selected
79 // dimensions. Iterate over the others. whichAxes must be the same length as
80 // the number of dimensions in the Lattice otherwise an AipsError is thrown.
81 template <class ComplexType> static void cfft(Lattice<ComplexType> & cLattice,
82 const Vector<Bool> & whichAxes, const Bool toFrequency=True);
83
84 // Non-folded version
85 template <class ComplexType> static void cfft0(Lattice<ComplexType> & cLattice,
86 const Vector<Bool> & whichAxes, const Bool toFrequency=True);
87
88 // N-D in-place complex->complex FFT. Transform over all axes.
89 template <class ComplexType> static void cfft(
90 Lattice<ComplexType> & cLattice, const Bool toFrequency=True
91 );
92
93 // N-D real->complex FFT. Only one half of the Hermition result is
94 // returned. Transforms are only done on selected dimensions. The origin of
95 // the transform is the center of the Lattice ie., [nx/2,ny/2,...] if
96 // doShift is True. Otherwise it is the first element ie., [0,0,...]
97 template <class ComplexType> static void rcfft(
100 const Vector<Bool> & whichAxes, const Bool doShift=True,
101 Bool doFast=False
102 );
103
104 template <class ComplexType> static void myrcfft(
107 const Vector<Bool> & whichAxes, const Bool doShift=True
108 );
109
110 // N-D real->complex FFT. Only one half of the Hermition result is
111 // returned. Transform over all dimensions. The origin of
112 // the transform is the center of the Lattice ie., [nx/2,ny/2,...] if
113 // doShift is True. Otherwise it is the first element ie., [0,0,...]
114 template <class ComplexType> static void rcfft(
117 const Bool doShift=True, Bool doFast=False
118 );
119 template <class ComplexType> static void myrcfft(
122 const Bool doShift=True
123 );
124
125 // N-D complex->real FFT. Only one half of the Hermition input is
126 // required. If whichAxis is specified Transforms are only done on selected
127 // dimensions otherwise they are done on all axes. The origin of the
128 // transform is the center of the Lattice ie., [nx/2,ny/2,...] if doShift is
129 // True, otherwise it is the first element ie., [0,0,...]
130
131 // These functions will <b>scramble the input Lattice</b> unless the versions
132 // with const inputs are used. The const input versions are less efficient as
133 // they create a temporary Lattice and copy the input data into it.
134 // <group>
135 template <class ComplexType> static void crfft(
137 Lattice<ComplexType> & in, const Vector<Bool> & whichAxes,
138 const Bool doShift=True, Bool doFast=False
139 );
140 template <class ComplexType> static void crfft(
142 Lattice<ComplexType> & in, const Bool doShift=True, Bool doFast=False
143 );
144 template <class ComplexType> static void crfft(
146 const Lattice<ComplexType> & in,
147 const Bool doShift=True, Bool doFast=False
148 );
149 // </group>
150};
151
152// implement template specializations to throw exceptions in the relevant cases.
153
154template <> inline void LatticeFFT::cfft2d(Lattice<Float>&, const Bool) {
155 ThrowCc(
156 String(__func__) +": This method does not support real-valued lattices"
157 );
158}
159
160template <> inline void LatticeFFT::cfft2d(Lattice<Double>&, const Bool) {
161 ThrowCc(
162 String(__func__) + ": This method does not support real-valued lattices"
163 );
164}
165
166template <> inline void LatticeFFT::cfft(
167 Lattice<Float>&, const Vector<Bool>&, const Bool
168) {
169 ThrowCc(
170 String(__func__) + ": This method does not support real-valued lattices"
171 );
172}
173
174template <> inline void LatticeFFT::cfft(
175 Lattice<Double>&, const Vector<Bool>&, const Bool
176) {
177 ThrowCc(
178 String(__func__) + ": This method does not support real-valued lattices"
179 );
180}
181
182template <> inline void LatticeFFT::rcfft(
183 Lattice<Float> &, const Lattice<Complex> &, const Vector<Bool> & ,
184 const Bool, Bool
185) {
186 ThrowCc(
187 String(__func__) + ": This is the real -> complex version, you've "
188 "called it with the wrong parameters"
189 );
190}
191
192template <> inline void LatticeFFT::rcfft(
194 const Bool, Bool
195) {
196 ThrowCc(
197 String(__func__) + ": This is the real -> complex version, you've "
198 "called it with the wrong parameters"
199 );
200}
201
202template <> inline void LatticeFFT::myrcfft(
204 const Vector<Bool> &, const Bool
205) {
206 ThrowCc(
207 String(__func__) + ": This is the real -> complex version, you've "
208 "called it with the wrong parameters"
209 );
210}
211
212template <> inline void LatticeFFT::myrcfft(
214 const Vector<Bool> &, const Bool
215) {
216 ThrowCc(
217 String(__func__) + ": This is the real -> complex version, you've "
218 "called it with the wrong parameters"
219 );
220}
221
222template <> inline void LatticeFFT::rcfft(
223 Lattice<Float> &, const Lattice<Complex> &, const Bool, Bool
224) {
225 ThrowCc(
226 String(__func__) + ": This is the real -> complex version, you've "
227 "called it with the wrong parameters"
228 );
229}
230
231template <> inline void LatticeFFT::rcfft(
232 Lattice<Double> &, const Lattice<DComplex> &, const Bool, Bool
233) {
234 ThrowCc(
235 String(__func__) + ": This is the real -> complex version, you've "
236 "called it with the wrong parameters"
237 );
238}
239
240template <> inline void LatticeFFT::myrcfft(
241 Lattice<Float> &, const Lattice<Complex> &, const Bool
242) {
243 ThrowCc(
244 String(__func__) + ": This is the real -> complex version, you've "
245 "called it with the wrong parameters"
246 );
247}
248
249template <> inline void LatticeFFT::myrcfft(
250 Lattice<Double> &, const Lattice<DComplex> &, const Bool
251) {
252 ThrowCc(
253 String(__func__) + ": This is the real -> complex version, you've "
254 "called it with the wrong parameters"
255 );
256}
257
258template <> inline void LatticeFFT::crfft(
260 const Vector<Bool> &, const Bool, Bool
261) {
262 ThrowCc(
263 String(__func__) + ": This is the complex -> real version, you've "
264 "called it with the wrong parameters"
265 );
266}
267
268template <> inline void LatticeFFT::crfft(
270 const Vector<Bool> &, const Bool, Bool
271) {
272 ThrowCc(
273 String(__func__) + ": This is the complex -> real version, you've "
274 "called it with the wrong parameters"
275 );
276}
277
278template <> inline void LatticeFFT::crfft(
280) {
281 ThrowCc(
282 String(__func__) + ": This is the complex -> real version, you've "
283 "called it with the wrong parameters"
284 );
285}
286
287template <> inline void LatticeFFT::crfft(
289) {
290 ThrowCc(
291 String(__func__) + ": This is the complex -> real version, you've "
292 "called it with the wrong parameters"
293 );
294}
295
296template <> inline void LatticeFFT::crfft(
297 Lattice<Complex> &, const Lattice<Float> &, const Bool, Bool
298) {
299 ThrowCc(
300 String(__func__) + ": This is the complex -> real version, you've "
301 "called it with the wrong parameters"
302 );
303}
304
305template <> inline void LatticeFFT::crfft(
306 Lattice<DComplex> &, const Lattice<Double> &, const Bool, Bool
307) {
308 ThrowCc(
309 String(__func__) + ": This is the complex -> real version, you've "
310 "called it with the wrong parameters"
311 );
312}
313
314} //# NAMESPACE CASACORE - END
315#ifndef CASACORE_NO_AUTO_TEMPLATES
316#include "LatticeFFT.tcc"
317#endif //# CASACORE_NO_AUTO_TEMPLATES
318#endif
#define ThrowCc(m)
Definition: Error.h:85
static void crfft(Lattice< typename NumericTraits< ComplexType >::ConjugateType > &out, Lattice< ComplexType > &in, const Vector< Bool > &whichAxes, const Bool doShift=True, Bool doFast=False)
N-D complex->real FFT.
static void cfft(Lattice< ComplexType > &cLattice, const Bool toFrequency=True)
N-D in-place complex->complex FFT.
static void myrcfft(Lattice< ComplexType > &out, const Lattice< typename NumericTraits< ComplexType >::ConjugateType > &in, const Vector< Bool > &whichAxes, const Bool doShift=True)
static void cfft0(Lattice< ComplexType > &cLattice, const Vector< Bool > &whichAxes, const Bool toFrequency=True)
Non-folded version.
static void crfft(Lattice< typename NumericTraits< ComplexType >::ConjugateType > &out, Lattice< ComplexType > &in, const Bool doShift=True, Bool doFast=False)
static void cfft(Lattice< ComplexType > &cLattice, const Vector< Bool > &whichAxes, const Bool toFrequency=True)
N-D in-place complex->complex FFT.
static void crfft(Lattice< typename NumericTraits< ComplexType >::ConjugateType > &out, const Lattice< ComplexType > &in, const Bool doShift=True, Bool doFast=False)
static void rcfft(Lattice< ComplexType > &out, const Lattice< typename NumericTraits< ComplexType >::ConjugateType > &in, const Bool doShift=True, Bool doFast=False)
N-D real->complex FFT.
static void cfft2d(Lattice< ComplexType > &cLattice, const Bool toFrequency=True)
2-D in-place complex->complex FFT.
static void myrcfft(Lattice< ComplexType > &out, const Lattice< typename NumericTraits< ComplexType >::ConjugateType > &in, const Bool doShift=True)
static void rcfft(Lattice< ComplexType > &out, const Lattice< typename NumericTraits< ComplexType >::ConjugateType > &in, const Vector< Bool > &whichAxes, const Bool doShift=True, Bool doFast=False)
N-D real->complex FFT.
Char ConjugateType
Conjugate (real<->complex) type.
String: the storage and methods of handling collections of characters.
Definition: String.h:225
this file contains all the compiler specific defines
Definition: mainpage.dox:28
const Bool False
Definition: aipstype.h:44
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
const Bool True
Definition: aipstype.h:43