Mercurial > hg > audiodb
comparison sample.cpp @ 276:5c34b71c5ffa sampling
Restore static decoration to yfun and yinv.
author | mas01cr |
---|---|
date | Tue, 01 Jul 2008 09:00:29 +0000 |
parents | 1c76d5f41708 |
children | d9dba57becd4 |
comparison
equal
deleted
inserted
replaced
274:1c76d5f41708 | 276:5c34b71c5ffa |
---|---|
1 #include "audioDB.h" | 1 #include "audioDB.h" |
2 | 2 |
3 #include <gsl/gsl_sf.h> | 3 #include <gsl/gsl_sf.h> |
4 | 4 |
5 // static | 5 static |
6 double yfun(double d) { | 6 double yfun(double d) { |
7 return gsl_sf_log(d) - gsl_sf_psi(d); | 7 return gsl_sf_log(d) - gsl_sf_psi(d); |
8 } | 8 } |
9 // static | 9 |
10 static | |
10 double yinv(double y) { | 11 double yinv(double y) { |
11 double a = 1.0e-5; | 12 double a = 1.0e-5; |
12 double b = 1000.0; | 13 double b = 1000.0; |
13 | 14 |
14 double ay = yfun(a); | 15 double ay = yfun(a); |
15 double by = yfun(b); | 16 double by = yfun(b); |
16 | 17 |
17 double c, cy; | 18 double c, cy; |
18 | 19 |
19 /* FIXME: simple binary search */ | 20 /* FIXME: simple binary search; there's probably some clever solver |
21 in gsl somewhere which is less sucky. */ | |
20 while ((b - a) > 1.0e-5) { | 22 while ((b - a) > 1.0e-5) { |
21 c = (a + b) / 2; | 23 c = (a + b) / 2; |
22 cy = yfun(c); | 24 cy = yfun(c); |
23 if (cy > y) { | 25 if (cy > y) { |
24 a = c; | 26 a = c; |