From 1ba85b048b5d7e9cee0453b48a1f0ff16990cfa7 Mon Sep 17 00:00:00 2001 From: Jamie Bullock Date: Tue, 11 Feb 2014 16:39:41 +0000 Subject: Make xtract_lowest_value() return XTRACT_NO_RESULT if all values in the input data are below or equal to threshold value. Fixes #46 If XTRACT_NO_RESULT is returned, *result will be set to DBL_MAX --- src/scalar.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/scalar.c b/src/scalar.c index 934f14e..3ecd446 100644 --- a/src/scalar.c +++ b/src/scalar.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "dywapitchtrack/dywapitchtrack.h" @@ -746,16 +747,18 @@ int xtract_lowest_value(const double *data, const int N, const void *argv, doubl { int n = N; - double temp; - *result = data[--n]; + *result = DBL_MAX; while(n--) { - if((temp = data[n]) > *(double *)argv) + if(data[n] > *(double *)argv) *result = XTRACT_MIN(*result, data[n]); } + if (*result == DBL_MAX) + return XTRACT_NO_RESULT; + return XTRACT_SUCCESS; } -- cgit v1.2.3