Index: trunk/psLib/src/math/psStats.c
===================================================================
--- trunk/psLib/src/math/psStats.c	(revision 9540)
+++ trunk/psLib/src/math/psStats.c	(revision 9730)
@@ -16,6 +16,6 @@
  * use ->min and ->max (PS_STAT_USE_RANGE)
  *
- *  @version $Revision: 1.187 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-10-13 22:04:58 $
+ *  @version $Revision: 1.188 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-24 22:52:56 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -388,5 +388,5 @@
 
     // Allocate temporary vectors for the data.
-    psVector* vector = psVectorAlloc(myVector->n, PS_TYPE_F32); // Vector containing the unmasked values
+    psVector* vector = psVectorAllocEmpty(myVector->n, PS_TYPE_F32); // Vector containing the unmasked values
     long count = 0;                     // Number of valid entries
 
@@ -486,5 +486,4 @@
     long numBins = histogram->nums->n;  // Number of histogram bins
     psVector *smooth = psVectorAlloc(numBins, PS_TYPE_F32); // Smoothed version of histogram bins
-    smooth->n = smooth->nalloc;
     const psVector *bounds = histogram->bounds; // The bounds for the histogram bins
 
@@ -723,5 +722,4 @@
     // We copy the mask vector, to preserve the original
     psVector *tmpMask = psVectorAlloc(myVector->n, PS_TYPE_U8);
-    tmpMask->n = tmpMask->nalloc;
     psVectorInit(tmpMask, 0);
     if (maskVector) {
@@ -901,6 +899,4 @@
     psVector *x = psVectorAlloc(3, PS_TYPE_F64);
     psVector *y = psVectorAlloc(3, PS_TYPE_F64);
-    x->n = 3;
-    y->n = 3;
     psF32 tmpFloat = 0.0f;
 
@@ -1066,5 +1062,4 @@
 
     psVector *mask = psVectorAlloc(myVector->n, PS_TYPE_MASK); // The actual mask we will use
-    mask->n = myVector->n;
     psVectorInit(mask, 0);
     if (maskVector) {
@@ -1487,10 +1482,7 @@
         psVector *y = psVectorAlloc((1 + (binMax - binMin)), PS_TYPE_F32); // Vector of coordinates
         psArray *x = psArrayAlloc((1 + (binMax - binMin))); // Array of ordinates
-        y->n = y->nalloc;
-        x->n = x->nalloc;
         for (long i = binMin, j = 0; i <= binMax ; i++, j++) {
             y->data.F32[j] = smoothed->data.F32[i];
             psVector *ordinate = psVectorAlloc(1, PS_TYPE_F32); // The ordinate value
-            ordinate->n = 1;
             ordinate->data.F32[0] = PS_BIN_MIDPOINT(histogram, i);
             x->data[j] = ordinate;
@@ -1521,5 +1513,4 @@
         psMinimization *minimizer = psMinimizationAlloc(100, 0.01); // The minimizer information
         psVector *params = psVectorAlloc(2, PS_TYPE_F32); // Parameters for the Gaussian
-        params->n = params->nalloc;
         // Initial guess for the mean (index 0) and standard dev (index 1).
         params->data.F32[0] = stats->robustMedian;
@@ -1654,5 +1645,4 @@
     psVector* newBounds = psVectorAlloc(n + 1, PS_TYPE_F32);
     newHist->bounds = newBounds;
-    newBounds->n = newHist->bounds->nalloc;
 
     // Calculate the bounds for each bin.
@@ -1666,8 +1656,5 @@
     // Allocate the bins, and initialize them to zero.
     newHist->nums = psVectorAlloc(n, PS_TYPE_F32);
-    for (long i = 0; i < newHist->nums->nalloc; i++) {
-        newHist->nums->data.F32[i] = 0.0;
-        newHist->nums->n++;
-    }
+    psVectorInit(newHist->nums, 0.0);
 
     // Initialize the other members.
@@ -1699,18 +1686,11 @@
     psHistogram *newHist = (psHistogram* ) psAlloc(sizeof(psHistogram)); // The new histogram structure
     psMemSetDeallocator(newHist, (psFreeFunc) histogramFree);
-    psVector* newBounds = psVectorAlloc(bounds->n, PS_TYPE_F32);
+    psVector* newBounds = psVectorCopy(NULL, bounds, PS_TYPE_F32);
     newHist->bounds = newBounds;
-    newBounds->n = newHist->bounds->nalloc;
-    for (long i = 0; i < bounds->n; i++) {
-        newBounds->data.F32[i] = bounds->data.F32[i];
-    }
 
     // Allocate the bins, and initialize them to zero.  If there are N bounds,
     // then there are N-1 bins.
     newHist->nums = psVectorAlloc((bounds->n) - 1, PS_TYPE_F32);
-    for (long i = 0; i < newHist->nums->nalloc; i++) {
-        newHist->nums->data.F32[i] = 0.0;
-        newHist->nums->n++;
-    }
+    psVectorInit(newHist->nums, 0.0);
 
     // Initialize the other members.
