Last active
August 29, 2015 13:57
-
-
Save JayKickliter/9514842 to your computer and use it in GitHub Desktop.
Calling FFTS c functions from Julia
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Complex transforms | |
| # Sign argument | |
| # -1 = Complex to Complex reverse FFT | |
| # 1 = Complex to Complex forward FFT | |
| # ffts_plan_t *ffts_init_1d(size_t N, int sign); | |
| # Create a plan for a forward 1D FFT of size 16 | |
| N = 2^16 | |
| Direction = 1 | |
| ffts_plan = ccall((:ffts_init_1d, "libffts"), Ptr{Void}, (Csize_t, Cint), N, Direction) | |
| # ffts_execute(ffts_plan_t * , const void *input, void *output) | |
| # Create a dirac delta signal and execute the FFT using the ffts_plan | |
| input = zeros(Complex64, N) | |
| input[1] = 1 | |
| output = zeros(Complex64, N) | |
| ccall((:ffts_execute, "libffts"), Void, (Ptr{Void}, Ptr{Void}, Ptr{Void}), ffts_plan, input, output) | |
| display(output) | |
| # 16-element Array{Complex{Float32},1}: | |
| # 1.0+0.0im | |
| # 1.0+0.0im | |
| # 1.0+0.0im | |
| # 1.0+0.0im | |
| # 1.0+0.0im | |
| # 1.0+0.0im | |
| # 1.0+0.0im | |
| # 1.0+0.0im | |
| # 1.0+0.0im | |
| # 1.0+0.0im | |
| # 1.0+0.0im | |
| # 1.0+0.0im | |
| # 1.0+0.0im | |
| # 1.0+0.0im | |
| # 1.0+0.0im | |
| # 1.0+0.0im | |
| # Free the plan from c memeory | |
| ccall((:ffts_free, "libffts"), Void, (Ptr{Void},), ffts_plan) | |
| # ffts_plan_t *ffts_init_2d(size_t N1, size_t N2, int sign); | |
| # Create a plan for a forward 2D FFT of size [16, 182] | |
| N = 16 | |
| Direction = 1 | |
| ffts_plan = ccall((:ffts_init_2d, "libffts"), Ptr{Void}, (Csize_t, Csize_t, Cint), N, N, Direction) | |
| # ffts_plan_t *ffts_init_nd(int rank, size_t *Ns, int sign); | |
| # Create a plan for a forward 3D FFT of size [16, 16, 16] | |
| Ns = Csize_t[16, 16, 16] | |
| Rank = 3 | |
| Direction = 1 | |
| ffts_plan = ccall((:ffts_init_nd, "libffts"), Ptr{Void}, (Cint, Ptr{Csize_t}, Cint), Rank, Ns, Direction) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment