casacore
Loading...
Searching...
No Matches
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: casa-feedback@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#ifndef LATTICES_LATTICEFFT_H
27#define LATTICES_LATTICEFFT_H
28
29#include <casacore/casa/aips.h>
30#include <casacore/casa/BasicSL/Complex.h>
31#include <casacore/casa/Exceptions/Error.h>
32#include <casacore/scimath/Mathematics/NumericTraits.h>
33#include <casacore/casa/Arrays/ArrayFwd.h>
34
35namespace casacore { //# NAMESPACE CASACORE - BEGIN
36
37template <class T> class Lattice;
38
39// <summary>Functions for Fourier transforming Lattices</summary>
40
41// <reviewed reviewer="" date="" tests="" demos="">
42// </reviewed>
43
44// <prerequisite>
45// </prerequisite>
46
47// <etymology>
48// </etymology>
49
50// <synopsis>
51// </synopsis>
52
53// <example>
54// <srcblock>
55// </srcblock>
56// </example>
57
58// <motivation>
59// </motivation>
60
61// <todo asof="">
62// </todo>
63
65{
66
67public:
68 // 2-D in-place complex->complex FFT. Transforms over the first two
69 // dimensions and iterates over all the others. The Lattice must have two or
70 // more dimensions otherwise an AipsError is thrown.
71 template <class ComplexType> static void cfft2d(
72 Lattice<ComplexType> & cLattice, const Bool toFrequency=True
73 );
74
75 // N-D in-place complex->complex FFT. Only transform over selected
76 // dimensions. Iterate over the others. whichAxes must be the same length as
77 // the number of dimensions in the Lattice otherwise an AipsError is thrown.
78 template <class ComplexType> static void cfft(Lattice<ComplexType> & cLattice,
79 const Vector<Bool> & whichAxes, const Bool toFrequency=True);
80
81 // Non-folded version
82 template <class ComplexType> static void cfft0(Lattice<ComplexType> & cLattice,
83 const Vector<Bool> & whichAxes, const Bool toFrequency=True);
84
85 // N-D in-place complex->complex FFT. Transform over all axes.
86 template <class ComplexType> static void cfft(
87 Lattice<ComplexType> & cLattice, const Bool toFrequency=True
88 );
89
90 // N-D real->complex FFT. Only one half of the Hermition result is
91 // returned. Transforms are only done on selected dimensions. The origin of
92 // the transform is the center of the Lattice ie., [nx/2,ny/2,...] if
93 // doShift is True. Otherwise it is the first element ie., [0,0,...]
94 template <class ComplexType> static void rcfft(
97 const Vector<Bool> & whichAxes, const Bool doShift=True,
98 Bool doFast=False
99 );
100
101 template <class ComplexType> static void myrcfft(
104 const Vector<Bool> & whichAxes, const Bool doShift=True
105 );
106
107 // N-D real->complex FFT. Only one half of the Hermition result is
108 // returned. Transform over all dimensions. The origin of
109 // the transform is the center of the Lattice ie., [nx/2,ny/2,...] if
110 // doShift is True. Otherwise it is the first element ie., [0,0,...]
111 template <class ComplexType> static void rcfft(
114 const Bool doShift=True, Bool doFast=False
115 );
116 template <class ComplexType> static void myrcfft(
119 const Bool doShift=True
120 );
121
122 // N-D complex->real FFT. Only one half of the Hermition input is
123 // required. If whichAxis is specified Transforms are only done on selected
124 // dimensions otherwise they are done on all axes. The origin of the
125 // transform is the center of the Lattice ie., [nx/2,ny/2,...] if doShift is
126 // True, otherwise it is the first element ie., [0,0,...]
127
128 // These functions will <b>scramble the input Lattice</b> unless the versions
129 // with const inputs are used. The const input versions are less efficient as
130 // they create a temporary Lattice and copy the input data into it.
131 // <group>
132 template <class ComplexType> static void crfft(
134 Lattice<ComplexType> & in, const Vector<Bool> & whichAxes,
135 const Bool doShift=True, Bool doFast=False
136 );
137 template <class ComplexType> static void crfft(
139 Lattice<ComplexType> & in, const Bool doShift=True, Bool doFast=False
140 );
141 template <class ComplexType> static void crfft(
143 const Lattice<ComplexType> & in,
144 const Bool doShift=True, Bool doFast=False
145 );
146 // </group>
147};
148
149// implement template specializations to throw exceptions in the relevant cases.
150
151template <> inline void LatticeFFT::cfft2d(Lattice<Float>&, const Bool) {
152 ThrowCc(
153 String(__func__) +": This method does not support real-valued lattices"
154 );
155}
156
157template <> inline void LatticeFFT::cfft2d(Lattice<Double>&, const Bool) {
158 ThrowCc(
159 String(__func__) + ": This method does not support real-valued lattices"
160 );
161}
162
163template <> inline void LatticeFFT::cfft(
164 Lattice<Float>&, const Vector<Bool>&, const Bool
165) {
166 ThrowCc(
167 String(__func__) + ": This method does not support real-valued lattices"
168 );
169}
170
171template <> inline void LatticeFFT::cfft(
172 Lattice<Double>&, const Vector<Bool>&, const Bool
173) {
174 ThrowCc(
175 String(__func__) + ": This method does not support real-valued lattices"
176 );
177}
178
179template <> inline void LatticeFFT::rcfft(
180 Lattice<Float> &, const Lattice<Complex> &, const Vector<Bool> & ,
181 const Bool, Bool
182) {
183 ThrowCc(
184 String(__func__) + ": This is the real -> complex version, you've "
185 "called it with the wrong parameters"
186 );
187}
188
189template <> inline void LatticeFFT::rcfft(
191 const Bool, Bool
192) {
193 ThrowCc(
194 String(__func__) + ": This is the real -> complex version, you've "
195 "called it with the wrong parameters"
196 );
197}
198
199template <> inline void LatticeFFT::myrcfft(
201 const Vector<Bool> &, const Bool
202) {
203 ThrowCc(
204 String(__func__) + ": This is the real -> complex version, you've "
205 "called it with the wrong parameters"
206 );
207}
208
209template <> inline void LatticeFFT::myrcfft(
211 const Vector<Bool> &, const Bool
212) {
213 ThrowCc(
214 String(__func__) + ": This is the real -> complex version, you've "
215 "called it with the wrong parameters"
216 );
217}
218
219template <> inline void LatticeFFT::rcfft(
220 Lattice<Float> &, const Lattice<Complex> &, const Bool, Bool
221) {
222 ThrowCc(
223 String(__func__) + ": This is the real -> complex version, you've "
224 "called it with the wrong parameters"
225 );
226}
227
228template <> inline void LatticeFFT::rcfft(
229 Lattice<Double> &, const Lattice<DComplex> &, const Bool, Bool
230) {
231 ThrowCc(
232 String(__func__) + ": This is the real -> complex version, you've "
233 "called it with the wrong parameters"
234 );
235}
236
237template <> inline void LatticeFFT::myrcfft(
238 Lattice<Float> &, const Lattice<Complex> &, const Bool
239) {
240 ThrowCc(
241 String(__func__) + ": This is the real -> complex version, you've "
242 "called it with the wrong parameters"
243 );
244}
245
246template <> inline void LatticeFFT::myrcfft(
247 Lattice<Double> &, const Lattice<DComplex> &, const Bool
248) {
249 ThrowCc(
250 String(__func__) + ": This is the real -> complex version, you've "
251 "called it with the wrong parameters"
252 );
253}
254
255template <> inline void LatticeFFT::crfft(
257 const Vector<Bool> &, const Bool, Bool
258) {
259 ThrowCc(
260 String(__func__) + ": This is the complex -> real version, you've "
261 "called it with the wrong parameters"
262 );
263}
264
265template <> inline void LatticeFFT::crfft(
267 const Vector<Bool> &, const Bool, Bool
268) {
269 ThrowCc(
270 String(__func__) + ": This is the complex -> real version, you've "
271 "called it with the wrong parameters"
272 );
273}
274
275template <> inline void LatticeFFT::crfft(
277) {
278 ThrowCc(
279 String(__func__) + ": This is the complex -> real version, you've "
280 "called it with the wrong parameters"
281 );
282}
283
284template <> inline void LatticeFFT::crfft(
286) {
287 ThrowCc(
288 String(__func__) + ": This is the complex -> real version, you've "
289 "called it with the wrong parameters"
290 );
291}
292
293template <> inline void LatticeFFT::crfft(
294 Lattice<Complex> &, const Lattice<Float> &, const Bool, Bool
295) {
296 ThrowCc(
297 String(__func__) + ": This is the complex -> real version, you've "
298 "called it with the wrong parameters"
299 );
300}
301
302template <> inline void LatticeFFT::crfft(
303 Lattice<DComplex> &, const Lattice<Double> &, const Bool, Bool
304) {
305 ThrowCc(
306 String(__func__) + ": This is the complex -> real version, you've "
307 "called it with the wrong parameters"
308 );
309}
310
311} //# NAMESPACE CASACORE - END
312#ifndef CASACORE_NO_AUTO_TEMPLATES
313#include "LatticeFFT.tcc"
314#endif //# CASACORE_NO_AUTO_TEMPLATES
315#endif
#define ThrowCc(m)
Definition Error.h:83
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:223
this file contains all the compiler specific defines
Definition mainpage.dox:28
const Bool False
Definition aipstype.h:42
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
const Bool True
Definition aipstype.h:41