ich habe eben einen kleinen Wrapper für FFTW3 geschrieben, der aber noch nicht vollständig ist.
Kann mal jemand für mich ausprobieren, was man unter Windows tun muss, damit der Import funktioniert? Ich will das in naher Zukunft in Codes, Tipps und Tricks setzen. Und da wäre es natürlich vorteilhaft, wenn es nicht nur unter Linux funktioniert.
Hier ist die Installationsanleitung für Windows: Windows Installation Notes
Code: Alles auswählen
; Die Funktionen für verschiedene Datentypen haben die folgenden Präfixe
; Double : fftw_
; Float : fftwf_
; Long Double : fftwl_
; Quad : fftwq_
Macro size_t
i
EndMacro
Macro DQ
"
EndMacro
#FFTW_FORWARD = -1
#FFTW_BACKWARD = 1
#FFTW_NO_TIMELIMIT = -1.0
; documented flags
#FFTW_MEASURE = (0)
#FFTW_DESTROY_INPUT = (1 << 0)
#FFTW_UNALIGNED = (1 << 1)
#FFTW_CONSERVE_MEMORY = (1 << 2)
#FFTW_EXHAUSTIVE = (1 << 3) ; NO_EXHAUSTIVE is Default
#FFTW_PRESERVE_INPUT = (1 << 4) ; cancels FFTW_DESTROY_INPUT
#FFTW_PATIENT = (1 << 5) ; IMPATIENT is Default
#FFTW_ESTIMATE = (1 << 6)
#FFTW_WISDOM_ONLY = (1 << 21)
; undocumented beyond-guru flags
#FFTW_ESTIMATE_PATIENT = (1 << 7)
#FFTW_BELIEVE_PCOST = (1 << 8)
#FFTW_NO_DFT_R2HC = (1 << 9)
#FFTW_NO_NONTHREADED = (1 << 10)
#FFTW_NO_BUFFERING = (1 << 11)
#FFTW_NO_INDIRECT_OP = (1 << 12)
#FFTW_ALLOW_LARGE_GENERIC = (1 << 13) ; NO_LARGE_GENERIC is Default
#FFTW_NO_RANK_SPLITS = (1 << 14)
#FFTW_NO_VRANK_SPLITS = (1 << 15)
#FFTW_NO_VRECURSE = (1 << 16)
#FFTW_NO_SIMD = (1 << 17)
#FFTW_NO_SLOW = (1 << 18)
#FFTW_NO_FIXED_RADIX_LARGE_N = (1 << 19)
#FFTW_ALLOW_PRUNING = (1 << 20)
Macro fftwDefineApi(X, R, library)
Structure X#_complexArray
R.R[2]
EndStructure
Structure X#_complex
StructureUnion
R.R[2]
c.X#_complexArray[0]
EndStructureUnion
EndStructure
Structure X#_plan
EndStructure
Structure X#_iodim
n.l
is.l
os.l
EndStructure
Structure X#_iodim64
n.i
is.i
os.i
EndStructure
Structure X#_R
R.R[0]
EndStructure
ImportC DQ#-l#library#DQ
X#_execute(*p.X#_plan) ;return void
X#_plan_dft.i(rank.l, *n.Long,
*in.X#_complex, *out.X#_complex, sign.l, flags.l) ;return *X#_plan
X#_plan_dft_1d.i(n.l, *in.X#_complex, *out.X#_complex, sign.l,
flags.l) ;return *X#_plan
X#_plan_dft_2d.i(n0.l, n1.l,
*in.X#_complex, *out.X#_complex, sign.l, flags.l) ;return *X#_plan
X#_plan_dft_3d.i(n0.l, n1.l, n2.l,
*in.X#_complex, *out.X#_complex, sign.l, flags.l) ;return *X#_plan
X#_plan_many_dft.i(rank.l, *n.Long,
howmany.l,
*in.X#_complex, *inembed.Long,
istride.l, idist.l,
*out.X#_complex, *onembed.Long,
ostride.l, odist.l,
sign.l, flags.l) ;return *X#_plan
X#_plan_guru_dft.i(rank.l, *dims.X#_iodim,
howmany_rank.l,
*howmany_dims.X#_iodim,
*ri.x#_R, *ii.x#_R, *ro.x#_R, *io.x#_R,
flags.l) ;return *X#_plan
X#_plan_guru_split_sft.i(rank.l, *dims.X#_iodim,
howmany_rank.l,
*howmany_dims.X#_iodim,
*ri.x#_R, *ii.x#_R, *ro.x#_R, *io.x#_R,
flags.l) ;return *X#_plan
X#_plan_guru64_dft.i(rank.l,
*dims.X#_iodim64,
howmany_rank.l,
*howmany_dims.X#_iodim64,
*in.X#_complex, *out.X#_complex,
sign.l, flags.l) ;return *X#_plan
X#_plan_guru64_split_dft.i(rank.l,
*dims.X#_iodim64,
howmany_rank.l,
*howmany_dims.X#_iodim64,
*ri.x#_R, *ii.x#_R, *ro.x#_R, *io.x#_R,
flags.l) ;return void
X#_execute_dft(*p.X#_plan, *in.X#_complex, *out.X#_complex)
X#_execute_split_dft(*p.X#_plan, *ri.x#_R, *ii.x#_R,
*ro.x#_R, *io.x#_R) ;return void
X#_destroy_plan(*p.X#_plan) ;return void
X#_forget_wisdom() ;return void
X#_cleanup() ;return void
X#_set_timelimit(t.d) ;return void
X#_malloc.i(n.size_t) ;return pointer
X#_alloc_real.i(n.size_t) ;return X#_R
X#_alloc_complex.i(n.size_t) ;return X#_complex
X#_free(*p)
EndImport
EndMacro
fftwDefineApi(fftw, d, fftw3)
fftwDefineApi(fftwf, f, fftw3f)
EnableExplicit
CompilerIf #PB_Compiler_IsMainFile
OpenConsole()
#n = 32
Define.fftw_complex *in, *out
Define.fftw_plan *plan
*in = fftw_malloc(SizeOf(fftw_complex) * #n)
*out = fftw_malloc(SizeOf(fftw_complex) * #n)
Define time.i = ElapsedMilliseconds()
*plan = fftw_plan_dft_1d(#n, *in, *out, #FFTW_FORWARD, #FFTW_MEASURE)
time = ElapsedMilliseconds() - time
PrintN("Plan: " + time + " ms")
Define i.i
For i = 0 To #n - 1
*in\c[i]\d[0] = Cos(2 * #PI * i / #n)
*in\c[i]\d[1] = Sin(2 * #PI * i / #n)
PrintN(RSet(Str(i), 5, " ") + " = " + StrD(*in\c[i]\d[0]))
Next
time = ElapsedMilliseconds()
fftw_execute(*plan)
time = ElapsedMilliseconds() - time
PrintN("Execute: " + time + " ms")
For i = 0 To #n - 1
PrintN(RSet(Str(i), 5, " ") + " = " + RSet(StrD(*out\c[i]\d[0], 5), 10, " ") + " + " + RSet(StrD(*out\c[i]\d[1], 5), 10, " ") + "i")
Next
fftw_destroy_plan(*plan)
fftw_free(*in)
fftw_free(*out)
PrintN("Press any key...")
Input()
CloseConsole()
CompilerEndIf