Index: /trunk/psModules/src/pmImageSubtract.c
===================================================================
--- /trunk/psModules/src/pmImageSubtract.c	(revision 4036)
+++ /trunk/psModules/src/pmImageSubtract.c	(revision 4037)
@@ -5,6 +5,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-05-25 23:59:08 $
+ *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-05-26 00:13:48 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -75,14 +75,12 @@
     // for convenience.
     //
-    // XXX: replace (i, j) with (xOrder, yOrder) for clarity.
-    //
     psS32 ptr = 0;
     for (psS32 order = 0; order <= spatialOrder; order++) {
-        for (psS32 i = 0; i <= order; i++) {
-            psS32 j = order - i;
+        for (psS32 xOrder = 0; xOrder <= order; xOrder++) {
+            psS32 yOrder = order - xOrder;
             tmp->u->data.F32[ptr] = 0;
             tmp->v->data.F32[ptr] = 0;
-            tmp->xOrder->data.F32[ptr] = i;
-            tmp->yOrder->data.F32[ptr] = j;
+            tmp->xOrder->data.F32[ptr] = xOrder;
+            tmp->yOrder->data.F32[ptr] = yOrder;
             ptr++;
         }
@@ -100,13 +98,11 @@
                 // x^i * y^j  such that (i+j) <= spatialOrder.
                 //
-                // XXX: replace (i, j) with (xOrder, yOrder) for clarity.
-                //
                 for (psS32 order = 0; order <= spatialOrder; order++) {
-                    for (psS32 i = 0; i <= order; i++) {
-                        psS32 j = order - i;
+                    for (psS32 xOrder = 0; xOrder <= order; xOrder++) {
+                        psS32 yOrder = order - xOrder;
                         tmp->u->data.F32[ptr] = 0;
                         tmp->v->data.F32[ptr] = 0;
-                        tmp->xOrder->data.F32[ptr] = i;
-                        tmp->yOrder->data.F32[ptr] = j;
+                        tmp->xOrder->data.F32[ptr] = xOrder;
+                        tmp->yOrder->data.F32[ptr] = yOrder;
                         ptr++;
                     }
@@ -177,6 +173,4 @@
     // This loop creates
     //
-    // XXX: Put the v loop before the u loop.
-    // XXX: Put the orderYTerm loop before the orderXTerm loop.
     // XXX: must loop on the sigmas.
     //
@@ -191,6 +185,6 @@
             psImage *currKernel = (psImage *) psImageAlloc(1 + (2 * size), 1 + (2 * size), PS_TYPE_F32);
 
-            for (psS32 u = -xKernelHalfSize; u <= xKernelHalfSize; u++) {
-                for (psS32 v = -yKernelHalfSize; v <= yKernelHalfSize; v++) {
+            for (psS32 v = -yKernelHalfSize; v <= yKernelHalfSize; v++) {
+                for (psS32 u = -xKernelHalfSize; u <= xKernelHalfSize; u++) {
                     // Scale the (u,v) coordinates in kernel space to [-1.0:1.0].
                     psF32 uScaled = ((psF32) (u - xKernelHalfSize)) / ((psF32) (1 + (2 * xKernelHalfSize)));
@@ -199,5 +193,5 @@
                     psF32 exponent = (PS_SQR(uScaled) * PS_SQR(vScaled)) /
                                      (2.0 * PS_SQR(sigmas->data.F32[sigPtr]));
-                    currKernel->data.F32[u+xKernelHalfSize][v+yKernelHalfSize] =
+                    currKernel->data.F32[v+yKernelHalfSize][u+xKernelHalfSize] =
                         exp(exponent) * pow(uScaled, orderXTerm) + pow(vScaled, orderYTerm);
                 }
@@ -209,6 +203,4 @@
     //
     // sigPtr loops through each sigma value in the *sigmas argument.
-    // XXX: Put the v loop before the u loop.
-    // XXX: Put the orderYTerm loop before the orderXTerm loop.
     //
     psS32 ptr = 0;
@@ -250,6 +242,6 @@
                         psImage *currKernel = (psImage *) tmp->preCalc->data[ptr];
 
-                        for (psS32 u = -xKernelHalfSize; u <= xKernelHalfSize; u++) {
-                            for (psS32 v = -yKernelHalfSize; v <= yKernelHalfSize; v++) {
+                        for (psS32 v = -yKernelHalfSize; v <= yKernelHalfSize; v++) {
+                            for (psS32 u = -xKernelHalfSize; u <= xKernelHalfSize; u++) {
                                 // Scale the (u,v) coordinates in kernel space to [-1.0:1.0].
                                 psF32 uScaled = ((psF32) (u - xKernelHalfSize)) / ((psF32) (1 + (2 * xKernelHalfSize)));
@@ -259,5 +251,5 @@
                                 psF32 exponent = (PS_SQR(uScaled) * PS_SQR(vScaled)) /
                                                  (2.0 * PS_SQR(sigmas->data.F32[sigPtr]));
-                                currKernel->data.F32[u+xKernelHalfSize][v+yKernelHalfSize] =
+                                currKernel->data.F32[v+yKernelHalfSize][u+xKernelHalfSize] =
                                     exp(exponent) * pow(uScaled, orderXTerm) + pow(vScaled, orderYTerm);
                             }
@@ -274,5 +266,4 @@
 }
 
-// XXX: These should maybe be public, maybe private global, or private local.
 void p_pmStampFree(pmStamp *stamp)
 {
@@ -282,5 +273,4 @@
 }
 
-// XXX: These should maybe be public, maybe private global, or private local.
 pmStamp *p_pmStampAlloc(pmStampStatus status)
 {
@@ -328,5 +318,7 @@
     if (stamps != NULL) {
         PS_ASSERT_INT_EQUAL(stamps->n, (xNum * yNum), NULL);
-        // XXX: Ensure that a pmStamp struct exists at each psArray location.
+        //
+        // Ensure that a pmStamp struct exists at each psArray location.
+        //
         for (psS32 s = 0 ; s < (xNum * yNum) ; s++) {
             if (NULL == stamps->data[s]) {
@@ -367,5 +359,5 @@
                 // border of pixels from the image edge.
                 //
-                // XXX: verify this (numX, numY), then get rid of it.
+                // XXX: verify (numX, numY), then get rid of it.
                 //
                 psS32 numX = xNum;
@@ -435,11 +427,8 @@
 
 
-
 /*******************************************************************************
- 
 XXX: How is the spatial order factor calculated?  Is it simply a x^iy^j power
-eavaluated at the (x, y) center for the stamp?  Why bother with the 2-D
-polynomial in evaluating it?  Finally, why is it scaled to the half-size of
-the reference image?
+evaluated at the (x, y) center for the stamp?  Why bother with the 2-D
+polynomial in evaluating it?
  ******************************************************************************/
 bool pmSubtractionCalculateEquation(psArray *stamps,          ///< The stamps for which to calculate the equation,
@@ -515,7 +504,4 @@
             // Iterate over all pixels surrounding this stamp.
             //
-            // XXX: I modified the y,x loop order, and an [x][y] reference (1.0/reference->data.F32[y][x]).
-            //      Verify it.
-            //
             for (psS32 y = stamp->y - footprint; y < stamp->y + footprint; y++) {
                 for (psS32 x = stamp->x - footprint; x < stamp->x + footprint; x++) {
@@ -547,5 +533,4 @@
                                 conv1 -= reference->data.F32[y][x];
                             }
-
 
                             //
@@ -710,6 +695,4 @@
 It returns the value of the convolved pixel.
  
-XXX: Parameter checks?
- 
 XXX: Static structure for polyValues?
  ******************************************************************************/
@@ -772,6 +755,4 @@
 the set of kernel basis functions and their appropriate weights in solution.
 It returns the value of the convolved pixel.
- 
-XXX: Parameter checks?
  
 XXX: Static structure for polyValues?
@@ -830,8 +811,4 @@
 ConvolveImage(input, mask, badStampMaskVal, solution, kernels): convolves an
 arbitrary image with either an ISIS or POIS set of kernel basis functions.
- 
-XXX: Function decomposition: create a function which convolves a single
-function with a set of POIS kernel basis functions.  Create another for ISIS
-kernel basis functions.  Then rewrite this.
  ******************************************************************************/
 psImage *ConvolveImage(const psImage *input,
@@ -989,6 +966,4 @@
     }
 
-
-
     psFree(stats);
     psFree(subStamp);
@@ -996,7 +971,4 @@
     return deviations;
 }
-
-
-
 
 /*******************************************************************************
@@ -1081,5 +1053,4 @@
 
 /*******************************************************************************
-XXX: There are definite (x, y) (row, col) problems here.
  ******************************************************************************/
 psImage *pmSubtractionKernelImage(psImage *out,
@@ -1094,5 +1065,10 @@
     PS_ASSERT_FLOAT_WITHIN_RANGE(x, -1.0, 1.0, NULL);
     PS_ASSERT_FLOAT_WITHIN_RANGE(y, -1.0, 1.0, NULL);
-    // XXX: Assert that all vectors and arrays in kernels are of the same length.
+    PS_ASSERT_VECTORS_SIZE_EQUAL(kernels->u, kernels->v, NULL);
+    PS_ASSERT_VECTORS_SIZE_EQUAL(kernels->u, kernels->xOrder, NULL);
+    PS_ASSERT_VECTORS_SIZE_EQUAL(kernels->u, kernels->yOrder, NULL);
+    PS_ASSERT_VECTORS_SIZE_EQUAL(kernels->u, kernels->preCalc, NULL);
+    PS_ASSERT_INT_EQUAL(1+kernels->u->n, solution->n, NULL);
+
     psS32 nBF = kernels->u->n;
     psS32 spatialOrder = kernels->p_spatialOrder;
