Index: trunk/psLib/src/math/psPolynomial.c
===================================================================
--- trunk/psLib/src/math/psPolynomial.c	(revision 2327)
+++ trunk/psLib/src/math/psPolynomial.c	(revision 2329)
@@ -7,6 +7,6 @@
  *  polynomials.  It also contains a Gaussian functions.
  *
- *  @version $Revision: 1.61 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-11-10 23:05:49 $
+ *  @version $Revision: 1.62 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-10 23:22:32 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -1876,117 +1876,11 @@
 
 /*****************************************************************************
-vectorBinDisectF32(): This is a private function which takes as input a
-vector of floating point data as well as a single floating point values.
-The input vector values are assumed to be non-decreasing (v[i-1] <= v[j] for
-all j>=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).
- 
-XXX: Macro this for a few different types.
- 
-XXX: name since we don't take psVectors as input.
+vectorBinDisectF32(): This is a macro for a private function which takes as
+input a vector 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).
  *****************************************************************************/
-/*
-static psS32 vectorBinDisectF32(float *bins,
-                                psS32 numBins,
-                                float x)
-{
-    psS32 min;
-    psS32 max;
-    psS32 mid;
- 
-    psTrace(".psLib.dataManip.psFunctions.vectorBinDisectF32", 4,
-            "---- Calling vectorBinDisectF32(%f)\n", x);
- 
-    if (x < bins[0]) {
-        psLogMsg(__func__, PS_LOG_WARN,
-                 "vectorBinDisectF32(): ordinate %f is outside vector range (%f - %f).",
-                 x, bins[0], bins[numBins-1]);
-        return(-2);
-    }
- 
-    if (x > bins[numBins-1]) {
-        psLogMsg(__func__, PS_LOG_WARN,
-                 "vectorBinDisectF32(): ordinate %f is outside vector range (%f - %f).",
-                 x, bins[0], bins[numBins-1]);
-        return(-1);
-    }
- 
-    min = 0;
-    max = numBins-2;
-    mid = ((max+1)-min)/2;
- 
-    while (min != max) {
-        psTrace(".psLib.dataManip.psFunctions.vectorBinDisectF32", 4,
-                "(min, mid, max) is (%d, %d, %d): (x, bins) is (%f, %f)\n",
-                min, mid, max, x, bins[mid]);
- 
-        if (x == bins[mid]) {
-            psTrace(".psLib.dataManip.psFunctions.vectorBinDisectF32", 4,
-                    "---- Exiting vectorBinDisectF32(): bin %d\n", mid);
-            return(mid);
-        } else if (x < bins[mid]) {
-            max = mid-1;
-        } else {
-            min = mid;
-        }
-        mid = ((max+1)+min)/2;
-    }
- 
-    psTrace(".psLib.dataManip.psFunctions.vectorBinDisectF32", 4,
-            "---- Exiting vectorBinDisectF32(): bin %d\n", min);
-    return(min);
-}
-*/
-/*****************************************************************************
-vectorBinDisectS32(): integer version of above.
- *****************************************************************************/
-/*
-static psS32 vectorBinDisectS32(psS32 *bins,
-                                psS32 numBins,
-                                psS32 x)
-{
-    psS32 min;
-    psS32 max;
-    psS32 mid;
- 
-    psTrace(".psLib.dataManip.psFunctions.vectorBinDisectS32", 4,
-            "---- Calling vectorBinDisectS32(%f)\n", x);
- 
-    if ((x < bins[0]) ||
-            (x > bins[numBins-1])) {
-        psLogMsg(__func__, PS_LOG_WARN,
-                 "vectorBinDisectS32(): ordinate %f is outside vector range (%f - %f).",
-                 x, bins[0], bins[numBins-1]);
-        return(-1);
-    }
- 
-    min = 0;
-    max = numBins-2;
-    mid = ((max+1)-min)/2;
- 
-    while (min != max) {
-        psTrace(".psLib.dataManip.psFunctions.vectorBinDisectS32", 4,
-                "(min, mid, max) is (%d, %d, %d): (x, bins) is (%f, %f)\n",
-                min, mid, max, x, bins[mid]);
- 
-        if (x == bins[mid]) {
-            psTrace(".psLib.dataManip.psFunctions.vectorBinDisectS32", 4,
-                    "---- Exiting vectorBinDisectS32(): bin %d\n", min);
-            return(min);
-        } else if (x < bins[mid]) {
-            max = mid-1;
-        } else {
-            min = mid;
-        }
-        mid = ((max+1)+min)/2;
-    }
- 
-    psTrace(".psLib.dataManip.psFunctions.vectorBinDisectS32", 4,
-            "---- Exiting vectorBinDisectS32(): bin %d\n", min);
-    return(min);
-}
-*/
-
 #define FUNC_MACRO_VECTOR_BIN_DISECT(TYPE) \
 static psS32 vectorBinDisect##TYPE(ps##TYPE *bins, \
@@ -2058,19 +1952,35 @@
                           psScalar *x)
 {
-    PS_PTR_CHECK_TYPE_EQUAL(x, bins, -2);
-
-    if (x->type.type == PS_TYPE_S32) {
+    PS_PTR_CHECK_TYPE_EQUAL(x, bins, -3);
+
+    switch (x->type.type) {
+    case PS_TYPE_U8:
+        return(vectorBinDisectU8(bins->data.U8, bins->n, x->data.U8));
+    case PS_TYPE_U16:
+        return(vectorBinDisectU16(bins->data.U16, bins->n, x->data.U16));
+    case PS_TYPE_U32:
+        return(vectorBinDisectU32(bins->data.U32, bins->n, x->data.U32));
+    case PS_TYPE_U64:
+        return(vectorBinDisectU64(bins->data.U64, bins->n, x->data.U64));
+    case PS_TYPE_S8:
+        return(vectorBinDisectS8(bins->data.S8, bins->n, x->data.S8));
+    case PS_TYPE_S16:
+        return(vectorBinDisectS16(bins->data.S16, bins->n, x->data.S16));
+    case PS_TYPE_S32:
         return(vectorBinDisectS32(bins->data.S32, bins->n, x->data.S32));
-    } else if (x->type.type == PS_TYPE_F32) {
+    case PS_TYPE_S64:
+        return(vectorBinDisectS64(bins->data.S64, bins->n, x->data.S64));
+    case PS_TYPE_F32:
         return(vectorBinDisectF32(bins->data.F32, bins->n, x->data.F32));
-    } else {
-        char* strType;
-        PS_TYPE_NAME(strType,x->type.type);
-        psError(PS_ERR_BAD_PARAMETER_TYPE,
-                PS_ERRORTEXT_psFunctions_TYPE_NOT_SUPPORTED,
-                strType);
-        return(-2);
-    }
-    return(-1);
+    case PS_TYPE_F64:
+        return(vectorBinDisectF64(bins->data.F64, bins->n, x->data.F64));
+    }
+
+    char* strType;
+    PS_TYPE_NAME(strType,x->type.type);
+    psError(PS_ERR_BAD_PARAMETER_TYPE,
+            PS_ERRORTEXT_psFunctions_TYPE_NOT_SUPPORTED,
+            strType);
+    return(-3);
 }
 
