Commit 39c888a4 authored by Liam Healy's avatar Liam Healy
Browse files

Decimation-in-frequency added to forward FFT

The function forward-fourier-transform now has an argument
:decimation-in-frequency that will call the generic function
forward-fourier-transform-dif-radix2 if non-NIL and the length of the
vector is a power of 2.  This is not tested yet.
parent b4f09c28
;; Functions for fast fourier transforms on complex data.
;; Sumant Oemrawsingh, Sat Oct 24 2009 - 12:55
;; Time-stamp: <2009-11-01 22:46:09EST fft-complex.lisp>
;; Time-stamp: <2009-11-03 22:21:07EST fft-complex.lisp>
;; /usr/include/gsl/gsl_fft_complex.h
;; /usr/include/gsl/gsl_fft_complex_float.h
......@@ -49,18 +49,6 @@
;; I don't know what they are and how they are supposed to work, so I don't
;; know if they work.
(defmfun fft-complex-radix2-dif-forward
((vector vector) &key (stride 1) (n (expt 2 (floor (log (size vector) 2)))))
("gsl_fft" :type "_radix2_dif_forward")
(((c-pointer vector) :pointer) (stride sizet) (n sizet))
:definition :generic
:element-types :complex
:inputs (vector)
:outputs (vector)
:return (vector)
:documentation
"Decimation-in-frequency version of the forward FFT for a complex radix-2 vector")
(defmfun fft-complex-radix2-dif-backward
((vector vector) &key (stride 1) (n (expt 2 (floor (log (size vector) 2)))))
("gsl_fft" :type "_radix2_dif_backward")
......
;; FFT transforms
;; Sumant Oemrawsingh, Sat Oct 31 2009 - 23:48
;; Time-stamp: <2009-11-01 22:43:18EST forward.lisp>
;; Time-stamp: <2009-11-03 22:14:37EST forward.lisp>
(in-package :gsl)
......@@ -105,6 +105,24 @@
"Forward FFT on a vector for which (floor length stride) is not a power of 2,
in half complex form.")
;;;;****************************************************************************
;;;; Decimation-in-frequency forward FFT
;;;;****************************************************************************
(defmfun forward-fourier-transform-dif-radix2 ((vector vector) &key (stride 1))
("gsl_fft" :type "_radix2_dif_forward")
(((c-pointer vector) :pointer) (stride sizet) ((size vector) sizet))
:definition :generic
:element-types :complex
:inputs (vector)
:outputs (vector)
:return (vector)
:export nil
:index forward-fourier-transform
:documentation
"Forward decimation-in-frequency FFT on a vector for which (floor
length stride) is a power of 2.")
;;;;****************************************************************************
;;;; Unified function forward-fourier-transform
;;;;****************************************************************************
......@@ -117,7 +135,8 @@
;;; This selects among the 12 forward FFT functions that GSL defines.
(export 'forward-fourier-transform)
(defun forward-fourier-transform
(vector &rest args &key half-complex (stride 1) &allow-other-keys)
(vector &rest args
&key half-complex decimation-in-frequency (stride 1) &allow-other-keys)
"Perform a forward fast Fourier transform on the given vector. If
the length of the vector is not a power of 2, and the user has a
suitable wavetable and/or workspace, these can be supplied as
......@@ -125,11 +144,14 @@
then the key argument :half-complex should be non-NIL."
(let ((pass-on-args (copy-list args)))
(remf pass-on-args :half-complex)
(remf pass-on-args :decimation-in-frequency)
(if (power-of-2-p (floor (size vector) stride))
(if half-complex
(apply 'forward-fourier-transform-halfcomplex-radix2
vector pass-on-args)
(apply 'forward-fourier-transform-radix2 vector pass-on-args))
(if decimation-in-frequency
(apply 'forward-fourier-transform-dif-radix2 vector pass-on-args)
(apply 'forward-fourier-transform-radix2 vector pass-on-args)))
(if half-complex
(apply 'forward-fourier-transform-halfcomplex-nonradix2
vector pass-on-args)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment