aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortlatorre <tlatorre@uchicago.edu>2019-11-18 10:22:34 -0600
committertlatorre <tlatorre@uchicago.edu>2019-11-18 10:22:34 -0600
commitf35baa0ed19b19be032107f812cc94a2b7582f4c (patch)
tree4cdf634b13398fce196331ed1a45563fb12d9be8 /src
parentf3472ab5fa5d6681b9ebbf296e80b3dfc47fa14b (diff)
downloadsddm-f35baa0ed19b19be032107f812cc94a2b7582f4c.tar.gz
sddm-f35baa0ed19b19be032107f812cc94a2b7582f4c.tar.bz2
sddm-f35baa0ed19b19be032107f812cc94a2b7582f4c.zip
fix bug due to roundoff error in get_{delta_ray,shower}_weights()
Diffstat (limited to 'src')
-rw-r--r--src/likelihood.c12
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);