diff options
author | tlatorre <tlatorre@uchicago.edu> | 2018-09-10 11:16:41 -0500 |
---|---|---|
committer | tlatorre <tlatorre@uchicago.edu> | 2018-09-10 11:16:41 -0500 |
commit | c8bff440e7848a33f369dff1ce11f726cecbbe20 (patch) | |
tree | 193f0c1ee91ad3fdf154f4917836b22534b1c840 /src/test.c | |
parent | 3228ad9f5a57b8e6b1e3c4cdcefce0536c012b92 (diff) | |
download | sddm-c8bff440e7848a33f369dff1ce11f726cecbbe20.tar.gz sddm-c8bff440e7848a33f369dff1ce11f726cecbbe20.tar.bz2 sddm-c8bff440e7848a33f369dff1ce11f726cecbbe20.zip |
add a fast likelihood function
This commit adds a fast function to calculate the expected number of PE at a
PMT without numerically integrating over the track. This calculation is *much*
faster than integrating over the track (~30 ms compared to several seconds) and
so we use it during the "quick" minimization phase of the fit to quickly find
the best position.
Diffstat (limited to 'src/test.c')
-rw-r--r-- | src/test.c | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -467,6 +467,28 @@ err: return 1; } +int test_lnfact(char *err) +{ + /* Tests the lnfact() function. */ + size_t i; + double x, expected; + + for (i = 0; i < 1000; i++) { + x = lnfact(i); + expected = gsl_sf_lnfact(i); + + if (!isclose(x, expected, 1e-9, 1e-9)) { + sprintf(err, "lnfact(%zu) returned %.5g, but expected %.5g", i, x, expected); + goto err; + } + } + + return 0; + +err: + return 1; +} + struct tests { testFunction *test; char *name; @@ -482,6 +504,7 @@ struct tests { {test_path, "test_path"}, {test_interp1d, "test_interp1d"}, {test_kahan_sum, "test_kahan_sum"}, + {test_lnfact, "test_lnfact"}, }; int main(int argc, char **argv) |