[Gsll-devel] small modification to blas2.lisp

Mirko Vukovic mirko.vukovic at gmail.com
Fri May 16 12:52:46 UTC 2008


Hello.

I am trying to use gsl's fft routines and I am having trouble.  Here
is the sample code where I have defined the interface followed by a
little driver.

>From my reading of the documentation and the example (see
http://www.gnu.org/software/gsl/manual/html_node/Radix_002d2-FFT-routines-for-complex-data.html)
, the fft routine needs the complex vector repackaged as a double
vector, a stride index, and the size.  That is what I tried to do
below.

I get the error sb-kernel::undefined-alien-function-error.
I am using sbcl 1.0.14 on linux.

The code is at the end of the message.

Thanks,

Mirko



(in-package :gsll)

(defmfun fft-c2f (x stride n)
  "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))
  :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))
  (letm ((dim (length arg))
	 (double* (vector-double-float
		   ;; repackaging complex as double -- is there a built-in?
		   (let ((double (make-array (* 2 dim)
					     :element-type 'double-float
					     :initial-element 0d0)))
		     (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))))
		     double))))
    (fft-c2f double* 1 dim)
    (data double*)))



More information about the gsll-devel mailing list