aboutsummaryrefslogtreecommitdiff
path: root/src/scalar.c
diff options
context:
space:
mode:
authorJamie Bullock <jamie@jamiebullock.com>2014-02-11 16:39:41 +0000
committerJamie Bullock <jamie@jamiebullock.com>2014-02-11 16:39:41 +0000
commit1ba85b048b5d7e9cee0453b48a1f0ff16990cfa7 (patch)
tree053092e1da54d0736ffd2f8f96d54ecae20b6eba /src/scalar.c
parent4805c96fce84b57ed44327a6e4e91a9d970ea27a (diff)
downloadLibXtract-1ba85b048b5d7e9cee0453b48a1f0ff16990cfa7.tar.gz
LibXtract-1ba85b048b5d7e9cee0453b48a1f0ff16990cfa7.tar.bz2
LibXtract-1ba85b048b5d7e9cee0453b48a1f0ff16990cfa7.zip
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
Diffstat (limited to 'src/scalar.c')
-rw-r--r--src/scalar.c9
1 files changed, 6 insertions, 3 deletions
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 <string.h>
#include <stdio.h>
#include <math.h>
+#include <limits.h>
#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;
}