Index: trunk/psLib/src/math/psMinimizePolyFit.c
===================================================================
--- trunk/psLib/src/math/psMinimizePolyFit.c	(revision 6305)
+++ trunk/psLib/src/math/psMinimizePolyFit.c	(revision 6484)
@@ -10,6 +10,6 @@
  *  @author EAM, IfA
  *
- *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-02-02 21:09:07 $
+ *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-02-24 23:43:15 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -44,8 +44,10 @@
     for (psS32 i = 0 ; i < SIZE ; i++) { \
         VEC->data.F64[i] = ((2.0 / ((psF64) (SIZE - 1))) * ((psF64) i)) - 1.0; \
+        VEC->n++; \
     }\
 } else if (TYPE == PS_TYPE_F32){ \
     for (psS32 i = 0 ; i < SIZE ; i++) { \
         VEC->data.F32[i] = ((2.0 / ((psF32) (SIZE - 1))) * ((psF32) i)) - 1.0; \
+        VEC->n++; \
     }\
 }\
@@ -87,6 +89,8 @@
     if (sums == NULL) {
         sums = psVectorAlloc(nSum, PS_TYPE_F64);
+        sums->n = sums->nalloc;
     } else if (nSum > sums->n) {
         sums = psVectorRealloc(sums, nSum);
+        sums->n = sums->nalloc;
     }
 
@@ -305,5 +309,5 @@
     linear equations which can be easily solved.  The resulting vector is the
     coefficients of the Chebyshev polys.
-    
+ 
     This method is significantly slower than the standard NR algorithm.  It
     was explicitly requested that we not use the NR algorithm.
@@ -371,4 +375,5 @@
         }
         B->data.F64[i] = ordPoly->coeff[i];
+        B->n++;
     }
 
@@ -534,4 +539,5 @@
     // Compute the B vector
     psVector *B = psVectorAlloc(NUM_POLY, PS_TYPE_F64);
+    B->n = B->nalloc;
     for (psS32 i = 0 ; i < NUM_POLY ; i++) {
         B->data.F64[i] = 0.0;
@@ -780,4 +786,5 @@
     A = psImageAlloc(nTerm, nTerm, PS_TYPE_F64);
     B = psVectorAlloc(nTerm, PS_TYPE_F64);
+    B->n = B->nalloc;
     // Initialize data structures.
     if (!psImageInit(A, 0.0) || !psVectorInit(B, 0.0)) {
@@ -1045,4 +1052,5 @@
     psVector *fit   = NULL;
     psVector *resid = psVectorAlloc(f->n, PS_TYPE_F64);
+    resid->n = resid->nalloc;
 
     // eventual expansion: user supplies one of various stats option pairs,
@@ -1205,4 +1213,5 @@
     A = psImageAlloc(nTerm, nTerm, PS_TYPE_F64);
     B = psVectorAlloc(nTerm, PS_TYPE_F64);
+    B->n = B->nalloc;
     // Initialize data structures.
     if (!psImageInit(A, 0.0) || !psVectorInit(B, 0.0)) {
@@ -1462,4 +1471,5 @@
     }
     psVector *resid = psVectorAlloc(f->n, PS_TYPE_F64);
+    resid->n = resid->nalloc;
 
     // eventual expansion: user supplies one of various stats option pairs,
@@ -1630,4 +1640,5 @@
     A = psImageAlloc(nTerm, nTerm, PS_TYPE_F64);
     B = psVectorAlloc(nTerm, PS_TYPE_F64);
+    B->n = B->nalloc;
     // Initialize data structures.
     if (!psImageInit(A, 0.0) || !psVectorInit(B, 0.0)) {
@@ -2002,4 +2013,5 @@
     psVector *fit   = NULL;
     psVector *resid = psVectorAlloc(f->n, PS_TYPE_F64);
+    resid->n = resid->nalloc;
 
     // eventual expansion: user supplies one of various stats option pairs,
@@ -2174,4 +2186,5 @@
     A = psImageAlloc(nTerm, nTerm, PS_TYPE_F64);
     B = psVectorAlloc(nTerm, PS_TYPE_F64);
+    B->n = B->nalloc;
     // Initialize data structures.
     if (!psImageInit(A, 0.0) || !psVectorInit(B, 0.0)) {
@@ -2596,4 +2609,5 @@
     psVector *fit   = NULL;
     psVector *resid = psVectorAlloc(f->n, PS_TYPE_F64);
+    resid->n = resid->nalloc;
 
     // eventual expansion: user supplies one of various stats option pairs,
