Index: trunk/psLib/src/math/psSpline.c
===================================================================
--- trunk/psLib/src/math/psSpline.c	(revision 2324)
+++ trunk/psLib/src/math/psSpline.c	(revision 2327)
@@ -7,6 +7,6 @@
  *  polynomials.  It also contains a Gaussian functions.
  *
- *  @version $Revision: 1.60 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-11-10 22:43:48 $
+ *  @version $Revision: 1.61 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-10 23:05:49 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -1887,4 +1887,5 @@
 XXX: name since we don't take psVectors as input.
  *****************************************************************************/
+/*
 static psS32 vectorBinDisectF32(float *bins,
                                 psS32 numBins,
@@ -1894,8 +1895,8 @@
     psS32 max;
     psS32 mid;
-
+ 
     psTrace(".psLib.dataManip.psFunctions.vectorBinDisectF32", 4,
             "---- Calling vectorBinDisectF32(%f)\n", x);
-
+ 
     if (x < bins[0]) {
         psLogMsg(__func__, PS_LOG_WARN,
@@ -1904,5 +1905,5 @@
         return(-2);
     }
-
+ 
     if (x > bins[numBins-1]) {
         psLogMsg(__func__, PS_LOG_WARN,
@@ -1911,14 +1912,14 @@
         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,
@@ -1932,13 +1933,14 @@
         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,
@@ -1948,8 +1950,8 @@
     psS32 max;
     psS32 mid;
-
+ 
     psTrace(".psLib.dataManip.psFunctions.vectorBinDisectS32", 4,
             "---- Calling vectorBinDisectS32(%f)\n", x);
-
+ 
     if ((x < bins[0]) ||
             (x > bins[numBins-1])) {
@@ -1959,14 +1961,14 @@
         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,
@@ -1980,9 +1982,73 @@
         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, \
+                                   psS32 numBins, \
+                                   ps##TYPE x) \
+{ \
+    psS32 min; \
+    psS32 max; \
+    psS32 mid; \
+    \
+    psTrace(".psLib.dataManip.psFunctions.vectorBinDisect##TYPE", 4, \
+            "---- Calling vectorBinDisect##TYPE(%f)\n", x); \
+    \
+    if (x < bins[0]) { \
+        psLogMsg(__func__, PS_LOG_WARN, \
+                 "vectorBinDisect##TYPE(): 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, \
+                 "vectorBinDisect##TYPE(): 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.vectorBinDisect##TYPE", 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.vectorBinDisect##TYPE", 4, \
+                    "---- Exiting vectorBinDisect##TYPE(): 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.vectorBinDisect##TYPE", 4, \
+            "---- Exiting vectorBinDisect##TYPE(): bin %d\n", min); \
+    return(min); \
+} \
+
+FUNC_MACRO_VECTOR_BIN_DISECT(S8)
+FUNC_MACRO_VECTOR_BIN_DISECT(S16)
+FUNC_MACRO_VECTOR_BIN_DISECT(S32)
+FUNC_MACRO_VECTOR_BIN_DISECT(S64)
+FUNC_MACRO_VECTOR_BIN_DISECT(U8)
+FUNC_MACRO_VECTOR_BIN_DISECT(U16)
+FUNC_MACRO_VECTOR_BIN_DISECT(U32)
+FUNC_MACRO_VECTOR_BIN_DISECT(U64)
+FUNC_MACRO_VECTOR_BIN_DISECT(F32)
+FUNC_MACRO_VECTOR_BIN_DISECT(F64)
 
 /*****************************************************************************
