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
Index: /trunk/psLib/test/mathtypes/tst_psVector.c
===================================================================
--- /trunk/psLib/test/mathtypes/tst_psVector.c	(revision 5113)
+++ /trunk/psLib/test/mathtypes/tst_psVector.c	(revision 5114)
@@ -14,6 +14,6 @@
  *  @author  Ross Harman, MHPCC
  *
- *  @version $Revision: 1.4 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2005-09-22 02:32:00 $
+ *  @version $Revision: 1.5 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2005-09-24 00:17:44 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -391,4 +391,5 @@
     psVector *vec = NULL;
     vec = psVectorAlloc(5, PS_TYPE_S32);
+    vec->n = 0;
 
     if ( !psVectorSet(vec, 0, 10) )
@@ -396,6 +397,6 @@
     if ( psVectorSet(vec, 10, 10) )
         fprintf(stderr, "VectorSet Improperly set S32 at out of range position\n");
-    if ( !psVectorSet(vec, -1, 4) )
-        fprintf(stderr, "VectorSet Failed to set S32 at position 4\n");
+    if ( !psVectorSet(vec, 1, 4) )
+        fprintf(stderr, "VectorSet Failed to set S32 at position 1\n");
     if ( (psS32)psVectorGet(vec, 0) != 10 )
         fprintf(stderr, "VectorGet Failed to return the correct S32 from position 0\n");
Index: /trunk/psLib/test/mathtypes/verified/tst_psImage.stderr
===================================================================
--- /trunk/psLib/test/mathtypes/verified/tst_psImage.stderr	(revision 5113)
+++ /trunk/psLib/test/mathtypes/verified/tst_psImage.stderr	(revision 5114)
@@ -138,4 +138,6 @@
 \**********************************************************************************/
 
+<DATE><TIME>|<HOST>|E|psImageSet (FILE:LINENO)
+    Invalid position.  Position too large
 
 ---> TESTPOINT PASSED (psImage{psImageInit} | tst_psImage.c)
Index: /trunk/psLib/test/mathtypes/verified/tst_psVector.stderr
===================================================================
--- /trunk/psLib/test/mathtypes/verified/tst_psVector.stderr	(revision 5113)
+++ /trunk/psLib/test/mathtypes/verified/tst_psVector.stderr	(revision 5114)
@@ -64,4 +64,6 @@
 \**********************************************************************************/
 
+<DATE><TIME>|<HOST>|E|psVectorSet (FILE:LINENO)
+    Invalid position.  Number too large
 
 ---> TESTPOINT PASSED (psVector{psVectorGet/Set} | tst_psVector.c)
Index: /trunk/psLib/test/types/tst_psArray.c
===================================================================
--- /trunk/psLib/test/types/tst_psArray.c	(revision 5113)
+++ /trunk/psLib/test/types/tst_psArray.c	(revision 5114)
@@ -17,6 +17,6 @@
  *  @author  Ross Harman, MHPCC
  *
- *  @version $Revision: 1.2 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2005-08-30 01:14:13 $
+ *  @version $Revision: 1.3 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2005-09-24 00:17:44 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -52,4 +52,5 @@
 static psS32 testArray01( void );
 static psS32 testArrayAdd( void );
+static psS32 testArrayGetSet( void );
 
 
@@ -58,4 +59,5 @@
                               {testArray01, -2, "psArray", 0, false},
                               {testArrayAdd, 788, "psArrayAdd", 0, false},
+                              {testArrayGetSet, -3, "psArrayGetSet", 0, false},
                               {NULL}
                           };
@@ -440,2 +442,34 @@
     return 0;  // the value that indicates success is part of the testDescription
 }
+
+psS32 testArrayGetSet( void )
+{
+    psArray *test;
+    int *p1 = psAlloc(sizeof(int));
+    int *p2 = psAlloc(sizeof(int));
+    int *p3 = psAlloc(sizeof(int));
+    test = psArrayAlloc(5);
+    test->n = 0;
+    *p1 = 10;
+    *p2 = 4;
+    *p3 = 666;
+
+    if ( !psArraySet(test, 0, p1) )
+        fprintf(stderr, "ArraySet failed to set S32 at position 0\n");
+    if ( psArraySet(test, 10, p1) )
+        fprintf(stderr, "ArraySet Improperly set S32 at out of range position\n");
+    if ( !psArraySet(test, 1, p2) )
+        fprintf(stderr, "ArraySet Failed to set S32 at position 1\n");
+    if ( psArrayGet(test, 0) != p1 )
+        fprintf(stderr, "ArrayGet Failed to return the correct S32 from position 0\n");
+    if ( psArrayGet(test, -1) != p2)
+        fprintf(stderr, "ArrayGet Failed to return the correct S32 from tail using -1\n");
+
+    if ( psArraySet(test, -6, p3) )
+        fprintf(stderr, "ArraySet failed to fail using an out of range negative number\n");
+
+    psFree(test);
+    psFree(p3);
+
+    return 0;
+}
Index: /trunk/psLib/test/types/verified/tst_psArray.stderr
===================================================================
--- /trunk/psLib/test/types/verified/tst_psArray.stderr	(revision 5113)
+++ /trunk/psLib/test/types/verified/tst_psArray.stderr	(revision 5114)
@@ -219,2 +219,15 @@
 ---> TESTPOINT PASSED (psArray{psArrayAdd} | tst_psArray.c)
 
+/***************************** TESTPOINT ******************************************\
+*             TestFile: tst_psArray.c                                              *
+*            TestPoint: psArray{psArrayGetSet}                                     *
+*             TestType: Positive                                                   *
+\**********************************************************************************/
+
+<DATE><TIME>|<HOST>|E|psArraySet (FILE:LINENO)
+    Specified position, 10, is greater than n+1 of the array, 1.
+<DATE><TIME>|<HOST>|E|psArraySet (FILE:LINENO)
+    Invalid position.  Negative number too large
+
+---> TESTPOINT PASSED (psArray{psArrayGetSet} | tst_psArray.c)
+
Index: /trunk/psLib/test/types/verified/tst_psPixels.stderr
===================================================================
--- /trunk/psLib/test/types/verified/tst_psPixels.stderr	(revision 5113)
+++ /trunk/psLib/test/types/verified/tst_psPixels.stderr	(revision 5114)
@@ -79,4 +79,6 @@
 \**********************************************************************************/
 
+<DATE><TIME>|<HOST>|E|psPixelsSet (FILE:LINENO)
+    Invalid position.  Number too large
 
 ---> TESTPOINT PASSED (psPixels{psPixelsGet/Set} | tst_psPixels.c)
