From: Neil Baylis
Subject: fftw bindings? (Fourier Transform Library)
Date: 
Message-ID: <c76b59c1-597b-4a82-a88a-c7844c201020@a3g2000prm.googlegroups.com>
Apparently, at one time there were CL FFI bindings for the fftw
library, at least according to cl-user.net. However, the link there is
broken, and the Google is not cooperating.

Does anyone know if such a package exists? Did someone maybe download
the file while it did exist?

If not, can anyone recommend an alternative high performance FFT that
I can use in an upcoming project? (The project will be in CL, with
opengl and some kind of widget toolkit, but I don't know which one.
The user will to some grunting and clicking in a window, then some
math will happen, and then an image will appear. Part of the math is
an inverse 2d FFT).

Or.. how hard would it be to make my own ffi bindings? It looks like
it exports about 100 functions, and I don't know how many types.

Thanks for any info,

Neil

From: Tamas K Papp
Subject: Re: fftw bindings? (Fourier Transform Library)
Date: 
Message-ID: <6f63meFa0gneU1@mid.individual.net>
On Sun, 27 Jul 2008 16:13:25 -0700, Neil Baylis wrote:

> If not, can anyone recommend an alternative high performance FFT that I
> can use in an upcoming project? (The project will be in CL, with opengl
> and some kind of widget toolkit, but I don't know which one. The user
> will to some grunting and clicking in a window, then some math will
> happen, and then an image will appear. Part of the math is an inverse 2d
> FFT).

GSLL (http://common-lisp.net/project/gsll/) might have it - GSL does, but 
I don't know if the links are there.  Ask on the GSLL mailing list.

> Or.. how hard would it be to make my own ffi bindings? It looks like it
> exports about 100 functions, and I don't know how many types.

If you have a C library that does FFT, try generating the bindings with 
SWIG.  Have a look at the FFA package for interfacing Lisp arrays.

Tamas
From: ········@gmail.com
Subject: Re: fftw bindings? (Fourier Transform Library)
Date: 
Message-ID: <b68fa672-f28b-40d5-8a79-f2a8c2d16ee7@d77g2000hsb.googlegroups.com>
> SWIG.  Have a look at the FFA package for interfacing Lisp arrays.
>
> Tamas

This might be a good moment to point out that FFA package is at this
time semi-broken, as you seem to have split array-operations into
separate system, without making it available. At least I failed to
find it anywhere. I didn't use it recently, so I didn't send a
bugreport, but if you are recommending its use on cll I thought you
might want to know.

Ramarren
From: Tamas K Papp
Subject: Re: fftw bindings? (Fourier Transform Library)
Date: 
Message-ID: <6f8517Fa66f4U1@mid.individual.net>
On Mon, 28 Jul 2008 10:48:35 -0700, Ramarren wrote:

>> SWIG.  Have a look at the FFA package for interfacing Lisp arrays.
>>
>> Tamas
> 
> This might be a good moment to point out that FFA package is at this
> time semi-broken, as you seem to have split array-operations into
> separate system, without making it available. At least I failed to find
> it anywhere. I didn't use it recently, so I didn't send a bugreport, but
> if you are recommending its use on cll I thought you might want to know.

Dear Ramarren,

I mistakenly updated the tarball for FFA, without publishing ARRAY-
OPERATIONS.  I cleaned it up now and posted it, and wrote a Cliki page 
for the latter.

Thanks for the bugreport - next time please drop me an e-mail if you can.

Tamas
From: ·············@gmail.com
Subject: Re: fftw bindings? (Fourier Transform Library)
Date: 
Message-ID: <b3a7b9b8-f14b-4aa0-a14d-bc0d4d2502d6@e39g2000hsf.googlegroups.com>
On Jul 28, 10:33 am, Tamas K Papp <······@gmail.com> wrote:
> On Sun, 27 Jul 2008 16:13:25 -0700, Neil Baylis wrote:
> > If not, can anyone recommend an alternative high performance FFT that I
> > can use in an upcoming project? (The project will be in CL, with opengl
> > and some kind of widget toolkit, but I don't know which one. The user
> > will to some grunting and clicking in a window, then some math will
> > happen, and then an image will appear. Part of the math is an inverse 2d
> > FFT).
>
> GSLL (http://common-lisp.net/project/gsll/) might have it - GSL does, but
> I don't know if the links are there.  Ask on the GSLL mailing list.
>
> > Or.. how hard would it be to make my own ffi bindings? It looks like it
> > exports about 100 functions, and I don't know how many types.
>
> If you have a C library that does FFT, try generating the bindings with
> SWIG.  Have a look at the FFA package for interfacing Lisp arrays.
>
> Tamas

I tried to get fft going via GSLL, but got an unhandled memory fault
in SBCL.  Here's my attempt:

(in-package :gsll)

(defmfun fft-c2f (x stride n)
 "gsl_fft_complex_radix2_forward"
;; for gsl doc and example see
;; http://www.gnu.org/software/gsl/manual/html_node/Radix_002d2-FFT-routines-for-complex-data.html
 (((pointer x) gsl-vector-c) (stride :int) (n :int))
 :type :function
 :c-return :int
 :documentation
 "Forward FFT for a complex double radix-2 vector")

;; test run
(let ((arg (make-array 4 :element-type 'complex :initial-element
#c(0d0 0d0))))
 (setf (aref arg 2) #c(1d0 0d0))
 (let* ((dim (length arg))
       (double (make-array (* 2 dim)
                            :element-type 'double-float
                            :initial-element 0d0)))
   ;; repackaging complex as double -- is there a built-in?
   (loop
      for re-im across arg
      for i from 0 to (* 2 (1- dim)) by 2
      do (progn
           (setf (aref double i) (realpart re-im))
           (setf (aref double (1+ i)) (imagpart re-im))))

   (letm ((double* (vector-double-float double)))
     (fft-c2f double* 1 dim))))

If someone can make it work, we all win :-)

Mirko
From: Neil Baylis
Subject: Re: fftw bindings? (Fourier Transform Library)
Date: 
Message-ID: <ad20539d-eb66-4c9c-bc84-5bf8d5d966b4@h17g2000prg.googlegroups.com>
On Jul 28, 7:33 am, Tamas K Papp <······@gmail.com> wrote:
> On Sun, 27 Jul 2008 16:13:25 -0700, Neil Baylis wrote:
> > If not, can anyone recommend an alternative high performance FFT that I
> > can use in an upcoming project? (The project will be in CL, with opengl
> > and some kind of widget toolkit, but I don't know which one. The user
> > will to some grunting and clicking in a window, then some math will
> > happen, and then an image will appear. Part of the math is an inverse 2d
> > FFT).
>
> GSLL (http://common-lisp.net/project/gsll/) might have it - GSL does, but
> I don't know if the links are there.  Ask on the GSLL mailing list.
>
> > Or.. how hard would it be to make my own ffi bindings? It looks like it
> > exports about 100 functions, and I don't know how many types.
>
> If you have a C library that does FFT, try generating the bindings with
> SWIG.  Have a look at the FFA package for interfacing Lisp arrays.
>
> Tamas

OK, thanks. I do have a c library: fftw. I'll look in to the SWIG
idea, as well as GSLL.

Neil
From: Jon Harrop
Subject: Re: fftw bindings? (Fourier Transform Library)
Date: 
Message-ID: <g6pv4e$pl$1@aioe.org>
Neil Baylis wrote:
> Apparently, at one time there were CL FFI bindings for the fftw
> library, at least according to cl-user.net. However, the link there is
> broken, and the Google is not cooperating.

Did you know that FFTW is written primarily in OCaml? :-)

> Does anyone know if such a package exists?

You should be able to write bindings to FFTW from Common Lisp fairly easily.

> If not, can anyone recommend an alternative high performance FFT that
> I can use in an upcoming project?

I strongly recommend using FFTW because it is much much better than anything
else out there. The only arguable exception is Intel's vendor tuned FFT
that is just as fast but commercial.

> Or.. how hard would it be to make my own ffi bindings? It looks like
> it exports about 100 functions, and I don't know how many types.

We described basic FFTW bindings from F# (not Common Lisp) in the F#.NET
Journal article "Numerical Libraries: linear algebra and spectral methods".

You only need half a dozen functions with simple signatures and no custom
types at all:

  fftw_malloc
  fftw_free
  fftw_plan_dft_2d
  fftw_destroy_plan
  fftw_execute

The type of a "plan" can be "void *" because it is never used directly from
the host language (e.g. Common Lisp).

Good luck!

-- 
Dr Jon D Harrop, Flying Frog Consultancy
http://www.ffconsultancy.com/products/?u
From: Neil Baylis
Subject: Re: fftw bindings? (Fourier Transform Library)
Date: 
Message-ID: <74513dde-dd57-405b-9bde-0f692d8ef5c1@x41g2000hsb.googlegroups.com>
On Jul 30, 7:51 am, Jon Harrop <····@ffconsultancy.com> wrote:
> Neil Baylis wrote:
> > Apparently, at one time there were CL FFI bindings for the fftw
> > library, at least according to cl-user.net. However, the link there is
> > broken, and the Google is not cooperating.
>
> Did you know that FFTW is written primarily in OCaml? :-)
>
> > Does anyone know if such a package exists?
>
> You should be able to write bindings to FFTW from Common Lisp fairly easily.
>
> > If not, can anyone recommend an alternative high performance FFT that
> > I can use in an upcoming project?
>
> I strongly recommend using FFTW because it is much much better than anything
> else out there. The only arguable exception is Intel's vendor tuned FFT
> that is just as fast but commercial.
>
> > Or.. how hard would it be to make my own ffi bindings? It looks like
> > it exports about 100 functions, and I don't know how many types.
>
> We described basic FFTW bindings from F# (not Common Lisp) in the F#.NET
> Journal article "Numerical Libraries: linear algebra and spectral methods".
>
> You only need half a dozen functions with simple signatures and no custom
> types at all:
>
>   fftw_malloc
>   fftw_free
>   fftw_plan_dft_2d
>   fftw_destroy_plan
>   fftw_execute
>
> The type of a "plan" can be "void *" because it is never used directly from
> the host language (e.g. Common Lisp).
>
> Good luck!
>
> --
> Dr Jon D Harrop, Flying Frog Consultancyhttp://www.ffconsultancy.com/products/?u

That's encouraging. Thanks very much!

Neil