Index: /trunk/psLib/src/image/psImage.c
===================================================================
--- /trunk/psLib/src/image/psImage.c	(revision 663)
+++ /trunk/psLib/src/image/psImage.c	(revision 664)
@@ -7,6 +7,6 @@
  *  @author Ross Harman, MHPCC
  *   
- *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-05-12 19:46:52 $
+ *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-05-13 20:03:35 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -18,5 +18,5 @@
 #include "psMemory.h"
 #include "psError.h"
-#include "psArray.h"
+#include "psVector.h"
 #include "psImage.h"
 
@@ -55,21 +55,23 @@
 /*****************************************************************************/
 
-psImage *psImageAlloc(int nCols, int nRows, psType type)
+psImage *psImageAlloc(unsigned int numCols, unsigned int numRows, psType type)
 {
     int area = 0;
     psElemType imageType = 0;
     psDimen imageDim = 0;
+    int elementSize = PSELEMTYPE_SIZEOF(type.type); // element size in bytes
+    int rowSize = numCols*elementSize;  // row size in bytes.
 
     imageType = type.type;
     imageDim =  type.dimen;
-    area = nCols*nRows;
+    area = numCols*numRows;
 
     if(imageDim != PS_DIMEN_IMAGE) {
-        psError(__func__, " : Line %d - Image dimensionality not PS_DIMEN_IMAGE=3 . Dimensionality: %d\n",
-                __LINE__, imageDim);
+        psError(__func__, " : Image dimensionality not PS_DIMEN_IMAGE (3). Dimensionality: %d\n",
+                imageDim);
         return NULL;
     } else if(area <= 0) {
-        psError(__func__, " : Line %d - Invalid value for number of rows or columns. nRows: %d nCols: %d \n",
-                __LINE__, nRows, nCols);
+        psError(__func__, " : Invalid value for number of rows or columns. numRows: %d numCols: %d\n",
+                numRows, numCols);
         return NULL;
     }
@@ -77,67 +79,14 @@
     psImage *image = (psImage *)psAlloc(sizeof(psImage));
 
-    switch (type.type) {
-    case PS_TYPE_CHAR:
-        image->rows.rows_c = (char **)psAlloc(ny*sizeof(char *));
-        image->rows.rows_c[0] = (char *)psAlloc(area*sizeof(char));
-        for(int i = 1; i < ny; i++) {
-            image->rows.rows_c[i] = &image->rows.rows_c[0][i*nx];
-        }
-        break;
-    case PS_TYPE_SHORT:
-        image->rows.rows_s = (short **)psAlloc(ny*sizeof(short *));
-        image->rows.rows_s[0] = (short *)psAlloc(area*sizeof(short));
-        for(int i = 1; i < ny; i++) {
-            image->rows.rows_s[i] = &image->rows.rows_s[0][i*nx];
-        }
-        break;
-    case PS_TYPE_INT:
-        image->rows.rows_i = (int **)psAlloc(ny*sizeof(int *));
-        image->rows.rows_i[0] = (int *)psAlloc(area*sizeof(int));
-        for(int i = 1; i < ny; i++) {
-            image->rows.rows_i[i] = &image->rows.rows_i[0][i*nx];
-        }
-        break;
-    case PS_TYPE_LONG:
-        image->rows.rows_l = (long **)psAlloc(ny*sizeof(long *));
-        image->rows.rows_l[0] = (long *)psAlloc(area*sizeof(long));
-        for(int i = 1; i < ny; i++) {
-            image->rows.rows_l[i] = &image->rows.rows_l[0][i*nx];
-        }
-        break;
-    case PS_TYPE_UCHAR:
-        image->rows.rows_uc = (unsigned char **)psAlloc(ny*sizeof(unsigned char *));
-        image->rows.rows_uc[0] = (unsigned char *)psAlloc(area*sizeof(unsigned char));
-        for(int i = 1; i < ny; i++) {
-            image->rows.rows_uc[i] = &image->rows.rows_uc[0][i*nx];
-        }
-        break;
-    case PS_TYPE_USHORT:
-        image->rows.rows_us = (unsigned short **)psAlloc(ny*sizeof(unsigned short *));
-        image->rows.rows_us[0] = (unsigned short *)psAlloc(area*sizeof(unsigned short));
-        for(int i = 1; i < ny; i++) {
-            image->rows.rows_us[i] = &image->rows.rows_us[0][i*nx];
-        }
-        break;
-    case PS_TYPE_UINT:
-        image->rows.rows_ui = (unsigned int **)psAlloc(ny*sizeof(unsigned int *));
-        image->rows.rows_ui[0] = (unsigned int *)psAlloc(area*sizeof(unsigned int));
-        for(int i = 1; i < ny; i++) {
-            image->rows.rows_ui[i] = &image->rows.rows_ui[0][i*nx];
-        }
-        break;
-    case PS_TYPE_ULONG:
-        image->rows.rows_ul = (unsigned long **)psAlloc(ny*sizeof(unsigned long *));
-        image->rows.rows_ul[0] = (unsigned long *)psAlloc(area*sizeof(unsigned long));
-        for(int i = 1; i < ny; i++) {
-            image->rows.rows_ul[i] = &image->rows.rows_ul[0][i*nx];
-        }
-        break;
+    image->data.v[0] = psAlloc(area*elementSize);
+
+    for(int i = 1; i < numRows; i++) {
+        image->data.v[i] = (void*)((int8_t*)image->data.v[i-1]+rowSize);
     }
 
-    image->cols0 = 0;
-    image->rows0 = 0;
-    image->nCols = nCols;
-    image->nRows = nRows;
+    image->col0 = 0;
+    image->row0 = 0;
+    image->numCols = numCols;
+    image->numRows = numRows;
     image->type = type;
     image->parent = NULL;
@@ -160,38 +109,6 @@
         children = image->children;
 
-        switch(imageType) {
-        case PS_TYPE_SHORT:
-            psFree(image->rows.rows_s);
-            break;
-        case PS_TYPE_INT:
-            psFree(image->rows.rows_i);
-            break;
-        case PS_TYPE_LONG:
-            psFree(image->rows.rows_l);
-            break;
-        case PS_TYPE_USHORT:
-            psFree(image->rows.rows_us);
-            break;
-        case PS_TYPE_UINT:
-            psFree(image->rows.rows_ui);
-            break;
-        case PS_TYPE_ULONG:
-            psFree(image->rows.rows_ul);
-            break;
-        case PS_TYPE_FLOAT:
-            psFree(image->rows.rows_f);
-            break;
-        case PS_TYPE_DOUBLE:
-            psFree(image->rows.rows_d);
-            break;
-        case PS_TYPE_COMPLEX:
-            psFree(image->rows.rows_cf);
-            break;
-        case PS_TYPE_OTHER:
-            psError(__func__, " : Line %d - Can't delete images of type PS_TYPE_OTHER\n", __LINE__);
-            break;
-        default:
-            psError(__func__, " : Line %d - Invalid psImage type: %d\n", __LINE__, imageType);
-        }
+        psFree(image->data.v[0]);
+        psFree(image->data.v);
 
         for(i=0; i<nChildren; i++) {
Index: /trunk/psLib/src/image/psImage.h
===================================================================
--- /trunk/psLib/src/image/psImage.h	(revision 663)
+++ /trunk/psLib/src/image/psImage.h	(revision 664)
@@ -7,6 +7,6 @@
  *  @author Ross Harman, MHPCC
  *   
- *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-05-12 19:46:52 $
+ *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-05-13 20:03:35 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -35,26 +35,21 @@
 typedef struct psImage
 {
-    psType type;                    ///< Image data type and dimension.
-    int nCols;                      ///< Number of rows in image
-    int nRows;                      ///< Number of columns in image.
-    int col0;                       ///< Row position relative to parent.
-    int row0;                       ///< Column position relative to parent.
+    psType type;                        ///< Image data type and dimension.
+    unsigned int numCols;               ///< Number of rows in image
+    unsigned int numRows;               ///< Number of columns in image.
+    int col0;                           ///< Row position relative to parent.
+    int row0;                           ///< Column position relative to parent.
 
     union {
-        char **rowsC                ///< Pointers to char integer data.
-        short **rowsS;              ///< Pointers to short integer data.
-        int **rowsI;                ///< Pointers to integer data.
-        long **rowsL ;              ///< Pointers to long integer data.
-        unsigned char **rowsUC;    ///< Pointers to unsigned char integer data.
-        unsigned short **rowsUS;    ///< Pointers to unsigned short integer data.
-        unsigned int **rowsUI;      ///< Pointers to unsigned integer data.
-        unsigned long **rowsUL;     ///< Pointers to unsigned long integer data.
-        float **rowsF;              ///< Pointers to floating point data.
-        double **rowsD;             ///< Pointers to double precision data.
-        complex float **rowsCF;     ///< Pointers to complex floating point data.
-    } rows;                         ///< Union for data types.
-    struct psImage *parent;         ///< Parent, if a subimage.
-    int nChildren;                  ///< Number of subimages.
-    struct psImage *children;       ///< Children of this region.
+        void    **v;                    ///< void pointer to data
+        uint8_t **ui8;                  ///< Pointers to char integer data.
+        int16_t **i16;                  ///< Pointers to short integer data.
+        int32_t **i32;                  ///< Pointers to integer data.
+        float **f32;                    ///< Pointers to floating point data.
+        complex float **c32;            ///< Pointers to complex floating point data.
+    } data;                             ///< Union for data types.
+    struct psImage *parent;             ///< Parent, if a subimage.
+    int nChildren;                      ///< Number of subimages.
+    struct psImage *children;           ///< Children of this region.
 }
 psImage;
@@ -67,5 +62,5 @@
 /** Create an image of the specified size and type.
  *
- * Uses psLib memory allocation functions to create an image struct of the specified size and type. 
+ * Uses psLib memory allocation functions to create an image struct of the specified size and type.
  *
  * @return psImage*: Pointer to psImage.
@@ -73,12 +68,12 @@
  */
 psImage *psImageAlloc(
-    int nCols,  ///< Number of rows in image.
-    int nRows,  ///< Number of columns in image.
-    psType type ///< Type of data for image.
+    unsigned int numCols,               ///< Number of rows in image.
+    unsigned int numRows,               ///< Number of columns in image.
+    psType type                         ///< Type of data for image.
 );
 
 /** Create a subimage of the specified area.
  *
- * Uses psLib memory allocation functions to create an image based on a larger one. 
+ * Uses psLib memory allocation functions to create an image based on a larger one.
  *
  * @return psImage*: Pointer to psImage.
@@ -86,15 +81,15 @@
  */
 psImage *psImageSubset(
-    psImage *out,           ///< Subimage to return, or NULL.
-    const psImage *image,   ///< Parent image.
-    int nCols,              ///< Subimage width (<= image.nCols - col0).
-    int nRows,              ///< Subimage height (<= image.nRows - row0).
-    int col0,               ///< Subimage col-offset (0 <= col0 < nCol).
-    int row0                ///< Subimage row-offset (0 <= row0 < nCol).
+    psImage *out,                       ///< Subimage to return, or NULL.
+    const psImage *image,               ///< Parent image.
+    unsigned int numCols,               ///< Subimage width (<= image.nCols - col0).
+    unsigned int numRows,               ///< Subimage height (<= image.nRows - row0).
+    int col0,                           ///< Subimage col-offset (0 <= col0 < nCol).
+    int row0                            ///< Subimage row-offset (0 <= row0 < nCol).
 );
 
 /** Destroy the specified image.
  *
- *  Uses psLib memory deallocation functions to free an image and any existing children. 
+ *  Uses psLib memory deallocation functions to free an image and any existing children.
  *
  * @return psImage*: Pointer to psImage.
@@ -102,5 +97,5 @@
  */
 void psImageFree(
-    psImage *restrict image ///< Free psImage
+    psImage *restrict image             ///< Free psImage
 );
 
Index: /trunk/psLib/src/mathtypes/psImage.c
===================================================================
--- /trunk/psLib/src/mathtypes/psImage.c	(revision 663)
+++ /trunk/psLib/src/mathtypes/psImage.c	(revision 664)
@@ -7,6 +7,6 @@
  *  @author Ross Harman, MHPCC
  *   
- *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-05-12 19:46:52 $
+ *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-05-13 20:03:35 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -18,5 +18,5 @@
 #include "psMemory.h"
 #include "psError.h"
-#include "psArray.h"
+#include "psVector.h"
 #include "psImage.h"
 
@@ -55,21 +55,23 @@
 /*****************************************************************************/
 
-psImage *psImageAlloc(int nCols, int nRows, psType type)
+psImage *psImageAlloc(unsigned int numCols, unsigned int numRows, psType type)
 {
     int area = 0;
     psElemType imageType = 0;
     psDimen imageDim = 0;
+    int elementSize = PSELEMTYPE_SIZEOF(type.type); // element size in bytes
+    int rowSize = numCols*elementSize;  // row size in bytes.
 
     imageType = type.type;
     imageDim =  type.dimen;
-    area = nCols*nRows;
+    area = numCols*numRows;
 
     if(imageDim != PS_DIMEN_IMAGE) {
-        psError(__func__, " : Line %d - Image dimensionality not PS_DIMEN_IMAGE=3 . Dimensionality: %d\n",
-                __LINE__, imageDim);
+        psError(__func__, " : Image dimensionality not PS_DIMEN_IMAGE (3). Dimensionality: %d\n",
+                imageDim);
         return NULL;
     } else if(area <= 0) {
-        psError(__func__, " : Line %d - Invalid value for number of rows or columns. nRows: %d nCols: %d \n",
-                __LINE__, nRows, nCols);
+        psError(__func__, " : Invalid value for number of rows or columns. numRows: %d numCols: %d\n",
+                numRows, numCols);
         return NULL;
     }
@@ -77,67 +79,14 @@
     psImage *image = (psImage *)psAlloc(sizeof(psImage));
 
-    switch (type.type) {
-    case PS_TYPE_CHAR:
-        image->rows.rows_c = (char **)psAlloc(ny*sizeof(char *));
-        image->rows.rows_c[0] = (char *)psAlloc(area*sizeof(char));
-        for(int i = 1; i < ny; i++) {
-            image->rows.rows_c[i] = &image->rows.rows_c[0][i*nx];
-        }
-        break;
-    case PS_TYPE_SHORT:
-        image->rows.rows_s = (short **)psAlloc(ny*sizeof(short *));
-        image->rows.rows_s[0] = (short *)psAlloc(area*sizeof(short));
-        for(int i = 1; i < ny; i++) {
-            image->rows.rows_s[i] = &image->rows.rows_s[0][i*nx];
-        }
-        break;
-    case PS_TYPE_INT:
-        image->rows.rows_i = (int **)psAlloc(ny*sizeof(int *));
-        image->rows.rows_i[0] = (int *)psAlloc(area*sizeof(int));
-        for(int i = 1; i < ny; i++) {
-            image->rows.rows_i[i] = &image->rows.rows_i[0][i*nx];
-        }
-        break;
-    case PS_TYPE_LONG:
-        image->rows.rows_l = (long **)psAlloc(ny*sizeof(long *));
-        image->rows.rows_l[0] = (long *)psAlloc(area*sizeof(long));
-        for(int i = 1; i < ny; i++) {
-            image->rows.rows_l[i] = &image->rows.rows_l[0][i*nx];
-        }
-        break;
-    case PS_TYPE_UCHAR:
-        image->rows.rows_uc = (unsigned char **)psAlloc(ny*sizeof(unsigned char *));
-        image->rows.rows_uc[0] = (unsigned char *)psAlloc(area*sizeof(unsigned char));
-        for(int i = 1; i < ny; i++) {
-            image->rows.rows_uc[i] = &image->rows.rows_uc[0][i*nx];
-        }
-        break;
-    case PS_TYPE_USHORT:
-        image->rows.rows_us = (unsigned short **)psAlloc(ny*sizeof(unsigned short *));
-        image->rows.rows_us[0] = (unsigned short *)psAlloc(area*sizeof(unsigned short));
-        for(int i = 1; i < ny; i++) {
-            image->rows.rows_us[i] = &image->rows.rows_us[0][i*nx];
-        }
-        break;
-    case PS_TYPE_UINT:
-        image->rows.rows_ui = (unsigned int **)psAlloc(ny*sizeof(unsigned int *));
-        image->rows.rows_ui[0] = (unsigned int *)psAlloc(area*sizeof(unsigned int));
-        for(int i = 1; i < ny; i++) {
-            image->rows.rows_ui[i] = &image->rows.rows_ui[0][i*nx];
-        }
-        break;
-    case PS_TYPE_ULONG:
-        image->rows.rows_ul = (unsigned long **)psAlloc(ny*sizeof(unsigned long *));
-        image->rows.rows_ul[0] = (unsigned long *)psAlloc(area*sizeof(unsigned long));
-        for(int i = 1; i < ny; i++) {
-            image->rows.rows_ul[i] = &image->rows.rows_ul[0][i*nx];
-        }
-        break;
+    image->data.v[0] = psAlloc(area*elementSize);
+
+    for(int i = 1; i < numRows; i++) {
+        image->data.v[i] = (void*)((int8_t*)image->data.v[i-1]+rowSize);
     }
 
-    image->cols0 = 0;
-    image->rows0 = 0;
-    image->nCols = nCols;
-    image->nRows = nRows;
+    image->col0 = 0;
+    image->row0 = 0;
+    image->numCols = numCols;
+    image->numRows = numRows;
     image->type = type;
     image->parent = NULL;
@@ -160,38 +109,6 @@
         children = image->children;
 
-        switch(imageType) {
-        case PS_TYPE_SHORT:
-            psFree(image->rows.rows_s);
-            break;
-        case PS_TYPE_INT:
-            psFree(image->rows.rows_i);
-            break;
-        case PS_TYPE_LONG:
-            psFree(image->rows.rows_l);
-            break;
-        case PS_TYPE_USHORT:
-            psFree(image->rows.rows_us);
-            break;
-        case PS_TYPE_UINT:
-            psFree(image->rows.rows_ui);
-            break;
-        case PS_TYPE_ULONG:
-            psFree(image->rows.rows_ul);
-            break;
-        case PS_TYPE_FLOAT:
-            psFree(image->rows.rows_f);
-            break;
-        case PS_TYPE_DOUBLE:
-            psFree(image->rows.rows_d);
-            break;
-        case PS_TYPE_COMPLEX:
-            psFree(image->rows.rows_cf);
-            break;
-        case PS_TYPE_OTHER:
-            psError(__func__, " : Line %d - Can't delete images of type PS_TYPE_OTHER\n", __LINE__);
-            break;
-        default:
-            psError(__func__, " : Line %d - Invalid psImage type: %d\n", __LINE__, imageType);
-        }
+        psFree(image->data.v[0]);
+        psFree(image->data.v);
 
         for(i=0; i<nChildren; i++) {
Index: /trunk/psLib/src/mathtypes/psImage.h
===================================================================
--- /trunk/psLib/src/mathtypes/psImage.h	(revision 663)
+++ /trunk/psLib/src/mathtypes/psImage.h	(revision 664)
@@ -7,6 +7,6 @@
  *  @author Ross Harman, MHPCC
  *   
- *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-05-12 19:46:52 $
+ *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-05-13 20:03:35 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -35,26 +35,21 @@
 typedef struct psImage
 {
-    psType type;                    ///< Image data type and dimension.
-    int nCols;                      ///< Number of rows in image
-    int nRows;                      ///< Number of columns in image.
-    int col0;                       ///< Row position relative to parent.
-    int row0;                       ///< Column position relative to parent.
+    psType type;                        ///< Image data type and dimension.
+    unsigned int numCols;               ///< Number of rows in image
+    unsigned int numRows;               ///< Number of columns in image.
+    int col0;                           ///< Row position relative to parent.
+    int row0;                           ///< Column position relative to parent.
 
     union {
-        char **rowsC                ///< Pointers to char integer data.
-        short **rowsS;              ///< Pointers to short integer data.
-        int **rowsI;                ///< Pointers to integer data.
-        long **rowsL ;              ///< Pointers to long integer data.
-        unsigned char **rowsUC;    ///< Pointers to unsigned char integer data.
-        unsigned short **rowsUS;    ///< Pointers to unsigned short integer data.
-        unsigned int **rowsUI;      ///< Pointers to unsigned integer data.
-        unsigned long **rowsUL;     ///< Pointers to unsigned long integer data.
-        float **rowsF;              ///< Pointers to floating point data.
-        double **rowsD;             ///< Pointers to double precision data.
-        complex float **rowsCF;     ///< Pointers to complex floating point data.
-    } rows;                         ///< Union for data types.
-    struct psImage *parent;         ///< Parent, if a subimage.
-    int nChildren;                  ///< Number of subimages.
-    struct psImage *children;       ///< Children of this region.
+        void    **v;                    ///< void pointer to data
+        uint8_t **ui8;                  ///< Pointers to char integer data.
+        int16_t **i16;                  ///< Pointers to short integer data.
+        int32_t **i32;                  ///< Pointers to integer data.
+        float **f32;                    ///< Pointers to floating point data.
+        complex float **c32;            ///< Pointers to complex floating point data.
+    } data;                             ///< Union for data types.
+    struct psImage *parent;             ///< Parent, if a subimage.
+    int nChildren;                      ///< Number of subimages.
+    struct psImage *children;           ///< Children of this region.
 }
 psImage;
@@ -67,5 +62,5 @@
 /** Create an image of the specified size and type.
  *
- * Uses psLib memory allocation functions to create an image struct of the specified size and type. 
+ * Uses psLib memory allocation functions to create an image struct of the specified size and type.
  *
  * @return psImage*: Pointer to psImage.
@@ -73,12 +68,12 @@
  */
 psImage *psImageAlloc(
-    int nCols,  ///< Number of rows in image.
-    int nRows,  ///< Number of columns in image.
-    psType type ///< Type of data for image.
+    unsigned int numCols,               ///< Number of rows in image.
+    unsigned int numRows,               ///< Number of columns in image.
+    psType type                         ///< Type of data for image.
 );
 
 /** Create a subimage of the specified area.
  *
- * Uses psLib memory allocation functions to create an image based on a larger one. 
+ * Uses psLib memory allocation functions to create an image based on a larger one.
  *
  * @return psImage*: Pointer to psImage.
@@ -86,15 +81,15 @@
  */
 psImage *psImageSubset(
-    psImage *out,           ///< Subimage to return, or NULL.
-    const psImage *image,   ///< Parent image.
-    int nCols,              ///< Subimage width (<= image.nCols - col0).
-    int nRows,              ///< Subimage height (<= image.nRows - row0).
-    int col0,               ///< Subimage col-offset (0 <= col0 < nCol).
-    int row0                ///< Subimage row-offset (0 <= row0 < nCol).
+    psImage *out,                       ///< Subimage to return, or NULL.
+    const psImage *image,               ///< Parent image.
+    unsigned int numCols,               ///< Subimage width (<= image.nCols - col0).
+    unsigned int numRows,               ///< Subimage height (<= image.nRows - row0).
+    int col0,                           ///< Subimage col-offset (0 <= col0 < nCol).
+    int row0                            ///< Subimage row-offset (0 <= row0 < nCol).
 );
 
 /** Destroy the specified image.
  *
- *  Uses psLib memory deallocation functions to free an image and any existing children. 
+ *  Uses psLib memory deallocation functions to free an image and any existing children.
  *
  * @return psImage*: Pointer to psImage.
@@ -102,5 +97,5 @@
  */
 void psImageFree(
-    psImage *restrict image ///< Free psImage
+    psImage *restrict image             ///< Free psImage
 );
 
