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>
38class Lattice;
39
40// <summary>Functions for Fourier transforming Lattices</summary>
41
42// <reviewed reviewer="" date="" tests="" demos="">
43// </reviewed>
44
45// <prerequisite>
46// </prerequisite>
47
48// <etymology>
49// </etymology>
50
51// <synopsis>
52// </synopsis>
53
54// <example>
55// <srcblock>
56// </srcblock>
57// </example>
58
59// <motivation>
60// </motivation>
61
62// <todo asof="">
63// </todo>
64
66 public:
67 // 2-D in-place complex->complex FFT. Transforms over the first two
68 // dimensions and iterates over all the others. The Lattice must have two or
69 // more dimensions otherwise an AipsError is thrown.
70 template <class ComplexType>
71 static void cfft2d(Lattice<ComplexType> &cLattice, const Bool toFrequency = True);
72
73 // N-D in-place complex->complex FFT. Only transform over selected
74 // dimensions. Iterate over the others. whichAxes must be the same length as
75 // the number of dimensions in the Lattice otherwise an AipsError is thrown.
76 template <class ComplexType>
77 static void cfft(Lattice<ComplexType> &cLattice, const Vector<Bool> &whichAxes,
78 const Bool toFrequency = True);
79
80 // Non-folded version
81 template <class ComplexType>
82 static void cfft0(Lattice<ComplexType> &cLattice, const Vector<Bool> &whichAxes,
83 const Bool toFrequency = True);
84
85 // N-D in-place complex->complex FFT. Transform over all axes.
86 template <class ComplexType>
87 static void cfft(Lattice<ComplexType> &cLattice, const Bool toFrequency = True);
88
89 // N-D real->complex FFT. Only one half of the Hermition result is
90 // returned. Transforms are only done on selected dimensions. The origin of
91 // the transform is the center of the Lattice ie., [nx/2,ny/2,...] if
92 // doShift is True. Otherwise it is the first element ie., [0,0,...]
93 template <class ComplexType>
94 static void rcfft(Lattice<ComplexType> &out,
96 const Vector<Bool> &whichAxes, const Bool doShift = True, Bool doFast = False);
97
98 template <class ComplexType>
99 static void myrcfft(Lattice<ComplexType> &out,
101 const Vector<Bool> &whichAxes, const Bool doShift = True);
102
103 // N-D real->complex FFT. Only one half of the Hermition result is
104 // returned. Transform over all dimensions. The origin of
105 // the transform is the center of the Lattice ie., [nx/2,ny/2,...] if
106 // doShift is True. Otherwise it is the first element ie., [0,0,...]
107 template <class ComplexType>
108 static void rcfft(Lattice<ComplexType> &out,
110 const Bool doShift = True, Bool doFast = False);
111 template <class ComplexType>
114 const Bool doShift = True);
115
116 // N-D complex->real FFT. Only one half of the Hermition input is
117 // required. If whichAxis is specified Transforms are only done on selected
118 // dimensions otherwise they are done on all axes. The origin of the
119 // transform is the center of the Lattice ie., [nx/2,ny/2,...] if doShift is
120 // True, otherwise it is the first element ie., [0,0,...]
121
122 // These functions will <b>scramble the input Lattice</b> unless the versions
123 // with const inputs are used. The const input versions are less efficient as
124 // they create a temporary Lattice and copy the input data into it.
125 // <group>
126 template <class ComplexType>
128 Lattice<ComplexType> &in, const Vector<Bool> &whichAxes,
129 const Bool doShift = True, Bool doFast = False);
130 template <class ComplexType>
132 Lattice<ComplexType> &in, const Bool doShift = True, Bool doFast = False);
133 template <class ComplexType>
135 const Lattice<ComplexType> &in, const Bool doShift = True, Bool doFast = False);
136 // </group>
137};
138
139// implement template specializations to throw exceptions in the relevant cases.
140
141template <>
143 ThrowCc(String(__func__) + ": This method does not support real-valued lattices");
144}
145
146template <>
148 ThrowCc(String(__func__) + ": This method does not support real-valued lattices");
149}
150
151template <>
152inline void LatticeFFT::cfft(Lattice<Float> &, const Vector<Bool> &, const Bool) {
153 ThrowCc(String(__func__) + ": This method does not support real-valued lattices");
154}
155
156template <>
157inline void LatticeFFT::cfft(Lattice<Double> &, const Vector<Bool> &, const Bool) {
158 ThrowCc(String(__func__) + ": This method does not support real-valued lattices");
159}
160
161template <>
163 const Bool, Bool) {
164 ThrowCc(String(__func__) +
165 ": This is the real -> complex version, you've "
166 "called it with the wrong parameters");
167}
168
169template <>
171 const Bool, Bool) {
172 ThrowCc(String(__func__) +
173 ": This is the real -> complex version, you've "
174 "called it with the wrong parameters");
175}
176
177template <>
179 const Bool) {
180 ThrowCc(String(__func__) +
181 ": This is the real -> complex version, you've "
182 "called it with the wrong parameters");
183}
184
185template <>
187 const Bool) {
188 ThrowCc(String(__func__) +
189 ": This is the real -> complex version, you've "
190 "called it with the wrong parameters");
191}
192
193template <>
195 ThrowCc(String(__func__) +
196 ": This is the real -> complex version, you've "
197 "called it with the wrong parameters");
198}
199
200template <>
202 ThrowCc(String(__func__) +
203 ": This is the real -> complex version, you've "
204 "called it with the wrong parameters");
205}
206
207template <>
209 ThrowCc(String(__func__) +
210 ": This is the real -> complex version, you've "
211 "called it with the wrong parameters");
212}
213
214template <>
216 ThrowCc(String(__func__) +
217 ": This is the real -> complex version, you've "
218 "called it with the wrong parameters");
219}
220
221template <>
223 const Bool, Bool) {
224 ThrowCc(String(__func__) +
225 ": This is the complex -> real version, you've "
226 "called it with the wrong parameters");
227}
228
229template <>
231 const Bool, Bool) {
232 ThrowCc(String(__func__) +
233 ": This is the complex -> real version, you've "
234 "called it with the wrong parameters");
235}
236
237template <>
239 ThrowCc(String(__func__) +
240 ": This is the complex -> real version, you've "
241 "called it with the wrong parameters");
242}
243
244template <>
246 ThrowCc(String(__func__) +
247 ": This is the complex -> real version, you've "
248 "called it with the wrong parameters");
249}
250
251template <>
253 ThrowCc(String(__func__) +
254 ": This is the complex -> real version, you've "
255 "called it with the wrong parameters");
256}
257
258template <>
260 ThrowCc(String(__func__) +
261 ": This is the complex -> real version, you've "
262 "called it with the wrong parameters");
263}
264
265} // namespace casacore
266#ifndef CASACORE_NO_AUTO_TEMPLATES
267#include "LatticeFFT.tcc"
268#endif // # CASACORE_NO_AUTO_TEMPLATES
269#endif
#define ThrowCc(m)
Definition Error.h:96
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:355
For temporary backward namespace compatibility, use casa as alias for casacore.
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