From: Miroslav Lichvar Date: Wed, 21 Jun 2017 17:11:10 +0000 (+0200) Subject: regress: provide function to find median X-Git-Tag: 3.2-pre1~41 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6207655ab285a7fa10bba99b2801526bfae72182;p=thirdparty%2Fchrony.git regress: provide function to find median --- diff --git a/regress.c b/regress.c index 68ef4fa9..e744c500 100644 --- 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 diff --git a/regress.h b/regress.h index 4e4c32b0..90055dad 100644 --- 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 */