Skip to content

Commit

Permalink
allow complex inputs that are PDL::Complex
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Mar 20, 2021
1 parent dd6727f commit a52becb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
- allow complex inputs that are PDL::Complex

0.07 2021-02-21
- change param names from "complex" which clashes with complex.h

Expand Down
2 changes: 1 addition & 1 deletion FFTW3_header_include.pm
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ EOF
my $type = ref $arg;
$type = 'scalar' unless defined $arg;

barf <<EOF unless ref $arg && ref $arg eq 'PDL';
barf <<EOF unless ref $arg && ($type eq 'PDL' or (!$is_real_fft and $type eq 'PDL::Complex'));
$thisfunction arguments must be of type 'PDL'. Instead I got an arg of
type '$type'. Giving up.
EOF
Expand Down
4 changes: 4 additions & 0 deletions t/fftw.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use Test::More;
use PDL::LiteF;
use PDL::Types;
use PDL::FFTW3;
use PDL::Complex;

# Please be careful about rearranging these tests, since they depend on the
# global FFTW plan cache, and thus order can matter.
Expand Down Expand Up @@ -55,6 +56,9 @@ my $Nplans = 0;
ok_should_make_plan( all( approx( fft1(float $x), float($Xref), approx_eps_single) ),
"Basic 1D complex FFT - single precision" );

ok_should_make_plan( all( approx( fft1(cplx $x), $Xref, approx_eps_double) ),
"Basic 1D complex FFT with PDL::Complex" );

ok_should_make_plan( all( approx( ifft1(fft1($x)), $x , approx_eps_double) ),
"Basic 1D complex FFT - inverse(forward) should be the same (normalized)" );
}
Expand Down

0 comments on commit a52becb

Please sign in to comment.