Index: /trunk/psLib/src/collections/Makefile
===================================================================
--- /trunk/psLib/src/collections/Makefile	(revision 484)
+++ /trunk/psLib/src/collections/Makefile	(revision 485)
@@ -13,4 +13,5 @@
     psBitMask.o \
     psSort.o \
+    psArray.o
 
 INCLUDES = -I$(includedir)
@@ -18,5 +19,5 @@
 %.o: %.c
 	@echo "    Compiling $<. "
-	$(CC) $(CFLAGS) $(INCLUDE_GLOBAL) $(INCLUDES) -c $< -o $@
+	$(CC) $(CFLAGS) -DPS_ALLOW_MALLOC $(INCLUDE_GLOBAL) $(INCLUDES) -c $< -o $@
 
 libpsCollections.a: $(SRC_OBJS)
Index: /trunk/psLib/src/collections/psArray.c
===================================================================
--- /trunk/psLib/src/collections/psArray.c	(revision 484)
+++ /trunk/psLib/src/collections/psArray.c	(revision 485)
@@ -1,30 +1,139 @@
-/* remove this file when there is a valid psArray.h */
+/** @file  psArray.c
+ *
+ *  @brief Contains support for array types
+ *
+ *  The type of basic one dimensional arrays are defined here include: int, float, double, complex float, and
+ *  void *.
+ *
+ *  @author Ross Harman, MHPCC
+ *   
+ *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-04-21 00:18:05 $
+ *
+ *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
+ */
 
+/******************************************************************************/
+/*  INCLUDE FILES                                                             */
+/******************************************************************************/
+#include "psMemory.h"
 #include "psArray.h"
+#include "psLogMsg.h"
 
-#include <stdlib.h>
+/******************************************************************************/
+/*  DEFINE STATEMENTS                                                         */
+/******************************************************************************/
 
-psFloatArray *psFloatArrayAlloc(int nalloc)
+// None
+
+/******************************************************************************/
+/*  TYPE DEFINITIONS                                                          */
+/******************************************************************************/
+
+// None
+
+/*****************************************************************************/
+/*  GLOBAL VARIABLES                                                         */
+/*****************************************************************************/
+
+// None
+
+/*****************************************************************************/
+/*  FILE STATIC VARIABLES                                                    */
+/*****************************************************************************/
+
+// None
+
+/*****************************************************************************/
+/*  FUNCTION IMPLEMENTATION - LOCAL                                          */
+/*****************************************************************************/
+
+// None
+
+/*****************************************************************************/
+/* FUNCTION IMPLEMENTATION - PUBLIC                                          */
+/*****************************************************************************/
+
+psFloatArray* psFloatArrayAlloc(int nalloc)
 {
-    psFloatArray *psArray = (psFloatArray*)malloc(sizeof(psFloatArray));
-    psArray->n = nalloc;
-    psArray->arr = (float*)malloc(sizeof(float)*nalloc);
-    
-    return psArray;
+    psFloatArray *psArr = (psFloatArray*)p_psAlloc(sizeof(psFloatArray), __FILE__, __LINE__);
+    psArr->type.dimen = PS_DIMEN_VECTOR;
+    psArr->type.type = PS_TYPE_FLOAT;
+    psArr->nalloc = nalloc;
+    psArr->n = 0;
+
+    if(nalloc == 0) {
+        psArr->arr = NULL;
+    } else {
+        psArr->arr = p_psAlloc(nalloc*sizeof(float), __FILE__, __LINE__);
+    }
+
+    return psArr;
 }
 
-int psFreeFloatArray(psFloatArray *inArray)
+psFloatArray *psFloatArrayRealloc(psFloatArray *psArr, int nalloc)
 {
-    free(inArray->arr);
-    free(inArray);
-    return 0;
+    if(psArr == NULL) {
+        return psFloatArrayAlloc(nalloc);
+    }
+    if(nalloc <= psArr->nalloc) {
+        if (psArr->n < nalloc) {
+            psArr->n = nalloc;
+        }
+    } else {
+        psArr->arr = p_psRealloc(psArr->arr, nalloc*sizeof(float), __FILE__, __LINE__);
+        psArr->nalloc = nalloc;
+    }
+    return psArr;
 }
 
-psIntArray *psIntArrayAlloc(int nalloc)
+void psFloatArrayFree(psFloatArray *restrict psArr)
 {
-    psIntArray *psArray = (psIntArray*)malloc(sizeof(psIntArray));
-    psArray->n = nalloc;
-    psArray->arr = (int*)malloc(sizeof(int)*nalloc);
-    
-    return psArray;
+    if (psArr == NULL) {
+        return;
+    }
+    p_psFree(psArr->arr, __FILE__, __LINE__);
+    p_psFree(psArr, __FILE__, __LINE__);
 }
+
+psIntArray* psIntArrayAlloc(int nalloc)
+{
+    psIntArray *psArr = (psIntArray*)p_psAlloc(sizeof(psIntArray), __FILE__, __LINE__);
+    psArr->type.dimen = PS_DIMEN_VECTOR;
+    psArr->type.type = PS_TYPE_INT;
+    psArr->nalloc = nalloc;
+    psArr->n = 0;
+
+    if(nalloc == 0) {
+        psArr->arr = NULL;
+    } else {
+        psArr->arr = p_psAlloc(nalloc*sizeof(int), __FILE__, __LINE__);
+    }
+
+    return psArr;
+}
+
+psIntArray *psIntArrayRealloc(psIntArray *psArr, int nalloc)
+{
+    if(psArr == NULL) {
+        return psIntArrayAlloc(nalloc);
+    }
+    if(nalloc <= psArr->nalloc) {
+        if (psArr->n < nalloc) {
+            psArr->n = nalloc;
+        }
+    } else {
+        psArr->arr = p_psRealloc(psArr->arr, nalloc*sizeof(int), __FILE__, __LINE__);
+        psArr->nalloc = nalloc;
+    }
+    return psArr;
+}
+
+void psIntArrayFree(psIntArray *restrict psArr)
+{
+    if (psArr == NULL) {
+        return;
+    }
+    p_psFree(psArr->arr, __FILE__, __LINE__);
+    p_psFree(psArr, __FILE__, __LINE__);
+}
Index: /trunk/psLib/src/collections/psArray.h
===================================================================
--- /trunk/psLib/src/collections/psArray.h	(revision 484)
+++ /trunk/psLib/src/collections/psArray.h	(revision 485)
@@ -1,15 +1,235 @@
-/* remove this file when there is a valid psArray.h */
-
-typedef struct {
-    int n;
-    float *arr;
-} psFloatArray;
-
-typedef struct {
-    int n;
-    int *arr;
-} psIntArray;
-
-psFloatArray *psFloatArrayAlloc(int nalloc);
-int psFreeFloatArray(psFloatArray *inArray);
-psIntArray *psIntArrayAlloc(int nalloc);
+/** @file  psArray.h
+ *
+ *  @brief Contains support for basic array types
+ *
+ *  The types of basic one dimensional arrays defined include: int, float, double, complex float, and
+ *  void *.
+ *
+ *  @author Ross Harman, MHPCC
+ *   
+ *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-04-21 00:18:05 $
+ *
+ *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
+ */
+
+#ifndef PS_ARRAY_H
+#define PS_ARRAY_H
+
+#include <complex.h>
+
+/******************************************************************************/
+/*  DEFINE STATEMENTS                                                         */
+/******************************************************************************/
+
+// None
+
+/******************************************************************************/
+/*  TYPE DEFINITIONS                                                          */
+/******************************************************************************/
+
+/** Types of the elements of vectors, images, etc.
+ *
+ * The basic types of the primitives used by psLib are defined within this enum. This enum is used by the psType struct.
+ *
+ */
+typedef enum {
+    PS_TYPE_CHAR,   ///< Character.
+    PS_TYPE_SHORT,   ///< Short integer.
+    PS_TYPE_INT,   ///< Integer.
+    PS_TYPE_LONG,   ///< Long integer.
+    PS_TYPE_UCHAR,   ///< Unsigned character.
+    PS_TYPE_USHORT,   ///< Unsigned short integer.
+    PS_TYPE_UINT,   ///< Unsigned integer.
+    PS_TYPE_ULONG,   ///< Unsigned long integer.
+    PS_TYPE_FLOAT,   ///< Floating point.
+    PS_TYPE_DOUBLE,   ///< Double-precision floating point.
+    PS_TYPE_COMPLEX,  ///< Complex numbers consisting of floating point.
+    PS_TYPE_OTHER,   ///< Something else that's not supported for arithmetic.
+} psElemType;
+
+/** Dimensions of a data type.
+ *
+ * The dimensions of containers used by psLib are defined within this enum. This enum is used by the psType struct.
+ *
+ */
+typedef enum {
+    PS_DIMEN_SCALAR,  ///< Scalar.
+    PS_DIMEN_VECTOR,  ///< Vector.
+    PS_DIMEN_TRANSV,  ///< Transposed vector.
+    PS_DIMEN_IMAGE,   ///< Image.
+    PS_DIMEN_OTHER   ///< Something else that's not supported for arithmetic.
+} psDimen;
+
+/** The type of a data type.
+ *
+ * All psLib complex types consist of primitive components. This struct provides the description of those 
+ * primitives.
+ *
+ */
+typedef struct
+{
+    psElemType type;  ///< Primitive type.
+    psDimen dimen;   ///< Dimensionality.
+}
+psType;
+
+/** An array of integers.
+ *
+ * Struct for maintaining an array of integer numbers.
+ *
+ */
+typedef struct
+{
+    psType type;    ///< Type of data. THIS STRUCT ELEMENT MUST BE FIRST IN THE STRUCT!
+    int nalloc;  ///< Total number of elements available.
+    int n;   ///< Number of elements in use.
+    int *arr;  ///< Array data.
+}
+psIntArray;
+
+/** An array of floats.
+ *
+ * Struct for maintaining an array of floating point numbers.
+ *
+ */
+typedef struct
+{
+    psType type; ///< Type of data. THIS STRUCT ELEMENT MUST BE FIRST IN THE STRUCT!
+    int nalloc;  ///< Total number of elements available.
+    int n;   ///< Number of elements in use.
+    float *arr;  ///< Array data.
+}
+psFloatArray;
+
+/*****************************************************************************/
+/* FUNCTION PROTOTYPES                                                       */
+/*****************************************************************************/
+
+/** Allocate an integer array */
+psIntArray *psIntArrayAlloc(
+    int nalloc  ///< Total number of elements to make available
+);
+
+/** Reallocate an integer array */
+psIntArray *psIntArrayRealloc(
+    psIntArray *myArray,    ///< Array to reallocate.
+    int nalloc              ///< Total number of elements to make available.
+);
+
+
+/** Deallocate an integer array */
+void psIntArrayFree(
+    psIntArray *restrict myArray    ///< Array to free
+);
+
+/** Allocate a float array.
+ *
+ * Uses psLib memory allocation functions to create an array of floats as defined by the psFloatArray struct. 
+ *
+ */
+psFloatArray *psFloatArrayAlloc(
+    int nalloc  ///< Total number of elements to make available.
+);
+
+/** Reallocate a float array.
+ *
+ * Uses psLib memory allocation functions to reallocate an array of floats as defined by the psFloatArray 
+ * struct. 
+ *
+ */
+psFloatArray *psFloatArrayRealloc(
+    psFloatArray *myArray,  ///< Array to reallocate.
+    int nalloc              ///< Total number of elements to make available.
+);
+
+/** Deallocate a float array
+ *
+ * Uses psLib memory allocation functions to deallocate an array of floats as defined by the psFloatArray 
+ * struct. 
+ *
+ */
+void psFloatArrayFree(
+    psFloatArray *restrict myArray  ///< Array to free
+);
+
+/** An array of complex numbers.
+ *
+ * Struct for maintaining an array of complex numbers.
+ *
+ */
+typedef struct
+{
+    psType type;  ///< Type of data. THIS STRUCT ELEMENT MUST BE FIRST IN THE STRUCT!
+    int size;   ///< Total number of elements available.
+    int n;    ///< Number of elements in use
+    complex float *arr; ///< Array data.
+}
+psComplexArray;
+
+/** Constructor \ingroup DataGroup */
+psComplexArray *psComplexArrayAlloc(int nalloc) ///< Total number of elements to make available
+;
+
+/** Reallocator \ingroup DataGroup */
+psComplexArray *psComplexArrayRealloc(psComplexArray *myArray, ///< Array to reallocate
+                                      int nalloc) ///< Total number of elements to make available
+;
+
+/** Destructor \ingroup DataGroup */
+void psComplexArrayFree(psComplexArray *restrict myArray) ///< Array to free
+;
+
+
+/************************************************************************************************************/
+
+/** An array of double-precision real numbers */
+typedef struct
+{
+    psType type;  ///< Type of data.  THIS STRUCT ELEMENT MUST BE FIRST IN THE STRUCT!
+    int nalloc;   ///< Total number of elements available
+    int n;    ///< Number of elements in use
+    double *arr;  ///< The array data
+}
+psDoubleArray;
+
+/** Constructor \ingroup DataGroup */
+psDoubleArray *psDoubleArrayAlloc(int nalloc) ///< Total number of elements to make available
+;
+
+/** Reallocator \ingroup DataGroup */
+psDoubleArray *psDoubleArrayRealloc(psDoubleArray *myArray, ///< Array to reallocate
+                                    int nalloc) ///< Total number of elements to make available
+;
+
+/** Destructor \ingroup DataGroup */
+void psDoubleArrayFree(psDoubleArray *restrict myArray) ///< Array to free
+;
+
+/** Array of pointers to void.
+ *  psVoidPtrArray is special, as it needs to have a destructor that
+ *  accepts a destructor for the array elements
+ */
+typedef struct
+{
+    int n;    ///< Number of elements in use
+    int nalloc;    ///< Number of total elements
+    void **arr;    ///< The elements
+}
+psVoidPtrArray;
+
+/** Constructor \ingroup DataGroup */
+psVoidPtrArray *psVoidPtrArrayAlloc(int nalloc) ///< Number of elements to use
+;
+
+/** Reallocate \ingroup DataGroup */
+psVoidPtrArray *psVoidPtrArrayRealloc(psVoidPtrArray *arr, ///< Array to reallocate
+                                      int nalloc) ///< Number of elements
+;
+
+/** Destructor \ingroup DataGroup */
+void psVoidPtrArrayFree(psVoidPtrArray *arr, ///< array to destroy
+                        void (*elemFree)(void *)) ///< destructor for array data
+;
+
+#endif
Index: /trunk/psLib/src/collections/psSort.c
===================================================================
--- /trunk/psLib/src/collections/psSort.c	(revision 484)
+++ /trunk/psLib/src/collections/psSort.c	(revision 485)
@@ -14,6 +14,6 @@
  *  @author Ross Harman, MHPCC
  *   
- *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-04-19 20:10:46 $
+ *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-04-21 00:18:05 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -22,5 +22,5 @@
 /******************************************************************************/
 /*  INCLUDE FILES                                                             */
-/******************************************************************************/  
+/******************************************************************************/
 
 #include <stdio.h>
@@ -71,5 +71,5 @@
  *  @return  int: Result of comparsion (-1, 0, or 1).
  */
- 
+
 static int psCompare(
     const void *x,  /**< First float to compare. */
@@ -79,23 +79,21 @@
     float *item1 = NULL;
     float *item2 = NULL;
-    
+
     if(x == NULL || y == NULL) {
         psError(__func__, " : Line %d - Null input argument: x=%d y=%d\n", __LINE__, x, y);
     }
-    
+
     item1 = (float*)x;
     item2 = (float*)y;
-    
+
     if(item1 == NULL || item2 == NULL) {
         psError(__func__, " : Line %d - Improper cast to float: item1=%d item2=%d\n", __LINE__, item1, item2);
     }
-    
+
     if(*item1 < *item2) {
         return -1;
-    }
-    else if(*item1 > *item2) {
+    } else if(*item1 > *item2) {
         return 1;
-    }
-    else {
+    } else {
         return 0;
     }
@@ -122,10 +120,10 @@
         return outArray;
     }
-    
+
     if(inArray == NULL) {
         psError(__func__, " : Line %d - Null input array\n", __LINE__);
         return outArray;
     }
-        
+
     // Initialize values
     inN = inArray->n;
@@ -134,5 +132,5 @@
     outArr = outArray->arr;
     elSize = sizeof(float);
-    
+
     if(inN != outN) {
         psError(__func__, " : Line %d - Input and output array sizes are not equal: in=%d out=%d\n", __LINE__,
@@ -140,13 +138,13 @@
         return outArray;
     }
-    
+
     // Copy input array values into output array
     for(i=0; i<inN; i++) {
         outArr[i] = inArr[i];
     }
-    
+
     // Sort output array
     qsort((void*)outArr, inN, elSize, psCompare);
-    
+
     return outArray;
 }
@@ -166,10 +164,10 @@
     float diff = 0.0f;
     psFloatArray *tmpFloatArray = NULL;
-    
+
     if(outArray == NULL) {
         psError(__func__, " : Line %d - Null output array\n", __LINE__);
         return outArray;
     }
-    
+
     if(inArray == NULL) {
         psError(__func__, " : Line %d - Null input array\n", __LINE__);
@@ -189,7 +187,7 @@
     }
 
-    tmpFloatArray = psFloatArrayAlloc(inN);
+    tmpFloatArray = psFloatArrayAlloc(inN, inN);
     tmpFloatArray = psSort(tmpFloatArray, inArray);
-    
+
     for(i=0; i<inN; i++) {
         tempVal = tmpFloatArray->arr[i];
@@ -200,10 +198,10 @@
                 break;
             }
-        } 
-    }
-    
+        }
+    }
+
     // Free temp memory
-    psFreeFloatArray(tmpFloatArray);
-    
-    return outArray;    
+    psFloatArrayFree(tmpFloatArray);
+
+    return outArray;
 }
Index: /trunk/psLib/src/types/psArray.c
===================================================================
--- /trunk/psLib/src/types/psArray.c	(revision 484)
+++ /trunk/psLib/src/types/psArray.c	(revision 485)
@@ -1,30 +1,139 @@
-/* remove this file when there is a valid psArray.h */
+/** @file  psArray.c
+ *
+ *  @brief Contains support for array types
+ *
+ *  The type of basic one dimensional arrays are defined here include: int, float, double, complex float, and
+ *  void *.
+ *
+ *  @author Ross Harman, MHPCC
+ *   
+ *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-04-21 00:18:05 $
+ *
+ *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
+ */
 
+/******************************************************************************/
+/*  INCLUDE FILES                                                             */
+/******************************************************************************/
+#include "psMemory.h"
 #include "psArray.h"
+#include "psLogMsg.h"
 
-#include <stdlib.h>
+/******************************************************************************/
+/*  DEFINE STATEMENTS                                                         */
+/******************************************************************************/
 
-psFloatArray *psFloatArrayAlloc(int nalloc)
+// None
+
+/******************************************************************************/
+/*  TYPE DEFINITIONS                                                          */
+/******************************************************************************/
+
+// None
+
+/*****************************************************************************/
+/*  GLOBAL VARIABLES                                                         */
+/*****************************************************************************/
+
+// None
+
+/*****************************************************************************/
+/*  FILE STATIC VARIABLES                                                    */
+/*****************************************************************************/
+
+// None
+
+/*****************************************************************************/
+/*  FUNCTION IMPLEMENTATION - LOCAL                                          */
+/*****************************************************************************/
+
+// None
+
+/*****************************************************************************/
+/* FUNCTION IMPLEMENTATION - PUBLIC                                          */
+/*****************************************************************************/
+
+psFloatArray* psFloatArrayAlloc(int nalloc)
 {
-    psFloatArray *psArray = (psFloatArray*)malloc(sizeof(psFloatArray));
-    psArray->n = nalloc;
-    psArray->arr = (float*)malloc(sizeof(float)*nalloc);
-    
-    return psArray;
+    psFloatArray *psArr = (psFloatArray*)p_psAlloc(sizeof(psFloatArray), __FILE__, __LINE__);
+    psArr->type.dimen = PS_DIMEN_VECTOR;
+    psArr->type.type = PS_TYPE_FLOAT;
+    psArr->nalloc = nalloc;
+    psArr->n = 0;
+
+    if(nalloc == 0) {
+        psArr->arr = NULL;
+    } else {
+        psArr->arr = p_psAlloc(nalloc*sizeof(float), __FILE__, __LINE__);
+    }
+
+    return psArr;
 }
 
-int psFreeFloatArray(psFloatArray *inArray)
+psFloatArray *psFloatArrayRealloc(psFloatArray *psArr, int nalloc)
 {
-    free(inArray->arr);
-    free(inArray);
-    return 0;
+    if(psArr == NULL) {
+        return psFloatArrayAlloc(nalloc);
+    }
+    if(nalloc <= psArr->nalloc) {
+        if (psArr->n < nalloc) {
+            psArr->n = nalloc;
+        }
+    } else {
+        psArr->arr = p_psRealloc(psArr->arr, nalloc*sizeof(float), __FILE__, __LINE__);
+        psArr->nalloc = nalloc;
+    }
+    return psArr;
 }
 
-psIntArray *psIntArrayAlloc(int nalloc)
+void psFloatArrayFree(psFloatArray *restrict psArr)
 {
-    psIntArray *psArray = (psIntArray*)malloc(sizeof(psIntArray));
-    psArray->n = nalloc;
-    psArray->arr = (int*)malloc(sizeof(int)*nalloc);
-    
-    return psArray;
+    if (psArr == NULL) {
+        return;
+    }
+    p_psFree(psArr->arr, __FILE__, __LINE__);
+    p_psFree(psArr, __FILE__, __LINE__);
 }
+
+psIntArray* psIntArrayAlloc(int nalloc)
+{
+    psIntArray *psArr = (psIntArray*)p_psAlloc(sizeof(psIntArray), __FILE__, __LINE__);
+    psArr->type.dimen = PS_DIMEN_VECTOR;
+    psArr->type.type = PS_TYPE_INT;
+    psArr->nalloc = nalloc;
+    psArr->n = 0;
+
+    if(nalloc == 0) {
+        psArr->arr = NULL;
+    } else {
+        psArr->arr = p_psAlloc(nalloc*sizeof(int), __FILE__, __LINE__);
+    }
+
+    return psArr;
+}
+
+psIntArray *psIntArrayRealloc(psIntArray *psArr, int nalloc)
+{
+    if(psArr == NULL) {
+        return psIntArrayAlloc(nalloc);
+    }
+    if(nalloc <= psArr->nalloc) {
+        if (psArr->n < nalloc) {
+            psArr->n = nalloc;
+        }
+    } else {
+        psArr->arr = p_psRealloc(psArr->arr, nalloc*sizeof(int), __FILE__, __LINE__);
+        psArr->nalloc = nalloc;
+    }
+    return psArr;
+}
+
+void psIntArrayFree(psIntArray *restrict psArr)
+{
+    if (psArr == NULL) {
+        return;
+    }
+    p_psFree(psArr->arr, __FILE__, __LINE__);
+    p_psFree(psArr, __FILE__, __LINE__);
+}
Index: /trunk/psLib/src/types/psArray.h
===================================================================
--- /trunk/psLib/src/types/psArray.h	(revision 484)
+++ /trunk/psLib/src/types/psArray.h	(revision 485)
@@ -1,15 +1,235 @@
-/* remove this file when there is a valid psArray.h */
-
-typedef struct {
-    int n;
-    float *arr;
-} psFloatArray;
-
-typedef struct {
-    int n;
-    int *arr;
-} psIntArray;
-
-psFloatArray *psFloatArrayAlloc(int nalloc);
-int psFreeFloatArray(psFloatArray *inArray);
-psIntArray *psIntArrayAlloc(int nalloc);
+/** @file  psArray.h
+ *
+ *  @brief Contains support for basic array types
+ *
+ *  The types of basic one dimensional arrays defined include: int, float, double, complex float, and
+ *  void *.
+ *
+ *  @author Ross Harman, MHPCC
+ *   
+ *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-04-21 00:18:05 $
+ *
+ *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
+ */
+
+#ifndef PS_ARRAY_H
+#define PS_ARRAY_H
+
+#include <complex.h>
+
+/******************************************************************************/
+/*  DEFINE STATEMENTS                                                         */
+/******************************************************************************/
+
+// None
+
+/******************************************************************************/
+/*  TYPE DEFINITIONS                                                          */
+/******************************************************************************/
+
+/** Types of the elements of vectors, images, etc.
+ *
+ * The basic types of the primitives used by psLib are defined within this enum. This enum is used by the psType struct.
+ *
+ */
+typedef enum {
+    PS_TYPE_CHAR,   ///< Character.
+    PS_TYPE_SHORT,   ///< Short integer.
+    PS_TYPE_INT,   ///< Integer.
+    PS_TYPE_LONG,   ///< Long integer.
+    PS_TYPE_UCHAR,   ///< Unsigned character.
+    PS_TYPE_USHORT,   ///< Unsigned short integer.
+    PS_TYPE_UINT,   ///< Unsigned integer.
+    PS_TYPE_ULONG,   ///< Unsigned long integer.
+    PS_TYPE_FLOAT,   ///< Floating point.
+    PS_TYPE_DOUBLE,   ///< Double-precision floating point.
+    PS_TYPE_COMPLEX,  ///< Complex numbers consisting of floating point.
+    PS_TYPE_OTHER,   ///< Something else that's not supported for arithmetic.
+} psElemType;
+
+/** Dimensions of a data type.
+ *
+ * The dimensions of containers used by psLib are defined within this enum. This enum is used by the psType struct.
+ *
+ */
+typedef enum {
+    PS_DIMEN_SCALAR,  ///< Scalar.
+    PS_DIMEN_VECTOR,  ///< Vector.
+    PS_DIMEN_TRANSV,  ///< Transposed vector.
+    PS_DIMEN_IMAGE,   ///< Image.
+    PS_DIMEN_OTHER   ///< Something else that's not supported for arithmetic.
+} psDimen;
+
+/** The type of a data type.
+ *
+ * All psLib complex types consist of primitive components. This struct provides the description of those 
+ * primitives.
+ *
+ */
+typedef struct
+{
+    psElemType type;  ///< Primitive type.
+    psDimen dimen;   ///< Dimensionality.
+}
+psType;
+
+/** An array of integers.
+ *
+ * Struct for maintaining an array of integer numbers.
+ *
+ */
+typedef struct
+{
+    psType type;    ///< Type of data. THIS STRUCT ELEMENT MUST BE FIRST IN THE STRUCT!
+    int nalloc;  ///< Total number of elements available.
+    int n;   ///< Number of elements in use.
+    int *arr;  ///< Array data.
+}
+psIntArray;
+
+/** An array of floats.
+ *
+ * Struct for maintaining an array of floating point numbers.
+ *
+ */
+typedef struct
+{
+    psType type; ///< Type of data. THIS STRUCT ELEMENT MUST BE FIRST IN THE STRUCT!
+    int nalloc;  ///< Total number of elements available.
+    int n;   ///< Number of elements in use.
+    float *arr;  ///< Array data.
+}
+psFloatArray;
+
+/*****************************************************************************/
+/* FUNCTION PROTOTYPES                                                       */
+/*****************************************************************************/
+
+/** Allocate an integer array */
+psIntArray *psIntArrayAlloc(
+    int nalloc  ///< Total number of elements to make available
+);
+
+/** Reallocate an integer array */
+psIntArray *psIntArrayRealloc(
+    psIntArray *myArray,    ///< Array to reallocate.
+    int nalloc              ///< Total number of elements to make available.
+);
+
+
+/** Deallocate an integer array */
+void psIntArrayFree(
+    psIntArray *restrict myArray    ///< Array to free
+);
+
+/** Allocate a float array.
+ *
+ * Uses psLib memory allocation functions to create an array of floats as defined by the psFloatArray struct. 
+ *
+ */
+psFloatArray *psFloatArrayAlloc(
+    int nalloc  ///< Total number of elements to make available.
+);
+
+/** Reallocate a float array.
+ *
+ * Uses psLib memory allocation functions to reallocate an array of floats as defined by the psFloatArray 
+ * struct. 
+ *
+ */
+psFloatArray *psFloatArrayRealloc(
+    psFloatArray *myArray,  ///< Array to reallocate.
+    int nalloc              ///< Total number of elements to make available.
+);
+
+/** Deallocate a float array
+ *
+ * Uses psLib memory allocation functions to deallocate an array of floats as defined by the psFloatArray 
+ * struct. 
+ *
+ */
+void psFloatArrayFree(
+    psFloatArray *restrict myArray  ///< Array to free
+);
+
+/** An array of complex numbers.
+ *
+ * Struct for maintaining an array of complex numbers.
+ *
+ */
+typedef struct
+{
+    psType type;  ///< Type of data. THIS STRUCT ELEMENT MUST BE FIRST IN THE STRUCT!
+    int size;   ///< Total number of elements available.
+    int n;    ///< Number of elements in use
+    complex float *arr; ///< Array data.
+}
+psComplexArray;
+
+/** Constructor \ingroup DataGroup */
+psComplexArray *psComplexArrayAlloc(int nalloc) ///< Total number of elements to make available
+;
+
+/** Reallocator \ingroup DataGroup */
+psComplexArray *psComplexArrayRealloc(psComplexArray *myArray, ///< Array to reallocate
+                                      int nalloc) ///< Total number of elements to make available
+;
+
+/** Destructor \ingroup DataGroup */
+void psComplexArrayFree(psComplexArray *restrict myArray) ///< Array to free
+;
+
+
+/************************************************************************************************************/
+
+/** An array of double-precision real numbers */
+typedef struct
+{
+    psType type;  ///< Type of data.  THIS STRUCT ELEMENT MUST BE FIRST IN THE STRUCT!
+    int nalloc;   ///< Total number of elements available
+    int n;    ///< Number of elements in use
+    double *arr;  ///< The array data
+}
+psDoubleArray;
+
+/** Constructor \ingroup DataGroup */
+psDoubleArray *psDoubleArrayAlloc(int nalloc) ///< Total number of elements to make available
+;
+
+/** Reallocator \ingroup DataGroup */
+psDoubleArray *psDoubleArrayRealloc(psDoubleArray *myArray, ///< Array to reallocate
+                                    int nalloc) ///< Total number of elements to make available
+;
+
+/** Destructor \ingroup DataGroup */
+void psDoubleArrayFree(psDoubleArray *restrict myArray) ///< Array to free
+;
+
+/** Array of pointers to void.
+ *  psVoidPtrArray is special, as it needs to have a destructor that
+ *  accepts a destructor for the array elements
+ */
+typedef struct
+{
+    int n;    ///< Number of elements in use
+    int nalloc;    ///< Number of total elements
+    void **arr;    ///< The elements
+}
+psVoidPtrArray;
+
+/** Constructor \ingroup DataGroup */
+psVoidPtrArray *psVoidPtrArrayAlloc(int nalloc) ///< Number of elements to use
+;
+
+/** Reallocate \ingroup DataGroup */
+psVoidPtrArray *psVoidPtrArrayRealloc(psVoidPtrArray *arr, ///< Array to reallocate
+                                      int nalloc) ///< Number of elements
+;
+
+/** Destructor \ingroup DataGroup */
+void psVoidPtrArrayFree(psVoidPtrArray *arr, ///< array to destroy
+                        void (*elemFree)(void *)) ///< destructor for array data
+;
+
+#endif
