Index: /trunk/psLib/src/dataManip/psConstants.h
===================================================================
--- /trunk/psLib/src/dataManip/psConstants.h	(revision 2217)
+++ /trunk/psLib/src/dataManip/psConstants.h	(revision 2218)
@@ -6,6 +6,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 21:06:30 $
+ *  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-10-27 21:25:52 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -36,4 +36,10 @@
 }
 
+#define PS_FLOAT_COMPARE(NAME1, NAME2, RVAL) \
+if ((NAME1 - NAME2) < -FLT_EPSILON) { \
+    psError(__func__,"%s is less than %s.", #NAME1, #NAME2); \
+    return(RVAL); \
+}
+
 
 
@@ -54,4 +60,15 @@
 }
 
+#define PS_PTR_CHECK_SIZE_EQUAL(PTR1, PTR2, RVAL) \
+if (PTR1->n != PTR2->n) { \
+    psError(__func__,"ptr %s has size %d, ptr %s has size %d.", #PTR1, PTR1->n, #PTR2, PTR2->n); \
+    return(RVAL); \
+}
+
+#define PS_PTR_CHECK_TYPE_EQUAL(PTR1, PTR2, RVAL) \
+if (PTR1->type.type != PTR2->type.type) { \
+    psError(__func__,"ptr %s has type %d, ptr %s has type %d.", #PTR1, PTR1->type.type, #PTR2, PTR2->type.type); \
+    return(RVAL); \
+}
 
 
Index: /trunk/psLib/src/dataManip/psFunctions.c
===================================================================
--- /trunk/psLib/src/dataManip/psFunctions.c	(revision 2217)
+++ /trunk/psLib/src/dataManip/psFunctions.c	(revision 2218)
@@ -7,6 +7,6 @@
  *  polynomials.  It also contains a Gaussian functions.
  *
- *  @version $Revision: 1.55 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 21:06:30 $
+ *  @version $Revision: 1.56 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-10-27 21:25:52 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -1688,13 +1688,12 @@
                             float max)
 {
+    PS_INT_CHECK_NON_NEGATIVE(numSplines, NULL);
+    PS_INT_CHECK_NON_NEGATIVE(order, NULL);
+    PS_FLOAT_COMPARE(max, min, NULL);
+
     psSpline1D *tmp = NULL;
     psS32 i;
     float tmpDomain;
     float width;
-
-    if (fabs(max-min) < FLT_EPSILON) {
-        psLogMsg(__func__, PS_LOG_WARN, "min and max are the same.\n");
-        return(NULL);
-    }
 
     tmp = (psSpline1D *) psAlloc(sizeof(psSpline1D));
@@ -1753,4 +1752,8 @@
                                    psS32 order)
 {
+    PS_INT_CHECK_NON_NEGATIVE(order, NULL);
+    PS_VECTOR_CHECK_NULL(bounds, NULL);
+    PS_VECTOR_CHECK_EMPTY(bounds, NULL);
+
     psSpline1D *tmp = NULL;
     psS32 i;
@@ -1898,8 +1901,5 @@
                           psScalar *x)
 {
-    if (x->type.type != bins->type.type) {
-        psError(__func__, "x->type.type != bins->type.type");
-        return(-2);
-    }
+    PS_PTR_CHECK_TYPE_EQUAL(x, bins, -2);
 
     if (x->type.type == PS_TYPE_S32) {
@@ -1927,4 +1927,8 @@
                                float x)
 {
+    PS_INT_CHECK_NON_NEGATIVE(n, NAN);
+    PS_PTR_CHECK_NULL(domain, NAN);
+    PS_PTR_CHECK_NULL(range, NAN);
+
     psS32 i;
     psS32 m;
@@ -2037,4 +2041,12 @@
                                 psScalar *x)
 {
+    PS_VECTOR_CHECK_NULL(domain, NULL);
+    PS_VECTOR_CHECK_NULL(range, NULL);
+    PS_PTR_CHECK_NULL(x, NULL);
+    PS_INT_CHECK_NON_NEGATIVE(order, NULL);
+    PS_VECTOR_CHECK_SIZE_EQUAL(domain, range, NULL);
+    PS_PTR_CHECK_TYPE_EQUAL(domain, range, NULL);
+    PS_PTR_CHECK_TYPE_EQUAL(domain, x, NULL);
+
     psVector *range32 = NULL;
     psVector *domain32 = NULL;
@@ -2042,20 +2054,7 @@
             "---- p_psVectorInterpolate() begin ----\n");
 
-    if ((domain->type.type != range->type.type) ||
-            (domain->type.type != x->type.type)) {
-        // XXX psError
-        printf("p_psVectorInterpolate(): domain->type.type != range->type.type != x->type.type\n");
-        printf("%d %d %d\n", domain->type.type, range->type.type, x->type.type);
-        exit(1);
-    }
-    if (domain->n != range->n) {
-        // XXX psError
-        printf("domain->n != range->n\n");
-        exit(1);
-    }
     if (order > (domain->n - 1)) {
-        // XXX psError: not enough data points for order-order interpolation.
-        printf("not enough data points for order-order interpolation.\n");
-        exit(1);
+        psError(__func__, "not enough data points for %d-order interpolation.\n", order);
+        return(NULL);
     }
 
@@ -2089,10 +2088,12 @@
     } else {
         // XXX psError: type not supported
-        printf("XXX psError: type not supported\n");
-    }
-
-    printf("return(NULL)\n");
+        psError(__func__, "type %d not supported\n", x->type.type);
+    }
+
+    psTrace(".psLib.dataManip.psFunctions.p_psVectorInterpolate", 4,
+            "return(NULL)\n");
     psTrace(".psLib.dataManip.psFunctions.p_psVectorInterpolate", 4,
             "---- p_psVectorInterpolate() end ----\n");
+
     return(NULL);
 }
@@ -2112,4 +2113,7 @@
                      float x)
 {
+    PS_PTR_CHECK_NULL(spline, NAN);
+    PS_INT_CHECK_NON_NEGATIVE(spline->n, NAN);
+
     psS32 binNum;
     psS32 n;
@@ -2138,4 +2142,8 @@
                                const psSpline1D *spline)
 {
+    PS_PTR_CHECK_NULL(spline, NULL);
+    PS_VECTOR_CHECK_NULL(x, NULL);
+    PS_VECTOR_CHECK_TYPE(x, PS_TYPE_F32, NULL);
+
     psS32 i;
     psVector *tmpVector;
Index: /trunk/psLib/src/math/psConstants.h
===================================================================
--- /trunk/psLib/src/math/psConstants.h	(revision 2217)
+++ /trunk/psLib/src/math/psConstants.h	(revision 2218)
@@ -6,6 +6,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 21:06:30 $
+ *  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-10-27 21:25:52 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -36,4 +36,10 @@
 }
 
+#define PS_FLOAT_COMPARE(NAME1, NAME2, RVAL) \
+if ((NAME1 - NAME2) < -FLT_EPSILON) { \
+    psError(__func__,"%s is less than %s.", #NAME1, #NAME2); \
+    return(RVAL); \
+}
+
 
 
@@ -54,4 +60,15 @@
 }
 
+#define PS_PTR_CHECK_SIZE_EQUAL(PTR1, PTR2, RVAL) \
+if (PTR1->n != PTR2->n) { \
+    psError(__func__,"ptr %s has size %d, ptr %s has size %d.", #PTR1, PTR1->n, #PTR2, PTR2->n); \
+    return(RVAL); \
+}
+
+#define PS_PTR_CHECK_TYPE_EQUAL(PTR1, PTR2, RVAL) \
+if (PTR1->type.type != PTR2->type.type) { \
+    psError(__func__,"ptr %s has type %d, ptr %s has type %d.", #PTR1, PTR1->type.type, #PTR2, PTR2->type.type); \
+    return(RVAL); \
+}
 
 
Index: /trunk/psLib/src/math/psPolynomial.c
===================================================================
--- /trunk/psLib/src/math/psPolynomial.c	(revision 2217)
+++ /trunk/psLib/src/math/psPolynomial.c	(revision 2218)
@@ -7,6 +7,6 @@
  *  polynomials.  It also contains a Gaussian functions.
  *
- *  @version $Revision: 1.55 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 21:06:30 $
+ *  @version $Revision: 1.56 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-10-27 21:25:52 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -1688,13 +1688,12 @@
                             float max)
 {
+    PS_INT_CHECK_NON_NEGATIVE(numSplines, NULL);
+    PS_INT_CHECK_NON_NEGATIVE(order, NULL);
+    PS_FLOAT_COMPARE(max, min, NULL);
+
     psSpline1D *tmp = NULL;
     psS32 i;
     float tmpDomain;
     float width;
-
-    if (fabs(max-min) < FLT_EPSILON) {
-        psLogMsg(__func__, PS_LOG_WARN, "min and max are the same.\n");
-        return(NULL);
-    }
 
     tmp = (psSpline1D *) psAlloc(sizeof(psSpline1D));
@@ -1753,4 +1752,8 @@
                                    psS32 order)
 {
+    PS_INT_CHECK_NON_NEGATIVE(order, NULL);
+    PS_VECTOR_CHECK_NULL(bounds, NULL);
+    PS_VECTOR_CHECK_EMPTY(bounds, NULL);
+
     psSpline1D *tmp = NULL;
     psS32 i;
@@ -1898,8 +1901,5 @@
                           psScalar *x)
 {
-    if (x->type.type != bins->type.type) {
-        psError(__func__, "x->type.type != bins->type.type");
-        return(-2);
-    }
+    PS_PTR_CHECK_TYPE_EQUAL(x, bins, -2);
 
     if (x->type.type == PS_TYPE_S32) {
@@ -1927,4 +1927,8 @@
                                float x)
 {
+    PS_INT_CHECK_NON_NEGATIVE(n, NAN);
+    PS_PTR_CHECK_NULL(domain, NAN);
+    PS_PTR_CHECK_NULL(range, NAN);
+
     psS32 i;
     psS32 m;
@@ -2037,4 +2041,12 @@
                                 psScalar *x)
 {
+    PS_VECTOR_CHECK_NULL(domain, NULL);
+    PS_VECTOR_CHECK_NULL(range, NULL);
+    PS_PTR_CHECK_NULL(x, NULL);
+    PS_INT_CHECK_NON_NEGATIVE(order, NULL);
+    PS_VECTOR_CHECK_SIZE_EQUAL(domain, range, NULL);
+    PS_PTR_CHECK_TYPE_EQUAL(domain, range, NULL);
+    PS_PTR_CHECK_TYPE_EQUAL(domain, x, NULL);
+
     psVector *range32 = NULL;
     psVector *domain32 = NULL;
@@ -2042,20 +2054,7 @@
             "---- p_psVectorInterpolate() begin ----\n");
 
-    if ((domain->type.type != range->type.type) ||
-            (domain->type.type != x->type.type)) {
-        // XXX psError
-        printf("p_psVectorInterpolate(): domain->type.type != range->type.type != x->type.type\n");
-        printf("%d %d %d\n", domain->type.type, range->type.type, x->type.type);
-        exit(1);
-    }
-    if (domain->n != range->n) {
-        // XXX psError
-        printf("domain->n != range->n\n");
-        exit(1);
-    }
     if (order > (domain->n - 1)) {
-        // XXX psError: not enough data points for order-order interpolation.
-        printf("not enough data points for order-order interpolation.\n");
-        exit(1);
+        psError(__func__, "not enough data points for %d-order interpolation.\n", order);
+        return(NULL);
     }
 
@@ -2089,10 +2088,12 @@
     } else {
         // XXX psError: type not supported
-        printf("XXX psError: type not supported\n");
-    }
-
-    printf("return(NULL)\n");
+        psError(__func__, "type %d not supported\n", x->type.type);
+    }
+
+    psTrace(".psLib.dataManip.psFunctions.p_psVectorInterpolate", 4,
+            "return(NULL)\n");
     psTrace(".psLib.dataManip.psFunctions.p_psVectorInterpolate", 4,
             "---- p_psVectorInterpolate() end ----\n");
+
     return(NULL);
 }
@@ -2112,4 +2113,7 @@
                      float x)
 {
+    PS_PTR_CHECK_NULL(spline, NAN);
+    PS_INT_CHECK_NON_NEGATIVE(spline->n, NAN);
+
     psS32 binNum;
     psS32 n;
@@ -2138,4 +2142,8 @@
                                const psSpline1D *spline)
 {
+    PS_PTR_CHECK_NULL(spline, NULL);
+    PS_VECTOR_CHECK_NULL(x, NULL);
+    PS_VECTOR_CHECK_TYPE(x, PS_TYPE_F32, NULL);
+
     psS32 i;
     psVector *tmpVector;
Index: /trunk/psLib/src/math/psSpline.c
===================================================================
--- /trunk/psLib/src/math/psSpline.c	(revision 2217)
+++ /trunk/psLib/src/math/psSpline.c	(revision 2218)
@@ -7,6 +7,6 @@
  *  polynomials.  It also contains a Gaussian functions.
  *
- *  @version $Revision: 1.55 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 21:06:30 $
+ *  @version $Revision: 1.56 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-10-27 21:25:52 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -1688,13 +1688,12 @@
                             float max)
 {
+    PS_INT_CHECK_NON_NEGATIVE(numSplines, NULL);
+    PS_INT_CHECK_NON_NEGATIVE(order, NULL);
+    PS_FLOAT_COMPARE(max, min, NULL);
+
     psSpline1D *tmp = NULL;
     psS32 i;
     float tmpDomain;
     float width;
-
-    if (fabs(max-min) < FLT_EPSILON) {
-        psLogMsg(__func__, PS_LOG_WARN, "min and max are the same.\n");
-        return(NULL);
-    }
 
     tmp = (psSpline1D *) psAlloc(sizeof(psSpline1D));
@@ -1753,4 +1752,8 @@
                                    psS32 order)
 {
+    PS_INT_CHECK_NON_NEGATIVE(order, NULL);
+    PS_VECTOR_CHECK_NULL(bounds, NULL);
+    PS_VECTOR_CHECK_EMPTY(bounds, NULL);
+
     psSpline1D *tmp = NULL;
     psS32 i;
@@ -1898,8 +1901,5 @@
                           psScalar *x)
 {
-    if (x->type.type != bins->type.type) {
-        psError(__func__, "x->type.type != bins->type.type");
-        return(-2);
-    }
+    PS_PTR_CHECK_TYPE_EQUAL(x, bins, -2);
 
     if (x->type.type == PS_TYPE_S32) {
@@ -1927,4 +1927,8 @@
                                float x)
 {
+    PS_INT_CHECK_NON_NEGATIVE(n, NAN);
+    PS_PTR_CHECK_NULL(domain, NAN);
+    PS_PTR_CHECK_NULL(range, NAN);
+
     psS32 i;
     psS32 m;
@@ -2037,4 +2041,12 @@
                                 psScalar *x)
 {
+    PS_VECTOR_CHECK_NULL(domain, NULL);
+    PS_VECTOR_CHECK_NULL(range, NULL);
+    PS_PTR_CHECK_NULL(x, NULL);
+    PS_INT_CHECK_NON_NEGATIVE(order, NULL);
+    PS_VECTOR_CHECK_SIZE_EQUAL(domain, range, NULL);
+    PS_PTR_CHECK_TYPE_EQUAL(domain, range, NULL);
+    PS_PTR_CHECK_TYPE_EQUAL(domain, x, NULL);
+
     psVector *range32 = NULL;
     psVector *domain32 = NULL;
@@ -2042,20 +2054,7 @@
             "---- p_psVectorInterpolate() begin ----\n");
 
-    if ((domain->type.type != range->type.type) ||
-            (domain->type.type != x->type.type)) {
-        // XXX psError
-        printf("p_psVectorInterpolate(): domain->type.type != range->type.type != x->type.type\n");
-        printf("%d %d %d\n", domain->type.type, range->type.type, x->type.type);
-        exit(1);
-    }
-    if (domain->n != range->n) {
-        // XXX psError
-        printf("domain->n != range->n\n");
-        exit(1);
-    }
     if (order > (domain->n - 1)) {
-        // XXX psError: not enough data points for order-order interpolation.
-        printf("not enough data points for order-order interpolation.\n");
-        exit(1);
+        psError(__func__, "not enough data points for %d-order interpolation.\n", order);
+        return(NULL);
     }
 
@@ -2089,10 +2088,12 @@
     } else {
         // XXX psError: type not supported
-        printf("XXX psError: type not supported\n");
-    }
-
-    printf("return(NULL)\n");
+        psError(__func__, "type %d not supported\n", x->type.type);
+    }
+
+    psTrace(".psLib.dataManip.psFunctions.p_psVectorInterpolate", 4,
+            "return(NULL)\n");
     psTrace(".psLib.dataManip.psFunctions.p_psVectorInterpolate", 4,
             "---- p_psVectorInterpolate() end ----\n");
+
     return(NULL);
 }
@@ -2112,4 +2113,7 @@
                      float x)
 {
+    PS_PTR_CHECK_NULL(spline, NAN);
+    PS_INT_CHECK_NON_NEGATIVE(spline->n, NAN);
+
     psS32 binNum;
     psS32 n;
@@ -2138,4 +2142,8 @@
                                const psSpline1D *spline)
 {
+    PS_PTR_CHECK_NULL(spline, NULL);
+    PS_VECTOR_CHECK_NULL(x, NULL);
+    PS_VECTOR_CHECK_TYPE(x, PS_TYPE_F32, NULL);
+
     psS32 i;
     psVector *tmpVector;
