diff options
author | tlatorre <tlatorre@uchicago.edu> | 2018-10-18 10:13:54 -0500 |
---|---|---|
committer | tlatorre <tlatorre@uchicago.edu> | 2018-10-18 10:13:54 -0500 |
commit | 4f1c77fb1dcc1c1a927c0ee6b7571aebcff71495 (patch) | |
tree | 427fb1ab4017868cf0d228750d812c0e1bb85940 /src/path.c | |
parent | 93f4b97a553998ac8fb59005c3d99b303afb6f60 (diff) | |
download | sddm-4f1c77fb1dcc1c1a927c0ee6b7571aebcff71495.tar.gz sddm-4f1c77fb1dcc1c1a927c0ee6b7571aebcff71495.tar.bz2 sddm-4f1c77fb1dcc1c1a927c0ee6b7571aebcff71495.zip |
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.
Diffstat (limited to 'src/path.c')
-rw-r--r-- | src/path.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -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]; |