From 26ac555f0cac44ee5ebda8a2dff46ad968587462 Mon Sep 17 00:00:00 2001 From: Ed J Date: Mon, 22 Mar 2021 16:52:59 +0000 Subject: [PATCH] use X not N for FFT rank description --- .gitignore | 4 ++-- FFTW3.pd | 1 - FFTW3_header_include.pm | 41 ++++++++++++----------------------------- README.pod | 14 +++++++------- 4 files changed, 21 insertions(+), 39 deletions(-) diff --git a/.gitignore b/.gitignore index cd59e31..880bdc9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,8 @@ patches/ PDL-FFTW3-*.tar.gz *~ -*.o -*.c +FFTW3.o +FFTW3.c *.bs FFTW3.pm FFTW3.xs diff --git a/FFTW3.pd b/FFTW3.pd index a9e0805..8ead2c2 100644 --- a/FFTW3.pd +++ b/FFTW3.pd @@ -148,7 +148,6 @@ sub generateDefinitions $pp_def{Code} = slurp('template_complex.c'); pp_def( "__fft$rank", %pp_def ); - ################################################################################## ####### now I generate the definitions for the real-complex and complex-real cases my @dims_real = @dims; diff --git a/FFTW3_header_include.pm b/FFTW3_header_include.pm index b8999d6..8262347 100644 --- a/FFTW3_header_include.pm +++ b/FFTW3_header_include.pm @@ -17,8 +17,7 @@ our $_last_do_double_precision; # PP-generated internals. Specifically, this function is called BEFORE any PDL # threading happens. Here I make sure the FFTW plan exists, or if it doesn't, I # make it. Thus the PP-based internals can safely assume that the plan exists -sub __fft_internal -{ +sub __fft_internal { my $thisfunction = shift; my ($do_inverse_fft, $is_real_fft, $rank) = $thisfunction =~ /^(i?)((?:r)?).*fft([0-9]+)/; @@ -29,31 +28,22 @@ sub __fft_internal my $Nargs = scalar @_; my ($in, $out); - if( $Nargs == 2 ) - { + if ( $Nargs == 2 ) { # all variables on stack, read in output and temp vars ($in, $out) = map {defined $_ ? PDL::Core::topdl($_) : $_} @_; - } - elsif( $Nargs == 1 ) - { + } elsif ( $Nargs == 1 ) { $in = PDL::Core::topdl $_[0]; - if( $in->is_inplace ) - { + if ( $in->is_inplace ) { barf <set_inplace(0); - } - else - { + } else { $out = PDL::null(); } - } - else - { + } else { barf( <isnull ) - { + if ( $out->isnull ) { my @dims = getOutDims($in, $is_real_fft, $do_inverse_fft); $out .= zeros($in->type, @dims); } @@ -95,25 +84,19 @@ EOF return $out; } -sub getOutDims -{ +sub getOutDims { my ($in, $is_real_fft, $do_inverse_fft) = @_; my @dims = $in->dims; - if ( !$is_real_fft ) - { + if ( !$is_real_fft ) { # complex fft. Output is the same size as the input. - } - elsif ( !$do_inverse_fft ) - { + } elsif ( !$do_inverse_fft ) { # forward real fft my $d0 = shift @dims; unshift @dims, 1+int($d0/2); unshift @dims, 2; - } - else - { + } else { # backward real fft # # there's an ambiguity here. I want int($out->dim(0)/2) + 1 == $in->dim(1), diff --git a/README.pod b/README.pod index 559e314..4a12416 100644 --- a/README.pod +++ b/README.pod @@ -197,7 +197,7 @@ including PDL. =head1 FUNCTIONS -=head2 fftN (fft1, fft2, fft3, ..., fftn) +=head2 fftX (fft1, fft2, fft3, ..., fftn) The basic complex <-> complex FFT. You can pass in the rank as a parameter with the C form, or append the rank to the function @@ -208,7 +208,7 @@ the last argument. If the output piddle is passed in, the user I make sure the dimensions match. The 0 dim of the input PDL must have size 2 and run over (real,imaginary) -components. The transform is carried out over dims 1 through N. +components. The transform is carried out over dims 1 through X. The fftn form takes a minimum of two arguments: the PDL to transform, and the number of dimensions to transform as a separate argument. @@ -220,17 +220,17 @@ The following are equivalent: fft1( $x, my $X = $x->zeros ); -=head2 ifftN (ifft1, ifft2, ifft3, ..., fftn) +=head2 ifftX (ifft1, ifft2, ifft3, ..., ifftn) The basic, properly normalized, complex <-> complex backward -FFT. Everything is exactly like in the C functions, except the +FFT. Everything is exactly like in the C functions, except the inverse transform is computed and normalized, so that (for example) ifft1( fft1 ( $x ) ) is a good approximation of C<$x> itself. -=head2 rfftN (rfft1, rfft2, rfft3, ..., rfftn) +=head2 rfftX (rfft1, rfft2, rfft3, ..., rfftn) The real -> complex FFT. You can pass in the rank with the C form, or append the rank to the function name for ranks up to 9. @@ -248,12 +248,12 @@ The following are equivalent: $X = rfft1( $x ); rfft1( $x, my $X = $x->zeroes ); -=head2 irfftN (irfft1, irfft2, irfft3, ..., irfftn) +=head2 irfftX (irfft1, irfft2, irfft3, ..., irfftn) The complex -> real inverse FFT. You can pass in the rank with the C form, or append the rank to the function name for ranks up to 9. Argument passing and interpretation is as described in -C above. Please read L for details about dimension +C above. Please read L for details about dimension interpretation. There's an ambiguity about the output dimensionality, which is described in that section.