NB. built from project: ~Addons/math/fftw/fftw
NB. z definitions:
script_z_ '~system\main\dll.ijs'
coclass 'jfftw'
fftw_z_=: (_1 & fftwnd_jfftw_) :. (1 & fftwnd_jfftw_)
ifftw_z_=: (1 & fftwnd_jfftw_) :. (_1 & fftwnd_jfftw_)
NB. fftw utils
NB.
NB. cd 15!:0
NB. clean clean numbers near 0
NB. info cover for wdinfo
NB. matchclean if clean x-y is all 0
izero=: 23-23
ione=: 23-22
dzero=: 1.1-1.1
done=: 2.1-1.1
zzero=: 1j1-1j1
zone=: 2j1-1j1
DLL=: '"',~'"',jpath '~addons\math\fftw\jfftw.dll'
FFTW_FORWARD=: _1
FFTW_BACKWARD=: ione
FFTW_ESTIMATE=: izero
FFTW_MEASURE=: ione
FFTW_VERSION=: 2.01
cd=: 15!:0
info=: wdinfo @ ('FFTW'&;)
matchclean=: 0: *./ . = clean @ , @: -
NB. =========================================================
NB.*clean v clean numbers to tolerance (default 1e_10)
NB. sets values less than tolerance to 0
clean=: (1e_10&$:) : (4 : 0)
if. L. y do.
x clean each y
else.
if. 16 ~: 3!:0 y do.
y * x <: |y
else.
j./"1 y* x <: | y=. +.y
end.
end.
)
NB. fftw
NB. =========================================================
NB.*createplan v create a plan
NB. y = shape ; in ; out ; direction; flag
NB.
NB. direction = FFTW_FORWARD | FFTW_BACKWARD
NB. flag = FFTW_ESTIMATE | FFTW_MEASURE
createplan=: 3 : 0
'shape in out dir flag'=. y
assert dir e. FFTW_FORWARD,FFTW_BACKWARD
assert flag e. FFTW_ESTIMATE, FFTW_MEASURE
shape=. ,shape + izero
dir=. dir + izero
flag=. flag + izero
cmd=. DLL,' fftw_plan_dft + i i *i *j *j i i'
0 pick cmd cd (#shape);shape;in;out;dir;flag
)
NB. =========================================================
NB.*destroyplan v destroy a plan
destroyplan=: 3 : 0
cmd=. DLL,' fftw_destroy_plan + n i'
1 [ cmd cd y
)
NB. =========================================================
NB.*fftwnd d n-dimensional FFT
NB. x = _1 forward
NB. 1 backward
NB. y = data
fftwnd=: 4 : 0
shp=. $y
in=. zzero + , |: y
out=. in * 0
assert x e. _1 1
dir=. x + izero
plan=. createplan shp;in;out;dir;FFTW_ESTIMATE
fftwexecute plan
destroyplan plan
res=. |: (|.shp) $ out
if. dir=1 do. res % */shp end.
)
NB. =========================================================
NB.*fftwexecute d one call to n-dimensional FFT
NB. y = plan
fftwexecute=: 3 : 0
cmd=. DLL,' fftw_execute + n i'
1 [ cmd cd y
)
"bill lam" <[email protected]> wrote in message
news:[email protected]...
> David,
> J forum does not accept attachments. Please re-post with the script
> in-line text.
>
> ven, 19 Mar 2010, David Hotham skribis:
>> So it turns out, to my great surprise, that apparently I am capable
>> of making this work after all.
>>
>> Attached is a version of fftw.ijs that seems to give correct results
>> against fftw3 (on my 64-bit Windows machine, using libfftw3-3.dll
>> from http://www.fftw.org/install/windows.html). Anyone should feel
>> free to do with this what they will, at least so far as my
>> contribution to it goes.
>>
>> If there's somewhere more useful that I should submit this, do let me
>> know.
>>
>> David
>>
>>
>> "bill lam" <[email protected]> wrote in message
>> news:[email protected]...
>> [---=| TOFU protection by t-prot: 58 lines snipped |=---]
>
>
> --
> regards,
> ====================================================
> GPG key 1024D/4434BAB3 2008-08-24
> gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm