FFT.pm (PDL-2.074) | : | FFT.pm (PDL-2.075) | ||
---|---|---|---|---|
skipping to change at line 17 | skipping to change at line 17 | |||
our %EXPORT_TAGS = (Func=>\@EXPORT_OK); | our %EXPORT_TAGS = (Func=>\@EXPORT_OK); | |||
use PDL::Core; | use PDL::Core; | |||
use PDL::Exporter; | use PDL::Exporter; | |||
use DynaLoader; | use DynaLoader; | |||
our @ISA = ( 'PDL::Exporter','DynaLoader' ); | our @ISA = ( 'PDL::Exporter','DynaLoader' ); | |||
push @PDL::Core::PP, __PACKAGE__; | push @PDL::Core::PP, __PACKAGE__; | |||
bootstrap PDL::FFT ; | bootstrap PDL::FFT ; | |||
#line 7 "fft.pd" | #line 6 "fft.pd" | |||
=head1 NAME | =head1 NAME | |||
PDL::FFT - FFTs for PDL | PDL::FFT - FFTs for PDL | |||
=head1 DESCRIPTION | =head1 DESCRIPTION | |||
!!!!!!!!!!!!!!!!!!!!!!!!!!WARNING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | !!!!!!!!!!!!!!!!!!!!!!!!!!WARNING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |||
As of PDL-2.006_04, the direction of the FFT/IFFT has been | As of PDL-2.006_04, the direction of the FFT/IFFT has been | |||
reversed to match the usage in the FFTW library and the convention | reversed to match the usage in the FFTW library and the convention | |||
in use generally. | in use generally. | |||
skipping to change at line 93 | skipping to change at line 94 | |||
C<< $kx = $real->xlinvals(-($N/2-0.5)/$N/$D,($N/2-0.5)/$N/$D)->rotate(-($N-1)/2) ; >> | C<< $kx = $real->xlinvals(-($N/2-0.5)/$N/$D,($N/2-0.5)/$N/$D)->rotate(-($N-1)/2) ; >> | |||
=head1 ALTERNATIVE FFT PACKAGES | =head1 ALTERNATIVE FFT PACKAGES | |||
Various other modules - such as L<PDL::FFTW3> and L<PDL::Slatec> - | Various other modules - such as L<PDL::FFTW3> and L<PDL::Slatec> - | |||
contain FFT routines. | contain FFT routines. | |||
However, unlike PDL::FFT, these modules are optional, | However, unlike PDL::FFT, these modules are optional, | |||
and so may not be installed. | and so may not be installed. | |||
=cut | =cut | |||
#line 102 "FFT.pm" | #line 103 "FFT.pm" | |||
=head1 FUNCTIONS | =head1 FUNCTIONS | |||
=cut | =cut | |||
#line 1059 "../../blib/lib/PDL/PP.pm" | #line 1058 "../../blib/lib/PDL/PP.pm" | |||
=head2 fft | =head2 fft | |||
=for sig | =for sig | |||
Signature: ([io]real(n); [io]imag(n)) | Signature: ([io]real(n); [io]imag(n)) | |||
=for ref | =for ref | |||
Complex 1-D FFT of the "real" and "imag" arrays [inplace]. A single | Complex 1-D FFT of the "real" and "imag" arrays [inplace]. A single | |||
skipping to change at line 123 | skipping to change at line 124 | |||
fft($real,$imag); | fft($real,$imag); | |||
fft($complex); | fft($complex); | |||
=for bad | =for bad | |||
fft does not process bad values. | fft does not process bad values. | |||
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. | It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. | |||
=cut | =cut | |||
#line 143 "FFT.pm" | #line 145 "FFT.pm" | |||
#line 1059 "../../blib/lib/PDL/PP.pm" | ||||
#line 1060 "../../blib/lib/PDL/PP.pm" | ||||
sub PDL::fft { | sub PDL::fft { | |||
# Convert the first argument to decimal and check for trouble. | # Convert the first argument to decimal and check for trouble. | |||
my ($re, $im) = @_; | my ($re, $im) = @_; | |||
if (!$re->type->real) { | if (!$re->type->real) { | |||
$im=$re->im; | $im=$re->im; | |||
$re=$re->re; | $re=$re->re; | |||
} | } | |||
eval { todecimal($re); }; | eval { todecimal($re); }; | |||
if ($@) { | if ($@) { | |||
$@ =~ s/ at .*//s; | $@ =~ s/ at .*//s; | |||
skipping to change at line 154 | skipping to change at line 156 | |||
if ($message =~ /undefined value/); | if ($message =~ /undefined value/); | |||
barf($message); | barf($message); | |||
} | } | |||
PDL::_fft_int($re,$im); | PDL::_fft_int($re,$im); | |||
if (!$_[0]->type->real) { | if (!$_[0]->type->real) { | |||
$_[0]= czip($re, $im); | $_[0]= czip($re, $im); | |||
} else { | } else { | |||
$_[0]=$re,$_[1]=$im; | $_[0]=$re,$_[1]=$im; | |||
} | } | |||
} | } | |||
#line 176 "FFT.pm" | #line 179 "FFT.pm" | |||
#line 1060 "../../blib/lib/PDL/PP.pm" | ||||
#line 1061 "../../blib/lib/PDL/PP.pm" | ||||
*fft = \&PDL::fft; | *fft = \&PDL::fft; | |||
#line 182 "FFT.pm" | #line 186 "FFT.pm" | |||
#line 1059 "../../blib/lib/PDL/PP.pm" | #line 1058 "../../blib/lib/PDL/PP.pm" | |||
=head2 ifft | =head2 ifft | |||
=for sig | =for sig | |||
Signature: ([io]real(n); [io]imag(n)) | Signature: ([io]real(n); [io]imag(n)) | |||
=for ref | =for ref | |||
Complex inverse 1-D FFT of the "real" and "imag" arrays [inplace]. A single | Complex inverse 1-D FFT of the "real" and "imag" arrays [inplace]. A single | |||
skipping to change at line 184 | skipping to change at line 187 | |||
ifft($real,$imag); | ifft($real,$imag); | |||
ifft($complex); | ifft($complex); | |||
=for bad | =for bad | |||
ifft does not process bad values. | ifft does not process bad values. | |||
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. | It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. | |||
=cut | =cut | |||
#line 213 "FFT.pm" | #line 218 "FFT.pm" | |||
#line 1059 "../../blib/lib/PDL/PP.pm" | ||||
#line 1060 "../../blib/lib/PDL/PP.pm" | ||||
sub PDL::ifft { | sub PDL::ifft { | |||
# Convert the first argument to decimal and check for trouble. | # Convert the first argument to decimal and check for trouble. | |||
my ($re, $im) = @_; | my ($re, $im) = @_; | |||
if (!$re->type->real) { | if (!$re->type->real) { | |||
$im=$re->im; | $im=$re->im; | |||
$re=$re->re; | $re=$re->re; | |||
} | } | |||
eval { todecimal($re); }; | eval { todecimal($re); }; | |||
if ($@) { | if ($@) { | |||
$@ =~ s/ at .*//s; | $@ =~ s/ at .*//s; | |||
skipping to change at line 215 | skipping to change at line 219 | |||
if ($message =~ /undefined value/); | if ($message =~ /undefined value/); | |||
barf($message); | barf($message); | |||
} | } | |||
PDL::_ifft_int($re,$im); | PDL::_ifft_int($re,$im); | |||
if (!$_[0]->type->real) { | if (!$_[0]->type->real) { | |||
$_[0]= czip($re, $im); | $_[0]= czip($re, $im); | |||
} else { | } else { | |||
$_[0]=$re,$_[1]=$im; | $_[0]=$re,$_[1]=$im; | |||
} | } | |||
} | } | |||
#line 246 "FFT.pm" | #line 252 "FFT.pm" | |||
#line 1060 "../../blib/lib/PDL/PP.pm" | ||||
#line 1061 "../../blib/lib/PDL/PP.pm" | ||||
*ifft = \&PDL::ifft; | *ifft = \&PDL::ifft; | |||
#line 252 "FFT.pm" | #line 259 "FFT.pm" | |||
#line 185 "fft.pd" | ||||
#line 186 "fft.pd" | ||||
use Carp; | use Carp; | |||
use PDL::Core qw/:Func/; | use PDL::Core qw/:Func/; | |||
use PDL::Basic qw/:Func/; | use PDL::Basic qw/:Func/; | |||
use PDL::Types; | use PDL::Types; | |||
use PDL::ImageND qw/kernctr/; # moved to ImageND since FFTW uses it too | use PDL::ImageND qw/kernctr/; # moved to ImageND since FFTW uses it too | |||
use PDL::Ops qw/czip/; | use PDL::Ops qw/czip/; | |||
sub todecimal { | sub todecimal { | |||
my ($arg) = @_; | my ($arg) = @_; | |||
$arg = $arg->double if $arg->type->integer; | $arg = $arg->double if $arg->type->integer; | |||
skipping to change at line 422 | skipping to change at line 428 | |||
barf "Must have image & kernel for fftconvolve" if $#_ != 1; | barf "Must have image & kernel for fftconvolve" if $#_ != 1; | |||
my ($im, $k) = map $_->r2C, @_; | my ($im, $k) = map $_->r2C, @_; | |||
fftnd($im); | fftnd($im); | |||
fftnd($k); | fftnd($k); | |||
my $c = $im * $k; | my $c = $im * $k; | |||
ifftnd($c); | ifftnd($c); | |||
$_[0] = $c->re->sever; | $_[0] = $c->re->sever; | |||
$_[1] = $c->im->sever; | $_[1] = $c->im->sever; | |||
@_; | @_; | |||
} | } | |||
#line 457 "FFT.pm" | #line 465 "FFT.pm" | |||
#line 388 "fft.pd" | ||||
#line 389 "fft.pd" | ||||
=head1 BUGS | =head1 BUGS | |||
Where the source is marked `FIX', could re-implement using phase-shift | Where the source is marked `FIX', could re-implement using phase-shift | |||
factors on the transforms and some real-space bookkeeping, to save | factors on the transforms and some real-space bookkeeping, to save | |||
some temporary space and redundant transforms. | some temporary space and redundant transforms. | |||
=head1 AUTHOR | =head1 AUTHOR | |||
This file copyright (C) 1997, 1998 R.J.R. Williams | This file copyright (C) 1997, 1998 R.J.R. Williams | |||
(rjrw@ast.leeds.ac.uk), Karl Glazebrook (kgb@aaoepp.aao.gov.au), | (rjrw@ast.leeds.ac.uk), Karl Glazebrook (kgb@aaoepp.aao.gov.au), | |||
Tuomas J. Lukka, (lukka@husc.harvard.edu). All rights reserved. There | Tuomas J. Lukka, (lukka@husc.harvard.edu). All rights reserved. There | |||
is no warranty. You are allowed to redistribute this software / | is no warranty. You are allowed to redistribute this software / | |||
documentation under certain conditions. For details, see the file | documentation under certain conditions. For details, see the file | |||
COPYING in the PDL distribution. If this file is separated from the | COPYING in the PDL distribution. If this file is separated from the | |||
PDL distribution, the copyright notice should be included in the file. | PDL distribution, the copyright notice should be included in the file. | |||
=cut | =cut | |||
#line 481 "FFT.pm" | #line 490 "FFT.pm" | |||
# Exit with OK status | # Exit with OK status | |||
1; | 1; | |||
End of changes. 18 change blocks. | ||||
18 lines changed or deleted | 25 lines changed or added |