Index: /trunk/psModules/src/pmImageSubtract.c
===================================================================
--- /trunk/psModules/src/pmImageSubtract.c	(revision 4034)
+++ /trunk/psModules/src/pmImageSubtract.c	(revision 4035)
@@ -5,6 +5,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-05-25 23:00:05 $
+ *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-05-25 23:08:33 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -395,7 +395,7 @@
 XXX: Modify loop so that terms higher than spatialOrder are not computed.
  ******************************************************************************/
-static psImage GenSpatialOrder(psS32 spatialOrder,
-                               psF32 x,
-                               psF32 y)
+static psImage *GenSpatialOrder(psS32 spatialOrder,
+                                psF32 x,
+                                psF32 y)
 {
     psImage *polyValues = psImageAlloc(spatialOrder+1, spatialOrder+1, PS_TYPE_F64);
@@ -407,7 +407,7 @@
         for (psS32 j = 0; j < spatialOrder + 1; j++) {
             polyValues->data.F64[i][j] = ySum;
-            ySum*= imageY;
-        }
-        xSum*= imageX;
+            ySum*= y;
+        }
+        xSum*= x;
     }
 
@@ -458,9 +458,4 @@
 
     //
-    // The [i][j]-th element of this structure will hold (x^i * y^j) for the stamp.
-    //
-    psImage *polyValues = psImageAlloc(spatialOrder+1, spatialOrder+1, PS_TYPE_F64);
-
-    //
     // We iterate over each stamp, allocate the matrix and vectors if
     // necessary, and then calculate those matrix/vectors.
@@ -698,11 +693,11 @@
 XXX: Static structure for polyValues?
  ******************************************************************************/
-statis psF32 *ConvolvePixelPois(const psImage *input,
-                                const psImage *mask,
-                                psU32 badStampMaskVal,
-                                const psVector *solution,
-                                const psSubtractionKernels *kernels
-                                psS32 col,
-                                psS32 row)
+static psF32 ConvolvePixelPois(const psImage *input,
+                               const psImage *mask,
+                               psU32 badStampMaskVal,
+                               const psVector *solution,
+                               const psSubtractionKernels *kernels,
+                               psS32 col,
+                               psS32 row)
 {
     psS32 nBF = kernels->u->n;
@@ -711,7 +706,7 @@
     psF32 background = solution->data.F64[solution->n-1];
     psS32 spatialOrder = kernels->p_spatialOrder;
+    psF32 conv = background; // Initial convolved value
 
     if ((mask == NULL) || !(mask->data.U8[row][col] & badStampMaskVal)) {
-        psF32 conv = background; // Initial convolved value
         psF32 imageX = (((psF32) col) - numColsHalf) / numColsHalf; // Normalised position
         psF32 imageY = (((psF32) row) - numRowsHalf) / numRowsHalf; // Normalised position
@@ -744,6 +739,6 @@
             }
         }
-    }
-    psFree(polyValues);
+        psFree(polyValues);
+    }
 
     return(conv);
@@ -763,11 +758,11 @@
 XXX: Static structure for polyValues?
  ******************************************************************************/
-statis psF32 *ConvolvePixelIsis(const psImage *input,
-                                const psImage *mask,
-                                psU32 badStampMaskVal,
-                                const psVector *solution,
-                                const psSubtractionKernels *kernels
-                                psS32 col,
-                                psS32 row)
+static psF32 ConvolvePixelIsis(const psImage *input,
+                               const psImage *mask,
+                               psU32 badStampMaskVal,
+                               const psVector *solution,
+                               const psSubtractionKernels *kernels,
+                               psS32 col,
+                               psS32 row)
 {
     psS32 nBF = kernels->u->n;
@@ -776,7 +771,8 @@
     psF32 background = solution->data.F64[solution->n-1];
     psS32 spatialOrder = kernels->p_spatialOrder;
+    psS32 kernelSize = kernels->p_size;
+    psF32 conv = background; // Initial convolved value
 
     if ((mask == NULL) || !(mask->data.U8[row][col] & badStampMaskVal)) {
-        psF32 conv = background; // Initial convolved value
         psF32 imageX = (((psF32) col) - numColsHalf) / numColsHalf; // Normalised position
         psF32 imageY = (((psF32) row) - numRowsHalf) / numRowsHalf; // Normalised position
@@ -805,5 +801,5 @@
 
                     conv += solution->data.F64[k] *
-                            input->data.F32[yy+y][xx+x] *
+                            input->data.F32[yy+row][xx+col] *
                             preCalc->data.F32[yy-kernelSize][xx-kernelSize] *
                             polyVal;
@@ -811,14 +807,9 @@
             }
         }
-    }
-    psFree(polyValues);
+        psFree(polyValues);
+    }
 
     return(conv);
 }
-
-
-
-
-
 
 /*******************************************************************************
@@ -1144,5 +1135,5 @@
         // the psImage polyValues will hold (x^i * y^j) for the stamp.
         //
-        psImage *polyValues = GenSpatialOrder(psS32 spatialOrder, x, y);
+        psImage *polyValues = GenSpatialOrder(spatialOrder, x, y);
 
         for (psS32 k = 0 ; k < nBF ; k++) {
