Index: /trunk/psLib/src/imageops/psImageStats.c
===================================================================
--- /trunk/psLib/src/imageops/psImageStats.c	(revision 5088)
+++ /trunk/psLib/src/imageops/psImageStats.c	(revision 5089)
@@ -9,6 +9,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.77 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-09-08 00:07:59 $
+ *  @version $Revision: 1.78 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-09-22 02:32:00 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -250,6 +250,6 @@
   Output:
   Internal Data Structures:
-    chebPolys[i][j] 
-    sums[i][j]: This will contain the sum of 
+    chebPolys[i][j]
+    sums[i][j]: This will contain the sum of
                 input->data.F32[x][y] *
                 psPolynomial1DEval(
@@ -258,5 +258,5 @@
                 psPolynomial1DEval(
 chebPolys[j],
-(float) y, 
+(float) y,
 );
         over all pixels (x,y) in the image.
@@ -373,6 +373,6 @@
   Output:
   Internal Data Structures:
-    chebPolys[i][j] 
-    sums[i][j]: This will contain the sum of 
+    chebPolys[i][j]
+    sums[i][j]: This will contain the sum of
                 input->data.F32[x][y] *
                 psPolynomial1DEval(
@@ -381,5 +381,5 @@
                 psPolynomial1DEval(
 chebPolys[j],
-(float) y, 
+(float) y,
 );
         over all pixels (x,y) in the image.
@@ -514,5 +514,5 @@
 
 /*****************************************************************************
-XXX: Use static variables for Chebyshev polynomials and scaling factors. 
+XXX: Use static variables for Chebyshev polynomials and scaling factors.
  *****************************************************************************/
 psImage* p_psImageEvalPolynomialCheb(psImage* input,
@@ -634,2 +634,18 @@
 }
 
+// count number of pixels with given mask value
+long psImageCountPixelMask (psImage *mask,
+                            psMaskType value)
+{
+    long Npixels = 0;
+
+    for (long i = 0; i < mask->numRows; i++) {
+        for (long j = 0; j < mask->numCols; j++) {
+            if (mask->data.U8[i][j] & value) {
+                Npixels ++;
+            }
+        }
+    }
+    return (Npixels);
+}
+
Index: /trunk/psLib/src/imageops/psImageStats.h
===================================================================
--- /trunk/psLib/src/imageops/psImageStats.h	(revision 5088)
+++ /trunk/psLib/src/imageops/psImageStats.h	(revision 5089)
@@ -9,6 +9,6 @@
 *  @author GLG, MHPCC
 *
-*  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2005-09-08 00:07:59 $
+*  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2005-09-22 02:32:00 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -85,4 +85,9 @@
 );
 
+long psImageCountPixelMask(
+    psImage *mask,
+    psMaskType value
+);
+
 /// @}
 
Index: /trunk/psLib/src/mathtypes/psVector.c
===================================================================
--- /trunk/psLib/src/mathtypes/psVector.c	(revision 5088)
+++ /trunk/psLib/src/mathtypes/psVector.c	(revision 5089)
@@ -9,6 +9,6 @@
 *  @author Robert DeSonia, MHPCC
 *
-*  @version $Revision: 1.53 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2005-09-21 21:37:21 $
+*  @version $Revision: 1.54 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2005-09-22 02:32:00 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -746,9 +746,9 @@
 
 #define FUNC_MACRO_VECTOR_CREATE(TYPE) \
-static psVector *vectorCreate##TYPE(double lower, double upper, double delta) \
+static psVector *vectorCreate##TYPE(psVector *input, double lower, double upper, double delta) \
 { \
     \
     int nBin = (upper - lower) / delta; \
-    psVector *vec = psVectorAlloc(nBin, PS_TYPE_##TYPE); \
+    psVector *vec = psVectorRecycle(input, nBin, PS_TYPE_##TYPE); \
     for (int i = 0; i < nBin; i++) \
     { \
@@ -769,5 +769,6 @@
 FUNC_MACRO_VECTOR_CREATE(F64)
 
-psVector *psVectorCreate (double lower,
+psVector *psVectorCreate (psVector *input,
+                          double lower,
                           double upper,
                           double delta,
@@ -777,42 +778,146 @@
     switch (type) {
     case PS_TYPE_S8:
-        out = vectorCreateS8( lower,  upper, delta);
+        out = vectorCreateS8(input, lower,  upper, delta);
         break;
     case PS_TYPE_S16:
-        out = vectorCreateS16(lower, upper, delta);
+        out = vectorCreateS16(input, lower, upper, delta);
         break;
     case PS_TYPE_S32:
-        out = vectorCreateS32(lower, upper, delta);
+        out = vectorCreateS32(input, lower, upper, delta);
         break;
     case PS_TYPE_S64:
-        out = vectorCreateS64(lower, upper, delta);
+        out = vectorCreateS64(input, lower, upper, delta);
         break;
     case PS_TYPE_U8:
-        out = vectorCreateU8(lower, upper, delta);
+        out = vectorCreateU8(input, lower, upper, delta);
         break;
     case PS_TYPE_U16:
-        out = vectorCreateU16(lower, upper, delta);
+        out = vectorCreateU16(input, lower, upper, delta);
         break;
     case PS_TYPE_U32:
-        out = vectorCreateU32(lower, upper, delta);
+        out = vectorCreateU32(input, lower, upper, delta);
         break;
     case PS_TYPE_U64:
-        out = vectorCreateU64(lower, upper, delta);
+        out = vectorCreateU64(input, lower, upper, delta);
         break;
     case PS_TYPE_F32:
-        out = vectorCreateF32(lower, upper, delta);
+        out = vectorCreateF32(input, lower, upper, delta);
         break;
     case PS_TYPE_F64:
-        out = vectorCreateF64(lower, upper, delta);
+        out = vectorCreateF64(input, lower, upper, delta);
         break;
     default:
         psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Invalid psType for Vector Create\n");
     }
-    /*
-      for (int i = 0; i < nBin; i++) {
-        out->data.F64[i] = lower + i * delta;
-      }
-    */
     return (out);
 }
 
+bool psVectorSet(const psVector *input,
+                 long position,
+                 complex value)
+{
+    if (input == NULL)
+        return false;
+    if (position >= input->n)
+        return false;
+    if(position < 0)
+        position += input->n;
+
+    switch (input->type.type) {
+    case PS_TYPE_U8:
+        *(psU8*)&input->data.U8[position] = value;
+        break;
+    case PS_TYPE_U16:
+        *(psU16*)&input->data.U16[position] = value;
+        break;
+    case PS_TYPE_U32:
+        *(psU32*)&input->data.U32[position] = value;
+        break;
+    case PS_TYPE_U64:
+        *(psU64*)&input->data.U64[position] = value;
+        break;
+    case PS_TYPE_S8:
+        *(psS8*)&input->data.S8[position] = value;
+        break;
+    case PS_TYPE_S16:
+        *(psS16*)&input->data.S16[position] = value;
+        break;
+    case PS_TYPE_S32:
+        *(psS32*)&input->data.S32[position] = value;
+        break;
+    case PS_TYPE_S64:
+        *(psS64*)&input->data.S64[position] = value;
+        break;
+    case PS_TYPE_F32:
+        *(psF32*)&input->data.F32[position] = value;
+        break;
+    case PS_TYPE_F64:
+        *(psF64*)&input->data.F64[position] = value;
+        break;
+    case PS_TYPE_C32:
+        *(psC32*)&input->data.C32[position] = value;
+        break;
+    case PS_TYPE_C64:
+        *(psC64*)&input->data.C64[position] = value;
+        break;
+    default:
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Invalid psVector Data Type\n");
+    }
+
+    return true;
+}
+
+complex psVectorGet(const psVector *input,
+                    long position)
+{
+    if (input == NULL)
+        return NAN;
+    if (position >= input->n) {
+        return NAN;
+    }
+    if(position < 0)
+        position += input->n;
+
+    switch (input->type.type) {
+    case PS_TYPE_U8:
+        return input->data.U8[position];
+        break;
+    case PS_TYPE_U16:
+        return input->data.U16[position];
+        break;
+    case PS_TYPE_U32:
+        return input->data.U32[position];
+        break;
+    case PS_TYPE_U64:
+        return input->data.U64[position];
+        break;
+    case PS_TYPE_S8:
+        return input->data.S8[position];
+        break;
+    case PS_TYPE_S16:
+        return input->data.S16[position];
+        break;
+    case PS_TYPE_S32:
+        return input->data.S32[position];
+        break;
+    case PS_TYPE_S64:
+        return input->data.S64[position];
+        break;
+    case PS_TYPE_F32:
+        return input->data.F32[position];
+        break;
+    case PS_TYPE_F64:
+        return input->data.F64[position];
+        break;
+    case PS_TYPE_C32:
+        return input->data.C32[position];
+        break;
+    case PS_TYPE_C64:
+        return input->data.C64[position];
+        break;
+    default:
+        return NAN;
+    }
+
+}
+
Index: /trunk/psLib/src/mathtypes/psVector.h
===================================================================
--- /trunk/psLib/src/mathtypes/psVector.h	(revision 5088)
+++ /trunk/psLib/src/mathtypes/psVector.h	(revision 5089)
@@ -11,6 +11,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.46 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-09-21 21:37:21 $
+ *  @version $Revision: 1.47 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-09-22 02:32:00 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -217,4 +217,5 @@
  */
 psVector *psVectorCreate (
+    psVector *input,                   ///< Input vector
     double lower,                      ///< lower bound
     double upper,                      ///< upper bound
@@ -223,4 +224,27 @@
 );
 
+/** Sets the value of the input vector at the specified position to value.
+ *
+ *  A negative position means index from the end.
+ *
+ *  @return bool:       True if successful, otherwise false.
+ */
+bool psVectorSet(
+    const psVector *input,             ///< Input vector to set
+    long position,                     ///< vector position
+    complex value                      ///< value to set
+);
+
+/** Returns the value of the input vector at the specified position.
+ *
+ *  A negative position means index from the end.
+ *
+ *  @return complex:        Value of the input vector at the specified position.
+ */
+complex psVectorGet(
+    const psVector *input,             ///< Input vector from which to get value
+    long position                      ///< vector position
+);
+
 /// @}
 
Index: /trunk/psLib/src/types/psMetadata.c
===================================================================
--- /trunk/psLib/src/types/psMetadata.c	(revision 5088)
+++ /trunk/psLib/src/types/psMetadata.c	(revision 5089)
@@ -12,6 +12,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.83 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-09-15 21:22:22 $
+ *  @version $Revision: 1.84 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-09-22 02:32:00 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -1269,2 +1269,63 @@
 }
 
+// we have log levels 1 (Error), 2 (Warning), 3 (Info), 4 (Details), 5 (Minutiae)
+// 2 = default, -v = 3, -vv = 4, -vvv = 5
+psS32 psLogArguments (int *argc, char **argv)
+{
+
+    int N, level;
+
+    // default log level is 2
+    level = 2;
+
+    // set in order, so that -vvv overrides -vv overrides -v
+    if ((N = psArgumentGet (*argc, argv, "-v"))) {
+        psArgumentRemove (N, argc, argv);
+        level = 3;
+    }
+    if ((N = psArgumentGet (*argc, argv, "-vv"))) {
+        psArgumentRemove (N, argc, argv);
+        level = 4;
+    }
+    if ((N = psArgumentGet (*argc, argv, "-vvv"))) {
+        psArgumentRemove (N, argc, argv);
+        level = 5;
+    }
+
+    if ((N = psArgumentGet (*argc, argv, "-logfmt"))) {
+        if (*argc < N + 2) {
+            psAbort ("psLogArguments", "USAGE: -logfmt (format)");
+        }
+        psArgumentRemove (N, argc, argv);
+        psLogSetFormat (argv[N]); // XXX EAM : this function should return an error if the log format is invalid
+        psArgumentRemove (N, argc, argv);
+    }
+
+    // set the level, return the level
+    psLogSetLevel (level);
+    return (level);
+}
+
+// set trace levels by facility
+psS32 psTraceArguments (int *argc, char **argv)
+{
+
+    int N;
+
+    // argument format is: -trace (facil) (level)
+    while ((N = psArgumentGet (*argc, argv, "-trace"))) {
+        if (*argc < N + 3) {
+            psAbort ("psTraceArguments", "USAGE: -trace (facility) (level)");
+        }
+        psArgumentRemove (N, argc, argv);
+        psTraceSetLevel (argv[N], atoi(argv[N+1]));
+        psArgumentRemove (N, argc, argv);
+        psArgumentRemove (N, argc, argv);
+    }
+    if ((N = psArgumentGet (*argc, argv, "-trace-levels"))) {
+        psTracePrintLevels ();
+        exit (2);
+    }
+    return (TRUE);
+}
+
Index: /trunk/psLib/test/mathtypes/tst_psVector.c
===================================================================
--- /trunk/psLib/test/mathtypes/tst_psVector.c	(revision 5088)
+++ /trunk/psLib/test/mathtypes/tst_psVector.c	(revision 5089)
@@ -14,6 +14,6 @@
  *  @author  Ross Harman, MHPCC
  *
- *  @version $Revision: 1.3 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2005-09-21 21:37:21 $
+ *  @version $Revision: 1.4 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2005-09-22 02:32:00 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -29,4 +29,5 @@
 static psS32 testVectorInit(void);
 static psS32 testVectorCreate(void);
+static psS32 testVectorGetSet(void);
 
 testDescription tests[] = {
@@ -36,4 +37,5 @@
                               {testVectorInit,-4,"psVectorInit",0,false},
                               {testVectorCreate,-5,"psVectorCreate",0,false},
+                              {testVectorGetSet,-6,"psVectorGet/Set",0,false},
                               {NULL}
                           };
@@ -364,7 +366,9 @@
     psVector *test = NULL;
     psVector *test2 = NULL;
-
-    test = psVectorCreate(0.0, 10.0, 1.0, PS_TYPE_S32);
-    test2 = psVectorCreate(0.0, 5.0, 0.5, PS_TYPE_F32);
+    psVector *input = NULL;
+    psVector *input2 = psVectorAlloc(5, PS_TYPE_F64);
+
+    test = psVectorCreate(input, 0.0, 10.0, 1.0, PS_TYPE_S32);
+    test2 = psVectorCreate(input2, 0.0, 5.0, 0.5, PS_TYPE_F32);
 
     for (int i = 0; i < 10; i++) {
@@ -383,2 +387,24 @@
 }
 
+psS32 testVectorGetSet(void)
+{
+    psVector *vec = NULL;
+    vec = psVectorAlloc(5, PS_TYPE_S32);
+
+    if ( !psVectorSet(vec, 0, 10) )
+        fprintf(stderr, "VectorSet failed to set S32 at position 0\n");
+    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 ( (psS32)psVectorGet(vec, 0) != 10 )
+        fprintf(stderr, "VectorGet Failed to return the correct S32 from position 0\n");
+    if ( (psS32)psVectorGet(vec, -1) != 4 )
+        fprintf(stderr, "VectorGet Failed to return the correct S32 from tail using -1\n");
+
+    psFree(vec);
+    return 0;
+}
+
+
+
Index: /trunk/psLib/test/mathtypes/verified/tst_psVector.stderr
===================================================================
--- /trunk/psLib/test/mathtypes/verified/tst_psVector.stderr	(revision 5088)
+++ /trunk/psLib/test/mathtypes/verified/tst_psVector.stderr	(revision 5089)
@@ -58,2 +58,11 @@
 ---> TESTPOINT PASSED (psVector{psVectorCreate} | tst_psVector.c)
 
+/***************************** TESTPOINT ******************************************\
+*             TestFile: tst_psVector.c                                             *
+*            TestPoint: psVector{psVectorGet/Set}                                  *
+*             TestType: Positive                                                   *
+\**********************************************************************************/
+
+
+---> TESTPOINT PASSED (psVector{psVectorGet/Set} | tst_psVector.c)
+
