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
12 ;;;; This file, part of FFTW3, is Copyright (c) 2009 by Kevin M. Rosenberg
14 ;;;; FFTW3 users are granted the rights to distribute and use this software
15 ;;;; as governed by the terms of the Lisp Lesser GNU Public License
16 ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
17 ;;;; *************************************************************************
21 (cffi:define-foreign-library fftw3
22 ((or :darwin :macosx) (:or #P"/opt/local/lib/libfftw3.dylib"
23 #P"/usr/lib/libfftw3.dylib"))
24 (:linux (:or #P"/usr/lib/libfftw3.so"
25 #P"/usr/local/lib/libfftw3.so"))
26 (t (:default "libfftw3")))
28 (cffi:use-foreign-library fftw3)
30 (cffi:defcstruct fftw-complex-struct
31 "Complex number structure."
35 (cffi:defctype fftw-plan :pointer)
37 (declaim (inline fftw-plan-dft-1d))
38 (cffi:defcfun ("fftw_plan_dft_1d" fftw-plan-dft-1d) fftw-plan
40 (in (:pointer fftw-complex-struct))
41 (out (:pointer fftw-complex-struct))
45 (declaim (inline fftw-plan-dft-2d))
46 (cffi:defcfun ("fftw_plan_dft_2d" fftw-plan-dft-2d) fftw-plan
49 (in (:pointer fftw-complex-struct))
50 (out (:pointer fftw-complex-struct))
54 (declaim (inline fftw-plan-dft-3d))
55 (cffi:defcfun ("fftw_plan_dft_3d" fftw-plan-dft-3d) fftw-plan
59 (in (:pointer fftw-complex-struct))
60 (out (:pointer fftw-complex-struct))
64 (declaim (inline fftw-plan-dft))
65 (cffi:defcfun ("fftw_plan_dft" fftw-plan-dft) fftw-plan
68 (in (:pointer fftw-complex-struct))
69 (out (:pointer fftw-complex-struct))
73 (declaim (inline fftw-plan-r2r-1d))
74 (cffi:defcfun ("fftw_plan_r2r_1d" fftw-plan-r2r-1d) fftw-plan
81 (declaim (inline fftw-plan-r2r-2d))
82 (cffi:defcfun ("fftw_plan_r2r_2d" fftw-plan-r2r-2d) fftw-plan
90 (declaim (inline fftw-plan-r2r-3d))
91 (cffi:defcfun ("fftw_plan_r2r_3d" fftw-plan-r2r-3d) fftw-plan
100 (declaim (inline fftw-plan-dft-r2c-1d))
101 (cffi:defcfun ("fftw_plan_dft_r2c_1d" fftw-plan-dft-r2c-1d) fftw-plan
107 (declaim (inline fftw-plan-dft-r2c-2d))
108 (cffi:defcfun ("fftw_plan_dft_r2c_2d" fftw-plan-dft-r2c-2d) fftw-plan
115 (declaim (inline fftw-plan-dft-r2c-3d))
116 (cffi:defcfun ("fftw_plan_dft_r2c_3d" fftw-plan-dft-r2c-3d) fftw-plan
124 (declaim (inline fftw-plan-dft-r2c))
125 (cffi:defcfun ("fftw_plan_dft_r2c" fftw-plan-dft-r2c) fftw-plan
132 (declaim (inline fftw-plan-dft-c2r-1d))
133 (cffi:defcfun ("fftw_plan_dft_c2r_1d" fftw-plan-dft-c2r-1d) fftw-plan
139 (declaim (inline fftw-plan-dft-c2r-2d))
140 (cffi:defcfun ("fftw_plan_dft_c2r_2d" fftw-plan-dft-c2r-2d) fftw-plan
147 (declaim (inline fftw-plan-dft-c2r-3d))
148 (cffi:defcfun ("fftw_plan_dft_c2r_3d" fftw-plan-dft-c2r-3d) fftw-plan
156 (declaim (inline fftw-plan-dft-c2r))
157 (cffi:defcfun ("fftw_plan_dft_c2r" fftw-plan-dft-c2r) fftw-plan
164 (declaim (inline fftw-plan-many-dft))
165 (cffi:defcfun ("fftw_plan_many_dft" fftw-plan-many-dft) fftw-plan
169 (in (:pointer fftw-complex-struct))
170 (inembed (:pointer :int))
173 (out (:pointer fftw-complex-struct))
174 (onembed (:pointer :int))
180 (declaim (inline fftw-plan-many-dft_r2c))
181 (cffi:defcfun ("fftw_plan_many_dft_r2c" fftw-plan-many-dft-r2c) fftw-plan
185 (in (:pointer :double))
186 (inembed (:pointer :int))
189 (out (:pointer fftw-complex-struct))
190 (onembed (:pointer :int))
195 (declaim (inline fftw-plan-many-dft_c2r))
196 (cffi:defcfun ("fftw_plan_many_dft_c2r" fftw-plan-many-dft-c2r) fftw-plan
200 (in (:pointer fftw-complex-struct))
201 (inembed (:pointer :int))
204 (out (:pointer :double))
205 (onembed (:pointer :int))
210 (declaim (inline fftw-plan-many-dft_r2r))
211 (cffi:defcfun ("fftw_plan_many_dft_r2r" fftw-plan-many-dft-r2r) fftw-plan
215 (in (:pointer :double))
216 (inembed (:pointer :int))
219 (out (:pointer :double))
220 (onembed (:pointer :int))
223 (kind (:pointer :int))
227 (declaim (inline fftw-malloc))
228 (cffi:defcfun ("fftw_malloc" fftw-malloc) (:pointer fftw-complex-struct)
231 (declaim (inline fftw-execute))
232 (cffi:defcfun ("fftw_execute" fftw-execute) :void
235 (declaim (inline fftw-destroy-plan))
236 (cffi:defcfun ("fftw_destroy_plan" fftw-destroy-plan) :void
239 (declaim (inline fftw-free))
240 (cffi:defcfun ("fftw_free" fftw-free) :void
246 (cffi:defcfun ("fftw_import_wisdom_from_string" fftw-import-wisdom-from-string) :int
247 (input-string :string))
249 (cffi:defcfun ("fftw_export_wisdom_to_string" fftw-export-wisdom-to-string) :string+ptr
252 (cffi:defcfun free :void