aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/likelihood.c4
-rw-r--r--src/misc.c22
-rw-r--r--src/misc.h4
-rw-r--r--src/test.c27
4 files changed, 2 insertions, 55 deletions
diff --git a/src/likelihood.c b/src/likelihood.c
index 9037cb9..abf064f 100644
--- a/src/likelihood.c
+++ b/src/likelihood.c
@@ -572,10 +572,10 @@ static void get_expected_charge(double beta, double theta0, double *pos, double
/* Calculate the cosine of the angle between the track direction and the
* vector to the PMT. */
cos_theta = DOT(dir,pmt_dir);
- sin_theta = fast_sqrt(1-cos_theta*cos_theta);
+ sin_theta = sqrt(1-cos_theta*cos_theta);
cos_theta_pmt = -DOT(pmt_dir,pmts[pmt].normal);
- sin_theta_pmt = fast_sqrt(1-cos_theta_pmt*cos_theta_pmt);
+ sin_theta_pmt = sqrt(1-cos_theta_pmt*cos_theta_pmt);
theta0 = fmax(theta0,get_theta0_min(distance_to_pmt,PMT_RADIUS,sin_theta_pmt));
diff --git a/src/misc.c b/src/misc.c
index 003b170..f705c74 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -881,25 +881,3 @@ double fast_acos(double x)
return interp1d(x,xs,ys,LEN(xs));
}
-
-/* Fast version of sqrt() for `x` between 0 and 1 which uses a lookup table
- * computed on the first call. */
-double fast_sqrt(double x)
-{
- size_t i;
- static int initialized = 0;
- static double xs[N_SQRT];
- static double ys[N_SQRT];
-
- if (!initialized) {
- for (i = 0; i < LEN(xs); i++) {
- xs[i] = 1.0*i/(LEN(xs)-1);
- ys[i] = sqrt(xs[i]);
- }
- initialized = 1;
- }
-
- if (x > 1.0) return sqrt(x);
-
- return interp1d(x,xs,ys,LEN(xs));
-}
diff --git a/src/misc.h b/src/misc.h
index e40c1f5..60e54ea 100644
--- a/src/misc.h
+++ b/src/misc.h
@@ -30,9 +30,6 @@
/* Number of points to create a lookup table for the fast_acos() function. */
#define N_ACOS 10000
-/* Number of points to create a lookup table for the fast_sqrt() function. */
-#define N_SQRT 10000
-
double trapz(const double *y, double dx, size_t n);
int intersect_sphere(double *pos, double *dir, double R, double *l);
void get_path_length(double *pos1, double *pos2, double R, double *l1, double *l2);
@@ -58,6 +55,5 @@ size_t argmax(double *a, size_t n);
size_t argmin(double *a, size_t n);
void get_dir(double *dir, double theta, double phi);
double fast_acos(double x);
-double fast_sqrt(double x);
#endif
diff --git a/src/test.c b/src/test.c
index 100091c..d07ee11 100644
--- a/src/test.c
+++ b/src/test.c
@@ -2100,32 +2100,6 @@ err:
return 1;
}
-int test_fast_sqrt(char *err)
-{
- /* Tests that the fast_sqrt() function returns values within 0.1% of sqrt(). */
- size_t i;
- double x, result, expected;
-
- init_genrand(0);
-
- for (i = 0; i < 100; i++) {
- x = genrand_real2()*2;
-
- result = fast_sqrt(x);
- expected = sqrt(x);
-
- if (!isclose(result, expected, 0, 1e-3)) {
- sprintf(err, "fast_sqrt() returned %.5g, but expected %.5g", result, expected);
- goto err;
- }
- }
-
- return 0;
-
-err:
- return 1;
-}
-
int test_get_most_likely_mean_pe(char *err)
{
/* Tests that the get_most_likely_mean_pe() function returns values which
@@ -2207,7 +2181,6 @@ struct tests {
{test_argmin, "test_argmin"},
{test_electron_get_angular_pdf_norm, "test_electron_get_angular_pdf_norm"},
{test_fast_acos, "test_fast_acos"},
- {test_fast_sqrt, "test_fast_sqrt"},
{test_get_most_likely_mean_pe, "test_get_most_likely_mean_pe"},
};