1FFT(3)                User Contributed Perl Documentation               FFT(3)
2
3
4

NAME

6       PDL::FFT - FFTs for PDL
7

DESCRIPTION

9       !!!!!!!!!!!!!!!!!!!!!!!!!!WARNING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10       As of PDL-2.006_04, the direction of the FFT/IFFT has been reversed to
11       match the usage in the FFTW library and the convention in use
12       generally.
13       !!!!!!!!!!!!!!!!!!!!!!!!!!WARNING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
14
15       FFTs for PDL.  These work for arrays of any dimension, although ones
16       with small prime factors are likely to be the quickest.  The forward
17       FFT is unnormalized while the inverse FFT is normalized so that the
18       IFFT of the FFT returns the original values.
19
20       For historical reasons, these routines work in-place and do not
21       recognize the in-place flag.  That should be fixed.
22

SYNOPSIS

24               use PDL::FFT qw/:Func/;
25
26               fft($real, $imag);
27               ifft($real, $imag);
28               realfft($real);
29               realifft($real);
30
31               fftnd($real,$imag);
32               ifftnd($real,$imag);
33
34               $kernel = kernctr($image,$smallk);
35               fftconvolve($image,$kernel);
36

DATA TYPES

38       The underlying C library upon which this module is based performs FFTs
39       on both single precision and double precision floating point ndarrays.
40       Performing FFTs on integer data types is not reliable.  Consider the
41       following FFT on ndarrays of type 'double':
42
43               $r = pdl(0,1,0,1);
44               $i = zeroes($r);
45               fft($r,$i);
46               print $r,$i;
47               [2 0 -2 0] [0 0 0 0]
48
49       But if $r and $i are unsigned short integers (ushorts):
50
51               $r = pdl(ushort,0,1,0,1);
52               $i = zeroes($r);
53               fft($r,$i);
54               print $r,$i;
55               [2 0 65534 0] [0 0 0 0]
56
57       This used to occur because PDL::PP converts the ushort ndarrays to
58       floats or doubles, performs the FFT on them, and then converts them
59       back to ushort, causing the overflow where the amplitude of the
60       frequency should be -2.
61
62       Therefore, if you pass in an ndarray of integer datatype (byte, short,
63       ushort, long) to any of the routines in PDL::FFT, your data will be
64       promoted to a double-precision ndarray.  If you pass in a float, the
65       single-precision FFT will be performed.
66

FREQUENCIES

68       For even-sized input arrays, the frequencies are packed like normal for
69       FFTs (where N is the size of the array and D is the physical step size
70       between elements):
71
72        0, 1/ND, 2/ND, ..., (N/2-1)/ND, 1/2D, -(N/2-1)/ND, ..., -1/ND.
73
74       which can easily be obtained (taking the Nyquist frequency to be
75       positive) using
76
77       "$kx = $real->xlinvals(-($N/2-1)/$N/$D,1/2/$D)->rotate(-($N/2 -1));"
78
79       For odd-sized input arrays the Nyquist frequency is not directly
80       acessible, and the frequencies are
81
82        0, 1/ND, 2/ND, ..., (N/2-0.5)/ND, -(N/2-0.5)/ND, ..., -1/ND.
83
84       which can easily be obtained using
85
86       "$kx =
87       $real->xlinvals(-($N/2-0.5)/$N/$D,($N/2-0.5)/$N/$D)->rotate(-($N-1)/2);"
88

ALTERNATIVE FFT PACKAGES

90       Various other modules - such as PDL::FFTW and PDL::Slatec - contain FFT
91       routines.  However, unlike PDL::FFT, these modules are optional, and so
92       may not be installed.
93

FUNCTIONS

95   fft()
96       Complex 1-D FFT of the "real" and "imag" arrays [inplace]. A single
97       cfloat/cdouble input ndarray can also be used.
98
99         Signature: ([o,nc]real(n); [o,nc]imag(n))
100
101       fft($real,$imag);
102
103   ifft()
104       Complex inverse 1-D FFT of the "real" and "imag" arrays [inplace]. A
105       single cfloat/cdouble input ndarray can also be used.
106
107         Signature: ([o,nc]real(n); [o,nc]imag(n))
108
109       ifft($real,$imag);
110
111   realfft()
112       One-dimensional FFT of real function [inplace].
113
114       The real part of the transform ends up in the first half of the array
115       and the imaginary part of the transform ends up in the second half of
116       the array.
117
118               realfft($real);
119
120   realifft()
121       Inverse of one-dimensional realfft routine [inplace].
122
123               realifft($real);
124
125   fftnd()
126       N-dimensional FFT over all pdl dims of input (inplace)
127
128               fftnd($real,$imag);
129
130   ifftnd()
131       N-dimensional inverse FFT over all pdl dims of input (inplace)
132
133               ifftnd($real,$imag);
134
135   fftconvolve()
136       N-dimensional convolution with periodic boundaries (FFT method)
137
138               $kernel = kernctr($image,$smallk);
139               fftconvolve($image,$kernel);
140
141       fftconvolve works inplace, and returns an error array in kernel as an
142       accuracy check -- all the values in it should be negligible.
143
144       See also PDL::ImageND::convolveND, which performs speed-optimized
145       convolution with a variety of boundary conditions.
146
147       The sizes of the image and the kernel must be the same.  kernctr
148       centres a small kernel to emulate the behaviour of the direct
149       convolution routines.
150
151       The speed cross-over between using straight convolution
152       (PDL::Image2D::conv2d()) and these fft routines is for kernel sizes
153       roughly 7x7.
154
155   convmath
156         Signature: ([o,nc]a(m); [o,nc]b(m))
157
158       Internal routine doing maths for convolution
159
160       convmath does not process bad values.  It will set the bad-value flag
161       of all output ndarrays if the flag is set for any of the input
162       ndarrays.
163
164   cmul
165         Signature: (ar(); ai(); br(); bi(); [o]cr(); [o]ci())
166
167       Complex multiplication
168
169       cmul does not process bad values.  It will set the bad-value flag of
170       all output ndarrays if the flag is set for any of the input ndarrays.
171
172   cdiv
173         Signature: (ar(); ai(); br(); bi(); [o]cr(); [o]ci())
174
175       Complex division
176
177       cdiv does not process bad values.  It will set the bad-value flag of
178       all output ndarrays if the flag is set for any of the input ndarrays.
179

BUGS

181       Where the source is marked `FIX', could re-implement using phase-shift
182       factors on the transforms and some real-space bookkeeping, to save some
183       temporary space and redundant transforms.
184

AUTHOR

186       This file copyright (C) 1997, 1998 R.J.R. Williams
187       (rjrw@ast.leeds.ac.uk), Karl Glazebrook (kgb@aaoepp.aao.gov.au), Tuomas
188       J. Lukka, (lukka@husc.harvard.edu).  All rights reserved. There is no
189       warranty. You are allowed to redistribute this software / documentation
190       under certain conditions. For details, see the file COPYING in the PDL
191       distribution. If this file is separated from the PDL distribution, the
192       copyright notice should be included in the file.
193
194
195
196perl v5.34.0                      2021-08-16                            FFT(3)
Impressum