diff options
author | tlatorre <tlatorre@uchicago.edu> | 2019-11-18 10:22:34 -0600 |
---|---|---|
committer | tlatorre <tlatorre@uchicago.edu> | 2019-11-18 10:22:34 -0600 |
commit | f35baa0ed19b19be032107f812cc94a2b7582f4c (patch) | |
tree | 4cdf634b13398fce196331ed1a45563fb12d9be8 | |
parent | f3472ab5fa5d6681b9ebbf296e80b3dfc47fa14b (diff) | |
download | sddm-f35baa0ed19b19be032107f812cc94a2b7582f4c.tar.gz sddm-f35baa0ed19b19be032107f812cc94a2b7582f4c.tar.bz2 sddm-f35baa0ed19b19be032107f812cc94a2b7582f4c.zip |
fix bug due to roundoff error in get_{delta_ray,shower}_weights()
-rw-r--r-- | src/likelihood.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/likelihood.c b/src/likelihood.c index 5ca9c8d..4a368c6 100644 --- a/src/likelihood.c +++ b/src/likelihood.c @@ -355,7 +355,11 @@ int get_delta_ray_weights(particle *p, double range, double distance_to_psup, do * compute cos(theta) for each of these values, map that value back to x, * and then compute the weight associated with that point. */ for (i = 0; i < n + 1; i++) { - cdf = cdf1 + i*delta; + if (i < n) + cdf = cdf1 + i*delta; + else + cdf = cdf2; + cos_theta = gsl_spline_eval(p->spline_delta,cdf,p->acc_delta); xcdf = cos_theta_to_x(cos_theta,R,cos_gamma,sin_gamma); @@ -446,7 +450,11 @@ int get_shower_weights(particle *p, double distance_to_psup, double *x, double * * compute cos(theta) for each of these values, map that value back to x, * and then compute the weight associated with that point. */ for (i = 0; i < n + 1; i++) { - cdf = cdf1 + i*delta; + if (i < n) + cdf = cdf1 + i*delta; + else + cdf = cdf2; + cos_theta = gsl_spline_eval(p->spline_shower,cdf,p->acc_shower); xcdf = cos_theta_to_x(cos_theta,R,cos_gamma,sin_gamma); |