From 04656e730d1f0a1c55fdee48e8ea9f34552c03d8 Mon Sep 17 00:00:00 2001 From: tlatorre Date: Sun, 21 Oct 2018 11:32:40 -0500 Subject: add a fast solid angle approximation to speed up the fast likelihood calculation --- src/test.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/test.c') diff --git a/src/test.c b/src/test.c index f8cedb9..16756ad 100644 --- a/src/test.c +++ b/src/test.c @@ -970,6 +970,31 @@ err: return 1; } +int test_solid_angle_fast(char *err) +{ + /* Tests the get_solid_angle_fast() function. */ + int i; + double pmt[3] = {0,0,0}; + double pos[3] = {0,0,1}; + double n[3] = {0,0,-1}; + double r = 1.0; + double solid_angle; + + for (i = 0; i < sizeof(solid_angle_results)/sizeof(struct solid_angle_results); i++) { + pos[0] = solid_angle_results[i].r0*r; + pos[2] = solid_angle_results[i].L*r; + + solid_angle = get_solid_angle_approx(pos,pmt,n,r); + + if (!isclose(solid_angle, solid_angle_results[i].omega, 1e-2, 0)) { + sprintf(err, "solid angle = %.5f, but expected %.5f", solid_angle, solid_angle_results[i].omega); + return 1; + } + } + + return 0; +} + struct tests { testFunction *test; char *name; @@ -999,6 +1024,7 @@ struct tests { {test_log_norm, "test_log_norm"}, {test_trapz, "test_trapz"}, {test_interp2d, "test_interp2d"}, + {test_solid_angle_fast, "test_solid_angle_fast"}, }; int main(int argc, char **argv) -- cgit