From 2cecd0d85296320f8e254fc8046cb8ff24bdcfe4 Mon Sep 17 00:00:00 2001 From: Ed J Date: Thu, 28 Nov 2024 20:45:26 +0000 Subject: [PATCH] use fftw_malloc not _alloc_real, broadcastloop c2r so only malloc once --- Makefile.PL | 4 ++-- fftw3.pd | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Makefile.PL b/Makefile.PL index 162fc71..a51e281 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -54,10 +54,10 @@ $descriptor{INC} = '' unless defined $descriptor{INC}; $descriptor{INC} .= " $cflags"; $descriptor{PREREQ_PM} = { - 'PDL' => '2.049', # as_native + 'PDL' => '2.075', # broadcastloop }; $descriptor{CONFIGURE_REQUIRES} = { - 'PDL' => '2.049', + 'PDL' => '2.075', 'IPC::Run' =>0, # 'Alien::FFTW3' =>0, }; diff --git a/fftw3.pd b/fftw3.pd index 80cdf54..ca7b74a 100644 --- a/fftw3.pd +++ b/fftw3.pd @@ -52,22 +52,22 @@ static_assert_fftw(sizeof($GENERIC()) == sizeof($TGC(fftwf_,fftw_)complex)); $TGC(fftwf_,fftw_)plan plan = INT2PTR($TGC(fftwf_,fftw_)plan, $COMP(plan)); // FFTW inverse real transforms clobber their input. I thus make a new // buffer and transform from there -unsigned long nelem = 1; -PDL_Indx i, rank = $PRIV(vtable)->par_realdims[0]; -for( i=0; idims[i]; -unsigned long elem_scale = sizeof($GENERIC()) / sizeof( $TGC(float,double) ); /* native complex */ -void *input_copy = $TGC(fftwf_,fftw_)alloc_real( nelem * elem_scale ); -memcpy( input_copy, $P(complexv), sizeof($GENERIC()) * nelem ); -$TGC(fftwf_,fftw_)execute_dft_c2r( plan, (void*)input_copy, (void*)$P(real) ); -$TGC(fftwf_,fftw_)free( input_copy ); +PDL_Indx i, nbytes = sizeof($GENERIC()); +PDL_Indx rank = $PRIV(vtable)->par_realdims[0], *dims = $PDL(complexv)->dims; +for (i=0; i