27
27
$kernel = kernctr($image,$smallk);
28
28
fftconvolve($image,$kernel);
32
The underlying C library upon which this module is based performs FFTs
33
on both single precision and double precision floating point piddles.
34
Performing FFTs on integer data types is not reliable. Consider the
35
following FFT on piddles of type 'double':
43
But if $r and $i are unsigned short integers (ushorts):
45
$r = pdl(ushort,0,1,0,1);
49
[2 0 65534 0] [0 0 0 0]
51
This used to occur because L<PDL::PP|PDL::PP> converts the ushort
52
piddles to floats or doubles, performs the FFT on them, and then
53
converts them back to ushort, causing the overflow where the amplitude
54
of the frequency should be -2.
56
Therefore, if you pass in a piddle of integer datatype (byte, short,
57
ushort, long) to any of the routines in PDL::FFT, your data will be
58
promoted to a double-precision piddle. If you pass in a float, the
59
single-precision FFT will be performed.
63
For even-sized input arrays, the frequencies are packed like normal
64
for FFTs (where N is the size of the array and D is the physical step
65
size between elements):
67
0, 1/ND, 2/ND, ..., (N/2-1)/ND, 1/2D, -(N/2-1)/ND, ..., -1/ND.
69
which can easily be obtained (taking the Nyquist frequency to be
72
$kx = $real->xlinvals(-($N/2-1)/$N/$D,1/2/$D)->rotate(-($N/2 -1));
74
For odd-sized input arrays the Nyquist frequency is not directly
75
acessible, and the frequencies are
77
0, 1/ND, 2/ND, ..., (N/2-0.5)/ND, -(N/2-0.5)/ND, ..., -1/ND.
79
which can easily be obtained using
81
$kx = $real->xlinvals(-($N/2-0.5)/$N/$D,($N/2-0.5)/$N/$D)->rotate(-($N-1)/2);
30
84
=head1 ALTERNATIVE FFT PACKAGES
32
86
Various other modules - such as
60
Pars => '[o,nc]real(n); [o,nc]imag(n);',
61
GenericTypes => [F,D],
62
Code => '$TFD(fftnf,fftn)
63
($SIZE(n), NULL , $P(real),$P(imag), 1, 1.);',
64
Doc=>'Complex FFT of the "real" and "imag" arrays [inplace]'
68
Pars => '[o,nc]real(n); [o,nc]imag(n);',
69
GenericTypes => [F,D],
70
Code => '$TFD(fftnf,fftn)
71
($SIZE(n), NULL , $P(real),$P(imag), -1, -1.);',
72
Doc=>'Complex Inverse FFT of the "real" and "imag" arrays [inplace]'
75
pp_add_exported('',"fftnd ifftnd fftconvolve realfft realifft kernctr");
114
Pars => '[o,nc]real(n); [o,nc]imag(n);',
115
GenericTypes => [F,D],
116
Code => '$TFD(fftnf,fftn)
117
($SIZE(n), NULL , $P(real),$P(imag), 1, 1.);',
122
Pars => '[o,nc]real(n); [o,nc]imag(n);',
123
GenericTypes => [F,D],
124
Code => '$TFD(fftnf,fftn)
125
($SIZE(n), NULL , $P(real),$P(imag), -1, -1.);',
129
pp_add_exported('',"fft ifft fftnd ifftnd fftconvolve realfft realifft kernctr");
77
131
pp_addpm(<<'EOD');