]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
regress: provide function to find median
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 21 Jun 2017 17:11:10 +0000 (19:11 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Tue, 27 Jun 2017 13:29:01 +0000 (15:29 +0200)
regress.c
regress.h

index 68ef4fa911956df34ab35f40f2d0369341058d46..e744c500b5cb8096e613b899f3ae34f4ef5e26bf 100644 (file)
--- a/regress.c
+++ b/regress.c
@@ -429,6 +429,19 @@ find_median(double *x, int n)
   }
 }
 
+/* ================================================== */
+
+double
+RGR_FindMedian(double *x, int n)
+{
+  double tmp[MAX_POINTS];
+
+  assert(n > 0 && n <= MAX_POINTS);
+  memcpy(tmp, x, n * sizeof (tmp[0]));
+
+  return find_median(tmp, n);
+}
+
 /* ================================================== */
 /* This function evaluates the equation
 
index 4e4c32b0d765b72cca015d33b8428778dc1d3b1e..90055dad2e153e20f2a3edcdbfdca8d4e5ffe7c1 100644 (file)
--- a/regress.h
+++ b/regress.h
@@ -131,4 +131,7 @@ RGR_MultipleRegress
  double *b2                     /* estimated second slope */
 );
 
+/* Return the median value from an array */
+extern double RGR_FindMedian(double *x, int n);
+
 #endif /* GOT_REGRESS_H */