Index: trunk/psLib/src/math/psMathUtils.c
===================================================================
--- trunk/psLib/src/math/psMathUtils.c	(revision 10999)
+++ trunk/psLib/src/math/psMathUtils.c	(revision 12434)
@@ -3,6 +3,6 @@
  *  This file contains standard math routines.
  *
- *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-01-09 22:38:53 $
+ *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-03-14 02:36:28 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -31,4 +31,5 @@
 #include "psAssert.h"
 #include "psConstants.h"
+#include "psAbort.h"
 
 /*****************************************************************************/
@@ -55,5 +56,5 @@
 This is a macro covering the various types for the below function.
  *****************************************************************************/
-#define VECTOR_BIN_DISECT_CASE(TYPE) \
+#define VECTOR_BINARY_DISECT_CASE(TYPE) \
 case PS_TYPE_##TYPE: { \
     ps##TYPE *bounds = bins->data.TYPE; \
@@ -65,14 +66,16 @@
     /* psTrace("psLib.math", 6, "Determining the bin for: %f\n", x); */\
     if (value < bounds[0]) { \
-        psLogMsg(__func__, PS_LOG_WARN, \
-                 "vectorBinDisect%s(): ordinate %f is outside vector range (%f - %f).", \
-                 #TYPE, (double)value, (double)bounds[0], (double)bounds[numBins-1]); \
-        return(-2); \
+        psTrace("psLib.math", 3, \
+                 "psVectorBinaryDisect : ordinate %f is outside vector range (%f - %f).", \
+                 (double)value, (double)bounds[0], (double)bounds[numBins-1]); \
+        *status = PS_BINARY_DISECT_OUTSIDE_RANGE; \
+        return (0); \
     } \
     if (value > bounds[numBins-1]) { \
-        psLogMsg(__func__, PS_LOG_WARN, \
-                 "vectorBinDisect%s(): ordinate %f is outside vector range (%f - %f).", \
-                 #TYPE, (double)value, (double)bounds[0], (double)bounds[numBins-1]); \
-        return(-1); \
+        psTrace("psLib.math", 3, \
+                 "psVectorBinaryDisect : ordinate %f is outside vector range (%f - %f).", \
+                 (double)value, (double)bounds[0], (double)bounds[numBins-1]); \
+        *status = PS_BINARY_DISECT_OUTSIDE_RANGE; \
+        return (numBins-1); \
     } \
     \
@@ -97,38 +100,43 @@
 
 /*****************************************************************************
-p_psVectorBinDisect(): This function takes as input an array of data as well as a single value for that data.
+psVectorBinDisect(): This function takes as input an array of data as well as a single value for that data.
 The input vector values are assumed to be non-decreasing (v[i-1] <= v[i] for all i).  This routine does a
 binary disection of the vector and returns "i" such that (v[i] <= x <= v[i+1).  If x lies outside the range of
 v[], then this routine prints a warning message and returns (-2 or -1).
   *****************************************************************************/
-psS32 p_psVectorBinDisect(
+psS32 psVectorBinaryDisect(
+    psVectorBinaryDisectResult *status,
     const psVector *bins,
     const psScalar *x)
 {
-    PS_ASSERT_VECTOR_NON_NULL(bins, -4);
-    PS_ASSERT_VECTOR_NON_EMPTY(bins, -4);
-    PS_ASSERT_PTR_NON_NULL(x, -6);
-    PS_ASSERT_PTR_TYPE_EQUAL(x, bins, -3);
+    PS_ASSERT_GENERAL_VECTOR_NON_NULL (bins, *status = PS_BINARY_DISECT_INVALID_INPUT; return 0);
+    PS_ASSERT_GENERAL_VECTOR_NON_EMPTY(bins, *status = PS_BINARY_DISECT_INVALID_INPUT; return 0);
+    PS_ASSERT_GENERAL_PTR_NON_NULL(x, *status = PS_BINARY_DISECT_INVALID_INPUT; return 0);
+    PS_ASSERT_GENERAL_PTR_TYPE_EQUAL(x, bins, *status = PS_BINARY_DISECT_INVALID_INPUT; return 0);
     long numBins = bins->n;             // Number of bins
 
+    *status = PS_BINARY_DISECT_PASS;
+
     switch (x->type.type) {
-        VECTOR_BIN_DISECT_CASE(S8);
-        VECTOR_BIN_DISECT_CASE(S16);
-        VECTOR_BIN_DISECT_CASE(S32);
-        VECTOR_BIN_DISECT_CASE(S64);
-        VECTOR_BIN_DISECT_CASE(U8);
-        VECTOR_BIN_DISECT_CASE(U16);
-        VECTOR_BIN_DISECT_CASE(U32);
-        VECTOR_BIN_DISECT_CASE(U64);
-        VECTOR_BIN_DISECT_CASE(F32);
-        VECTOR_BIN_DISECT_CASE(F64);
+        VECTOR_BINARY_DISECT_CASE(S8);
+        VECTOR_BINARY_DISECT_CASE(S16);
+        VECTOR_BINARY_DISECT_CASE(S32);
+        VECTOR_BINARY_DISECT_CASE(S64);
+        VECTOR_BINARY_DISECT_CASE(U8);
+        VECTOR_BINARY_DISECT_CASE(U16);
+        VECTOR_BINARY_DISECT_CASE(U32);
+        VECTOR_BINARY_DISECT_CASE(U64);
+	VECTOR_BINARY_DISECT_CASE(F32);
+        VECTOR_BINARY_DISECT_CASE(F64);
     default: {
             char* strType;
             PS_TYPE_NAME(strType, x->type.type);
             psError(PS_ERR_BAD_PARAMETER_TYPE, "psLib type %s is not supported.", strType);
-            return -1;
+	    *status = PS_BINARY_DISECT_INVALID_TYPE;
+            return 0;
         }
     }
-    return(-3);
+    psAbort ("programming error");
+    return (0);
 }
 
@@ -151,5 +159,6 @@
     } \
     psVector *p = psVectorCopy(NULL, range, PS_TYPE_##TYPE); \
-    psS32 binNum = p_psVectorBinDisect(domain, x); \
+    psVectorBinaryDisectResult result; \
+    psS32 binNum = psVectorBinaryDisect(&result, domain, x); \
     \
     psS32 numIntPoints = order+1; \
