1 ;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
6 ;;;; Purpose: CFFI interface for FFTW3 package
7 ;;;; Programmer: Kevin M. Rosenberg
8 ;;;; Date Started: Mar 2009
10 ;;;; This file and CL-FFTW3 are Copyright (c) 2009-2011 by Kevin M. Rosenberg
12 ;;;; FFTW3 users are granted the rights to distribute and use this software
13 ;;;; as governed by the terms of the Lisp Lesser GNU Public License
14 ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
15 ;;;; *************************************************************************
19 (cffi:define-foreign-library fftw3
20 ((or :darwin :macosx) (:or #P"/opt/local/lib/libfftw3.dylib"
21 #P"/usr/lib/libfftw3.dylib"))
22 (:linux (:or #P"/usr/lib/libfftw3.so"
23 #P"/usr/local/lib/libfftw3.so"))
24 (t (:default "libfftw3")))
26 (cffi:use-foreign-library fftw3)
28 (cffi:defcstruct fftw-complex-struct
29 "Complex number structure."
33 (cffi:defctype fftw-plan :pointer)
35 (declaim (inline fftw-plan-dft-1d))
36 (cffi:defcfun ("fftw_plan_dft_1d" fftw-plan-dft-1d) fftw-plan
38 (in (:pointer fftw-complex-struct))
39 (out (:pointer fftw-complex-struct))
43 (declaim (inline fftw-plan-dft-2d))
44 (cffi:defcfun ("fftw_plan_dft_2d" fftw-plan-dft-2d) fftw-plan
47 (in (:pointer fftw-complex-struct))
48 (out (:pointer fftw-complex-struct))
52 (declaim (inline fftw-plan-dft-3d))
53 (cffi:defcfun ("fftw_plan_dft_3d" fftw-plan-dft-3d) fftw-plan
57 (in (:pointer fftw-complex-struct))
58 (out (:pointer fftw-complex-struct))
62 (declaim (inline fftw-plan-dft))
63 (cffi:defcfun ("fftw_plan_dft" fftw-plan-dft) fftw-plan
66 (in (:pointer fftw-complex-struct))
67 (out (:pointer fftw-complex-struct))
71 (declaim (inline fftw-plan-r2r-1d))
72 (cffi:defcfun ("fftw_plan_r2r_1d" fftw-plan-r2r-1d) fftw-plan
79 (declaim (inline fftw-plan-r2r-2d))
80 (cffi:defcfun ("fftw_plan_r2r_2d" fftw-plan-r2r-2d) fftw-plan
88 (declaim (inline fftw-plan-r2r-3d))
89 (cffi:defcfun ("fftw_plan_r2r_3d" fftw-plan-r2r-3d) fftw-plan
98 (declaim (inline fftw-plan-dft-r2c-1d))
99 (cffi:defcfun ("fftw_plan_dft_r2c_1d" fftw-plan-dft-r2c-1d) fftw-plan
105 (declaim (inline fftw-plan-dft-r2c-2d))
106 (cffi:defcfun ("fftw_plan_dft_r2c_2d" fftw-plan-dft-r2c-2d) fftw-plan
113 (declaim (inline fftw-plan-dft-r2c-3d))
114 (cffi:defcfun ("fftw_plan_dft_r2c_3d" fftw-plan-dft-r2c-3d) fftw-plan
122 (declaim (inline fftw-plan-dft-r2c))
123 (cffi:defcfun ("fftw_plan_dft_r2c" fftw-plan-dft-r2c) fftw-plan
130 (declaim (inline fftw-plan-dft-c2r-1d))
131 (cffi:defcfun ("fftw_plan_dft_c2r_1d" fftw-plan-dft-c2r-1d) fftw-plan
137 (declaim (inline fftw-plan-dft-c2r-2d))
138 (cffi:defcfun ("fftw_plan_dft_c2r_2d" fftw-plan-dft-c2r-2d) fftw-plan
145 (declaim (inline fftw-plan-dft-c2r-3d))
146 (cffi:defcfun ("fftw_plan_dft_c2r_3d" fftw-plan-dft-c2r-3d) fftw-plan
154 (declaim (inline fftw-plan-dft-c2r))
155 (cffi:defcfun ("fftw_plan_dft_c2r" fftw-plan-dft-c2r) fftw-plan
162 (declaim (inline fftw-plan-many-dft))
163 (cffi:defcfun ("fftw_plan_many_dft" fftw-plan-many-dft) fftw-plan
167 (in (:pointer fftw-complex-struct))
168 (inembed (:pointer :int))
171 (out (:pointer fftw-complex-struct))
172 (onembed (:pointer :int))
178 (declaim (inline fftw-plan-many-dft_r2c))
179 (cffi:defcfun ("fftw_plan_many_dft_r2c" fftw-plan-many-dft-r2c) fftw-plan
183 (in (:pointer :double))
184 (inembed (:pointer :int))
187 (out (:pointer fftw-complex-struct))
188 (onembed (:pointer :int))
193 (declaim (inline fftw-plan-many-dft_c2r))
194 (cffi:defcfun ("fftw_plan_many_dft_c2r" fftw-plan-many-dft-c2r) fftw-plan
198 (in (:pointer fftw-complex-struct))
199 (inembed (:pointer :int))
202 (out (:pointer :double))
203 (onembed (:pointer :int))
208 (declaim (inline fftw-plan-many-dft_r2r))
209 (cffi:defcfun ("fftw_plan_many_dft_r2r" fftw-plan-many-dft-r2r) fftw-plan
213 (in (:pointer :double))
214 (inembed (:pointer :int))
217 (out (:pointer :double))
218 (onembed (:pointer :int))
221 (kind (:pointer :int))
225 (declaim (inline fftw-malloc))
226 (cffi:defcfun ("fftw_malloc" fftw-malloc) (:pointer fftw-complex-struct)
229 (declaim (inline fftw-execute))
230 (cffi:defcfun ("fftw_execute" fftw-execute) :void
233 (declaim (inline fftw-destroy-plan))
234 (cffi:defcfun ("fftw_destroy_plan" fftw-destroy-plan) :void
237 (declaim (inline fftw-free))
238 (cffi:defcfun ("fftw_free" fftw-free) :void
244 (cffi:defcfun ("fftw_import_wisdom_from_string" fftw-import-wisdom-from-string) :int
245 (input-string :string))
247 (cffi:defcfun ("fftw_export_wisdom_to_string" fftw-export-wisdom-to-string) :string+ptr
250 (cffi:defcfun free :void