Index: trunk/psLib/src/mathtypes/psImage.c
===================================================================
--- trunk/psLib/src/mathtypes/psImage.c	(revision 5113)
+++ trunk/psLib/src/mathtypes/psImage.c	(revision 5114)
@@ -9,6 +9,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.84 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-09-23 00:04:36 $
+ *  @version $Revision: 1.85 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-09-24 00:17:44 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -272,12 +272,26 @@
                 complex value)
 {
-    if (image == NULL)
+    if (image == NULL) {
+        psError(PS_ERR_BAD_PARAMETER_NULL, true, PS_ERRORTEXT_psImage_IMAGE_NULL);
         return false;
-    if (x >= image->numRows || y >= image->numCols)
+    }
+    if (x >= image->numRows || y >= image->numCols) {
+        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position.  Position too large\n");
         return false;
+    }
+
     if(x < 0)
         x += image->numRows;
+    if(x < 0) {
+        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid x.  Negative number too large\n");
+        return false;
+    }
+
     if(y < 0)
         y += image->numCols;
+    if(y < 0) {
+        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid y.  Negative number too large\n");
+        return false;
+    }
 
     switch (image->type.type) {
@@ -330,12 +344,26 @@
                    int y)
 {
-    if (image == NULL)
+    if (image == NULL) {
+        psError(PS_ERR_BAD_PARAMETER_NULL, true, PS_ERRORTEXT_psImage_IMAGE_NULL);
         return NAN;
-    if (x >= image->numRows || y >= image->numCols)
+    }
+    if (x >= image->numRows || y >= image->numCols) {
+        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position.  Position too large\n");
         return NAN;
+    }
+
     if(x < 0)
         x += image->numRows;
+    if(x < 0) {
+        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid x.  Negative number too large\n");
+        return NAN;
+    }
+
     if(y < 0)
         y += image->numCols;
+    if(y < 0) {
+        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid y.  Negative number too large\n");
+        return NAN;
+    }
 
     switch (image->type.type) {
@@ -377,4 +405,5 @@
         break;
     default:
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Invalid psImage Data Type\n");
         return NAN;
     }
Index: trunk/psLib/src/mathtypes/psVector.c
===================================================================
--- trunk/psLib/src/mathtypes/psVector.c	(revision 5113)
+++ trunk/psLib/src/mathtypes/psVector.c	(revision 5114)
@@ -9,6 +9,6 @@
 *  @author Robert DeSonia, MHPCC
 *
-*  @version $Revision: 1.55 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2005-09-23 00:04:36 $
+*  @version $Revision: 1.56 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2005-09-24 00:17:44 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -817,10 +817,28 @@
                  complex value)
 {
-    if (input == NULL)
+    if (input == NULL) {
+        psError(PS_ERR_BAD_PARAMETER_NULL, true, PS_ERRORTEXT_psVector_NULL);
         return false;
-    if (position >= input->n)
+    }
+    if (position > input->n) {
+        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position.  Number too large\n");
         return false;
-    if(position < 0)
+    }
+    if (position < 0)
         position += input->n;
+    if (position < 0) {
+        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position.  Negative number too large\n");
+        return false;
+    }
+
+    if (position == input->n) {
+        if (position >= input->nalloc) {
+            psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                    "Specified position, %ld, is greater than n+1 of the vector, %ld.",
+                    position, input->nalloc);
+            return false;
+        }
+        (*(psVector**)&input)->n++;
+    }
 
     switch (input->type.type) {
@@ -872,12 +890,18 @@
                     long position)
 {
-    if (input == NULL)
+    if (input == NULL) {
+        psError(PS_ERR_BAD_PARAMETER_NULL, true, PS_ERRORTEXT_psVector_NULL);
         return NAN;
+    }
     if (position >= input->n) {
+        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position.  Number too large\n");
         return NAN;
     }
     if(position < 0)
         position += input->n;
-
+    if (position < 0) {
+        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position.  Negative number too large\n");
+        return NAN;
+    }
     switch (input->type.type) {
     case PS_TYPE_U8:
@@ -918,4 +942,5 @@
         break;
     default:
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Invalid psVector Data Type\n");
         return NAN;
     }
Index: trunk/psLib/src/mathtypes/psVector.h
===================================================================
--- trunk/psLib/src/mathtypes/psVector.h	(revision 5113)
+++ trunk/psLib/src/mathtypes/psVector.h	(revision 5114)
@@ -11,6 +11,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.47 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-09-22 02:32:00 $
+ *  @version $Revision: 1.48 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-09-24 00:17:44 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -34,5 +34,5 @@
 typedef struct
 {
-    psMathType type;                       ///< Type of data.
+    psMathType type;                   ///< Type of data.
     long n;                            ///< Number of elements in use.
     const long nalloc;                 ///< Total number of elements available.
Index: trunk/psLib/src/types/psArray.c
===================================================================
--- trunk/psLib/src/types/psArray.c	(revision 5113)
+++ trunk/psLib/src/types/psArray.c	(revision 5114)
@@ -9,6 +9,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.37 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-08-30 01:14:13 $
+ *  @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-09-24 00:17:44 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -178,12 +178,30 @@
     }
 
-    if (position >= array->nalloc)
-    {
-        psError(PS_ERR_BAD_PARAMETER_NULL, true,
-                PS_ERRORTEXT_psArray_POSITION_BEYOND_NALLOC,
-                position, array->nalloc);
-        return false;
-    }
-
+    if (position > array->n)
+    {
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                "Specified position, %ld, is greater than n+1 of the array, %ld.",
+                position, array->n);
+        return false;
+    }
+
+    if (position < 0)
+        position += array->n;
+    if (position < 0)
+    {
+        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position.  Negative number too large\n");
+        return false;
+    }
+
+    if (position == array->n)
+    {
+        if (position >= array->nalloc) {
+            psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                    PS_ERRORTEXT_psArray_POSITION_BEYOND_NALLOC,
+                    position, array->nalloc);
+            return false;
+        }
+        array->n++;
+    }
     psFree(array->data[position]);
     array->data[position] = data;
@@ -202,11 +220,16 @@
     }
 
-    if (position >= array->nalloc) {
-        psError(PS_ERR_BAD_PARAMETER_NULL, true,
-                PS_ERRORTEXT_psArray_POSITION_BEYOND_NALLOC,
-                position, array->nalloc);
-        return NULL;
-    }
-
+    if (position >= array->n) {
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                "Specified position, %ld, is greater than n+1 of the array, %ld.",
+                position, array->n);
+        return NULL;
+    }
+    if (position < 0)
+        position += array->n;
+    if (position < 0) {
+        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position.  Negative number too large\n");
+        return NULL;
+    }
     return array->data[position];
 }
Index: trunk/psLib/src/types/psArray.h
===================================================================
--- trunk/psLib/src/types/psArray.h	(revision 5113)
+++ trunk/psLib/src/types/psArray.h	(revision 5114)
@@ -12,6 +12,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-08-30 01:14:13 $
+ *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-09-24 00:17:44 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
Index: trunk/psLib/src/types/psPixels.c
===================================================================
--- trunk/psLib/src/types/psPixels.c	(revision 5113)
+++ trunk/psLib/src/types/psPixels.c	(revision 5114)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-09-23 00:04:36 $
+ *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-09-24 00:17:44 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -337,13 +337,25 @@
                  psPixelCoord value)
 {
-    if (pixels == NULL)
+    if (pixels == NULL) {
+        psError(PS_ERR_BAD_PARAMETER_NULL, true, PS_ERRORTEXT_psPixels_NULL);
         return false;
-    if (position > pixels->n)
+    }
+    if (position > pixels->n) {
+        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position.  Number too large\n");
         return false;
+    }
     if(position < 0)
         position += pixels->n;
+    if(position < 0) {
+        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position.  Negative number too large\n");
+        return false;
+    }
     if (position == pixels->n) {
-        if (position >= pixels->nalloc)
+        if (position >= pixels->nalloc) {
+            psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                    "Specified position, %ld, is greater than n+1 of the pixels, %ld.",
+                    position, pixels->nalloc);
             return false;
+        }
         pixels->n++;
     }
@@ -359,4 +371,5 @@
     psPixelCoord out;
     if (pixels == NULL) {
+        psError(PS_ERR_BAD_PARAMETER_NULL, true, PS_ERRORTEXT_psPixels_NULL);
         out.x = 0; //XXX: should be NAN when changed to float
         out.y = 0; //XXX: should be NAN when changed to float
@@ -364,4 +377,5 @@
     }
     if (position >= pixels->n) {
+        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position.  Number too large\n");
         out.x = 0; //XXX: should be NAN when changed to float
         out.y = 0; //XXX: should be NAN when changed to float
@@ -370,4 +384,10 @@
     if (position < 0)
         position += pixels->n;
+    if (position < 0) {
+        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position.  Negative number too large\n");
+        out.x = 0; //XXX: should be NAN when changed to float
+        out.y = 0; //XXX: should be NAN when changed to float
+        return out;
+    }
     out.x = pixels->data[position].x;
     out.y = pixels->data[position].y;
Index: trunk/psLib/src/types/psPixels.h
===================================================================
--- trunk/psLib/src/types/psPixels.h	(revision 5113)
+++ trunk/psLib/src/types/psPixels.h	(revision 5114)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-09-23 00:04:36 $
+ *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-09-24 00:17:44 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
