diff options
author | tlatorre <tlatorre@uchicago.edu> | 2018-10-21 11:32:40 -0500 |
---|---|---|
committer | tlatorre <tlatorre@uchicago.edu> | 2018-10-21 11:32:40 -0500 |
commit | 04656e730d1f0a1c55fdee48e8ea9f34552c03d8 (patch) | |
tree | 3714efc8ccad7e2317f6e63d83bb81dcb9d6d60b /src/test.c | |
parent | b6af7f268dcd7b7508ab7c5a6b1ba5c3384b9c5d (diff) | |
download | sddm-04656e730d1f0a1c55fdee48e8ea9f34552c03d8.tar.gz sddm-04656e730d1f0a1c55fdee48e8ea9f34552c03d8.tar.bz2 sddm-04656e730d1f0a1c55fdee48e8ea9f34552c03d8.zip |
add a fast solid angle approximation to speed up the fast likelihood calculation
Diffstat (limited to 'src/test.c')
-rw-r--r-- | src/test.c | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -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) |