Mercurial > hg > may
changeset 429:2fbf3ce1e08b
Cache the factorials, makes things slightly quicker
author | Chris Cannam |
---|---|
date | Tue, 08 Oct 2013 07:57:27 +0100 |
parents | 9e3e97ecf9d0 |
children | 7ee8c2d55e58 |
files | src/may/signal/window.yeti |
diffstat | 1 files changed, 10 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/may/signal/window.yeti Sat Oct 05 11:29:39 2013 +0100 +++ b/src/may/signal/window.yeti Tue Oct 08 07:57:27 2013 +0100 @@ -100,16 +100,19 @@ //!!! if kaiser is going to take a structure, so I guess should sinc and cosineWindow kaiser { length, beta } = - (bes0 x = - (fact x = fold do x y: x*y done 1 [1..x]; // x! - ipow a b = fold do x _: x*a done 1 [1..b]; // a^b where b∈ℕ - square x = x*x; - term x i = + (terms = 20; + fact x = fold do x y: x*y done 1 [1..x]; // x! + ipow a b = fold do x _: x*a done 1 [1..b]; // a^b where b∈ℕ + factorials = array (map fact [1..terms]); + bes0 x = + (term x i = case i of 0: 1; - _: (ipow (x/2) (i*2)) / (square (fact i)); + _: + f = factorials[i-1]; + (ipow (x/2) (i*2)) / (f * f); esac; - sum (map (term x) [0..20])); + sum (map (term x) [0..terms])); denominator = bes0 beta; kw = vec.fromList (map do i: