From 4f1c77fb1dcc1c1a927c0ee6b7571aebcff71495 Mon Sep 17 00:00:00 2001 From: tlatorre Date: Thu, 18 Oct 2018 10:13:54 -0500 Subject: update path_init() to check for a divide by zero This commit updates path_init() to check that beta > 0 before dividing by it to compute the time. Previously when fitting electrons it would occasionally divide by zero which would cause the inf to propagate all the way through the likelihood function. --- src/path.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/path.c') diff --git a/src/path.c b/src/path.c index 340f8c7..85233d6 100644 --- a/src/path.c +++ b/src/path.c @@ -84,7 +84,10 @@ path *path_init(double *pos, double *dir, double T0, double range, double theta0 dz[i] = (s[i]-s[i-1])*cos(theta); /* Calculate total energy */ - t[i] = t[i-1] + (s[i]-s[i-1])/(beta[i]*SPEED_OF_LIGHT); + if (beta[i] > 0) + t[i] = t[i-1] + (s[i]-s[i-1])/(beta[i]*SPEED_OF_LIGHT); + else + t[i] = t[i-1]; x[i] = x[i-1] + dx[i]; y[i] = y[i-1] + dy[i]; -- cgit