diff options
author | James LewisMoss <dres@debian.org> | 1999-12-06 19:32:57 -0500 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2017-02-20 00:05:28 -0800 |
commit | c394920caedf3dac1981bb6b10eeb47fd6e4bb21 (patch) | |
tree | f21194653a3554f747dde3df908df993c48db5a0 /fft.scm | |
parent | 926b1b647ac830660933a5e63eb52d4a2552e264 (diff) | |
parent | bd9733926076885e3417b74de76e4c9c7bc56254 (diff) | |
download | slib-c394920caedf3dac1981bb6b10eeb47fd6e4bb21.tar.gz slib-c394920caedf3dac1981bb6b10eeb47fd6e4bb21.zip |
Import Debian changes 2c7-1debian/2c7-1
slib (2c7-1) unstable; urgency=low
* New upstream.
* Add slibconfig back in.
slib (2c6-2) unstable; urgency=low
* Remove the slib$(VERSION).info file. Cut the diff back down to
size.
slib (2c6-1) unstable; urgency=low
* New upstream.
* Move docs to /usr/share. Up standards version. add /usr/doc symlink.
Move info files. Remove undocumented link.
slib (2c5-6) unstable; urgency=low
* Lowercase two vars in yasyn.scm (Fixes bug #37222)
slib (2c5-5) unstable; urgency=low
* Fix it so string-index isn't defined (now there is a
strsrch:string-index) (Fixes #38812)
slib (2c5-4) unstable; urgency=low
* Don't run slibconfig in postinst. (Fixes bug #38253, #37733, #37715,
#37746, #37809, #37917, #38123, #38462)
slib (2c5-3) unstable; urgency=low
* Run slibconfig in postinst. It was commented out there, but I don't
see any old bug reports on why it was commented out, so let's try
again. :) (Fixes bug #37221)
slib (2c5-2) unstable; urgency=low
* Link mklibcat.scm to mklibcat. Fixes a problem with using slib with
guile.
slib (2c5-1) unstable; urgency=low
* New upstream.
slib (2c3-4) unstable; urgency=low
* New maintainer.
Diffstat (limited to 'fft.scm')
-rw-r--r-- | fft.scm | 70 |
1 files changed, 70 insertions, 0 deletions
@@ -0,0 +1,70 @@ +;;;"fft.scm" Fast Fourier Transform +;Copyright (C) 1999 Aubrey Jaffer +; +;Permission to copy this software, to redistribute it, and to use it +;for any purpose is granted, subject to the following restrictions and +;understandings. +; +;1. Any copy made of this software must include this copyright notice +;in full. +; +;2. I have made no warrantee or representation that the operation of +;this software will be error-free, and I am under no obligation to +;provide any services, by way of maintenance, update, or otherwise. +; +;3. In conjunction with products arising from the use of this +;material, there shall be no use of my name in any advertising, +;promotional, or sales literature without prior written consent in +;each case. + +;;;; See: +;;; Introduction to Algorithms (MIT Electrical +;;; Engineering and Computer Science Series) +;;; by Thomas H. Cormen, Charles E. Leiserson (Contributor), +;;; Ronald L. Rivest (Contributor) +;;; MIT Press; ISBN: 0-262-03141-8 (July 1990) + +;;; http://www.astro.virginia.edu/~eww6n/math/DiscreteFourierTransform.html +;;; differs in the direction of rotation of the complex unit vectors. + +(require 'array) + +(define (fft:shuffled&scaled ara n scale) + (define lgn (integer-length (+ -1 n))) + (define new (apply make-array 0 (array-dimensions ara))) + (define bit-reverse (lambda (width in) + (if (zero? width) 0 + (+ (bit-reverse (+ -1 width) (quotient in 2)) + (ash (modulo in 2) (+ -1 width)))))) + (if (not (eqv? n (expt 2 lgn))) + (slib:error 'fft "array length not power of 2" n)) + (do ((k 0 (+ 1 k))) + ((>= k n) new) + (array-set! new (* (array-ref ara k) scale) (bit-reverse lgn k)))) + +(define (dft! ara n dir) + (define lgn (integer-length (+ -1 n))) + (define pi2i (* 0+8i (atan 1))) + (do ((s 1 (+ 1 s))) + ((> s lgn) ara) + (let* ((m (expt 2 s)) + (w_m (exp (* dir (/ pi2i m)))) + (m/2-1 (+ (quotient m 2) -1))) + (do ((j 0 (+ 1 j)) + (w 1 (* w w_m))) + ((> j m/2-1)) + (do ((k j (+ m k))) + ((>= k n)) + (let* ((k+m/2 (+ k m/2-1 1)) + (t (* w (array-ref ara k+m/2))) + (u (array-ref ara k))) + (array-set! ara (+ u t) k) + (array-set! ara (- u t) k+m/2))))))) + +(define (fft ara) + (define n (car (array-dimensions ara))) + (dft! (fft:shuffled&scaled ara n 1) n 1)) + +(define (fft-1 ara) + (define n (car (array-dimensions ara))) + (dft! (fft:shuffled&scaled ara n (/ n)) n -1)) |