Index: trunk/psLib/src/astro/psCoord.c
===================================================================
--- trunk/psLib/src/astro/psCoord.c	(revision 3713)
+++ trunk/psLib/src/astro/psCoord.c	(revision 3714)
@@ -10,6 +10,6 @@
 *  @author GLG, MHPCC
 *
-*  @version $Revision: 1.63 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2005-04-19 01:22:59 $
+*  @version $Revision: 1.64 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2005-04-19 04:16:02 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -84,11 +84,33 @@
  X1 = (-D + ((F*A)/C)) / (E - ((F*B)/C)) +
       (X2 * -((F/C) / (E - ((F*B)/C)))) +
-             (Y2 * (1.0 / (E - ((F*B)/C))));
-        Y1 = (-D + ((E*A)/B))/(F - ((C*E)/B)) +
-             (X2 * -((E/B) / (F - ((C*E)/B)))) +
-             (Y2 * (1.0 / (F - ((C*E)/B))));
+      (Y2 * (1.0 / (E - ((F*B)/C))));
+ Y1 = (-D + ((E*A)/B))/(F - ((C*E)/B)) +
+      (X2 * -((E/B) / (F - ((C*E)/B)))) +
+      (Y2 * (1.0 / (F - ((C*E)/B))));
  
 XXX: Since thre is now a general psPlaneTransformInvert() function, we
 should rename this.
+ 
+X1, Y1 = (2, 3)
+ 
+    X2 = 1 + 4 + 9   = 14
+    Y2 = 4 + 10 + 18 = 32
+ 
+in inverse
+ 
+Y1 = (32 - ((5/2) * 14) - 4 + ((5)/2)) / (6 - ((15)/2));
+Y1 = (32 - 35 - 4 + (5/2)) / (6 - 15/2);
+Y1 = (-7 + (5/2)) / (12/2 - 15/2);
+Y1 = (-7 + (5/2)) / (-3/2);
+Y1 = (-14/2 + 5/2) / (-3/2);
+Y1 = (-9/2) / (-3/2);
+Y1 = (9/2) / (3/2);
+Y1 = 3
+ 
+X1 = (Y2 - ((F/C) * X2) - D + ((F*A)/C)) / (E - ((F*B)/C));
+X1 = (32 - ((6/3) * 14) - 4 + ((6)/3)) / (5 - ((12)/3));
+X1 = (32 - (2 * 14) - 4 + 2 / (5 - 4);
+X1 = (32 - 28 - 4 + 2) / 1;
+X1 = 2;
  
  *****************************************************************************/
@@ -125,8 +147,8 @@
     psPlaneTransform *out = psPlaneTransformAlloc(2, 2);
 
-    out->x->coeff[0][0] = -D + ((F*A)/C) / (E - ((F*B)/C));
+    out->x->coeff[0][0] = (-D + ((F*A)/C)) / (E - ((F*B)/C));
     out->x->coeff[1][0] = -(F/C) / (E - ((F*B)/C));
     out->x->coeff[0][1] =  1.0 / (E - ((F*B)/C));
-    out->y->coeff[0][0] = -D + ((E*A)/B) / (F - ((C*E)/B));
+    out->y->coeff[0][0] = (-D + ((E*A)/B)) / (F - ((C*E)/B));
     out->y->coeff[1][0] = -(E/B) / (F - ((C*E)/B));
     out->y->coeff[0][1] =  1.0 / (F - ((C*E)/B));
@@ -1140,5 +1162,4 @@
     //
     if (p_psIsProjectionLinear((psPlaneTransform *) in)) {
-        printf("COOL: is linear\n");
         return(p_psPlaneTransformLinearInvert((psPlaneTransform *) in));
     }
Index: trunk/psLib/src/astronomy/psCoord.c
===================================================================
--- trunk/psLib/src/astronomy/psCoord.c	(revision 3713)
+++ trunk/psLib/src/astronomy/psCoord.c	(revision 3714)
@@ -10,6 +10,6 @@
 *  @author GLG, MHPCC
 *
-*  @version $Revision: 1.63 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2005-04-19 01:22:59 $
+*  @version $Revision: 1.64 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2005-04-19 04:16:02 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -84,11 +84,33 @@
  X1 = (-D + ((F*A)/C)) / (E - ((F*B)/C)) +
       (X2 * -((F/C) / (E - ((F*B)/C)))) +
-             (Y2 * (1.0 / (E - ((F*B)/C))));
-        Y1 = (-D + ((E*A)/B))/(F - ((C*E)/B)) +
-             (X2 * -((E/B) / (F - ((C*E)/B)))) +
-             (Y2 * (1.0 / (F - ((C*E)/B))));
+      (Y2 * (1.0 / (E - ((F*B)/C))));
+ Y1 = (-D + ((E*A)/B))/(F - ((C*E)/B)) +
+      (X2 * -((E/B) / (F - ((C*E)/B)))) +
+      (Y2 * (1.0 / (F - ((C*E)/B))));
  
 XXX: Since thre is now a general psPlaneTransformInvert() function, we
 should rename this.
+ 
+X1, Y1 = (2, 3)
+ 
+    X2 = 1 + 4 + 9   = 14
+    Y2 = 4 + 10 + 18 = 32
+ 
+in inverse
+ 
+Y1 = (32 - ((5/2) * 14) - 4 + ((5)/2)) / (6 - ((15)/2));
+Y1 = (32 - 35 - 4 + (5/2)) / (6 - 15/2);
+Y1 = (-7 + (5/2)) / (12/2 - 15/2);
+Y1 = (-7 + (5/2)) / (-3/2);
+Y1 = (-14/2 + 5/2) / (-3/2);
+Y1 = (-9/2) / (-3/2);
+Y1 = (9/2) / (3/2);
+Y1 = 3
+ 
+X1 = (Y2 - ((F/C) * X2) - D + ((F*A)/C)) / (E - ((F*B)/C));
+X1 = (32 - ((6/3) * 14) - 4 + ((6)/3)) / (5 - ((12)/3));
+X1 = (32 - (2 * 14) - 4 + 2 / (5 - 4);
+X1 = (32 - 28 - 4 + 2) / 1;
+X1 = 2;
  
  *****************************************************************************/
@@ -125,8 +147,8 @@
     psPlaneTransform *out = psPlaneTransformAlloc(2, 2);
 
-    out->x->coeff[0][0] = -D + ((F*A)/C) / (E - ((F*B)/C));
+    out->x->coeff[0][0] = (-D + ((F*A)/C)) / (E - ((F*B)/C));
     out->x->coeff[1][0] = -(F/C) / (E - ((F*B)/C));
     out->x->coeff[0][1] =  1.0 / (E - ((F*B)/C));
-    out->y->coeff[0][0] = -D + ((E*A)/B) / (F - ((C*E)/B));
+    out->y->coeff[0][0] = (-D + ((E*A)/B)) / (F - ((C*E)/B));
     out->y->coeff[1][0] = -(E/B) / (F - ((C*E)/B));
     out->y->coeff[0][1] =  1.0 / (F - ((C*E)/B));
@@ -1140,5 +1162,4 @@
     //
     if (p_psIsProjectionLinear((psPlaneTransform *) in)) {
-        printf("COOL: is linear\n");
         return(p_psPlaneTransformLinearInvert((psPlaneTransform *) in));
     }
Index: trunk/psLib/src/dataManip/psFunctions.c
===================================================================
--- trunk/psLib/src/dataManip/psFunctions.c	(revision 3713)
+++ trunk/psLib/src/dataManip/psFunctions.c	(revision 3714)
@@ -7,13 +7,15 @@
  *  polynomials.  It also contains a Gaussian functions.
  *
- *  @version $Revision: 1.97 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-04-19 00:34:04 $
+ *  @version $Revision: 1.98 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-04-19 04:16:02 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
  *
- *  XXX: What happens if the polyEVal functions are called with data of the wrong
+ *  XXX: What happens if the polyEval functions are called with data of the wrong
  *       type?
  *  XXX: Should the "coeffErr[]" be used as well?  Bug ???.  Ignore coeffErr
  *
+ *  XXX: In the various polyAlloc(n) functions, n is really the order of the
+ *  polynomial plus 1.  To create a 2nd-order polynomial, n == 3.
  */
 /*****************************************************************************/
@@ -175,7 +177,7 @@
 static void dPolynomial2DFree(psDPolynomial2D* myPoly)
 {
-    psS32 x = 0;
-
-    for (x = 0; x < myPoly->nX; x++) {
+    //printf("dPolynomial2DFree(): HMMM: myPoly->nX is %d\n", myPoly->nX);
+    //printf("dPolynomial2DFree(): HMMM: myPoly->nY is %d\n", myPoly->nY);
+    for (psS32 x = 0; x < myPoly->nX; x++) {
         psFree(myPoly->coeff[x]);
         psFree(myPoly->coeffErr[x]);
Index: trunk/psLib/src/image/psImageStats.c
===================================================================
--- trunk/psLib/src/image/psImageStats.c	(revision 3713)
+++ trunk/psLib/src/image/psImageStats.c	(revision 3714)
@@ -9,6 +9,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.71 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-04-08 17:58:57 $
+ *  @version $Revision: 1.72 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-04-19 04:16:02 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -40,4 +40,7 @@
  
 XXX: use static psVectors
+ 
+XXX: optimize this.  2k vs 4k, sample mean, takes8 seconds on Gene's machine.
+Should take .2.
  *****************************************************************************/
 psStats* psImageStats(psStats* stats,
Index: trunk/psLib/src/imageops/psImageStats.c
===================================================================
--- trunk/psLib/src/imageops/psImageStats.c	(revision 3713)
+++ trunk/psLib/src/imageops/psImageStats.c	(revision 3714)
@@ -9,6 +9,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.71 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-04-08 17:58:57 $
+ *  @version $Revision: 1.72 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-04-19 04:16:02 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -40,4 +40,7 @@
  
 XXX: use static psVectors
+ 
+XXX: optimize this.  2k vs 4k, sample mean, takes8 seconds on Gene's machine.
+Should take .2.
  *****************************************************************************/
 psStats* psImageStats(psStats* stats,
Index: trunk/psLib/src/math/psPolynomial.c
===================================================================
--- trunk/psLib/src/math/psPolynomial.c	(revision 3713)
+++ trunk/psLib/src/math/psPolynomial.c	(revision 3714)
@@ -7,13 +7,15 @@
  *  polynomials.  It also contains a Gaussian functions.
  *
- *  @version $Revision: 1.97 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-04-19 00:34:04 $
+ *  @version $Revision: 1.98 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-04-19 04:16:02 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
  *
- *  XXX: What happens if the polyEVal functions are called with data of the wrong
+ *  XXX: What happens if the polyEval functions are called with data of the wrong
  *       type?
  *  XXX: Should the "coeffErr[]" be used as well?  Bug ???.  Ignore coeffErr
  *
+ *  XXX: In the various polyAlloc(n) functions, n is really the order of the
+ *  polynomial plus 1.  To create a 2nd-order polynomial, n == 3.
  */
 /*****************************************************************************/
@@ -175,7 +177,7 @@
 static void dPolynomial2DFree(psDPolynomial2D* myPoly)
 {
-    psS32 x = 0;
-
-    for (x = 0; x < myPoly->nX; x++) {
+    //printf("dPolynomial2DFree(): HMMM: myPoly->nX is %d\n", myPoly->nX);
+    //printf("dPolynomial2DFree(): HMMM: myPoly->nY is %d\n", myPoly->nY);
+    for (psS32 x = 0; x < myPoly->nX; x++) {
         psFree(myPoly->coeff[x]);
         psFree(myPoly->coeffErr[x]);
Index: trunk/psLib/src/math/psSpline.c
===================================================================
--- trunk/psLib/src/math/psSpline.c	(revision 3713)
+++ trunk/psLib/src/math/psSpline.c	(revision 3714)
@@ -7,13 +7,15 @@
  *  polynomials.  It also contains a Gaussian functions.
  *
- *  @version $Revision: 1.97 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-04-19 00:34:04 $
+ *  @version $Revision: 1.98 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-04-19 04:16:02 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
  *
- *  XXX: What happens if the polyEVal functions are called with data of the wrong
+ *  XXX: What happens if the polyEval functions are called with data of the wrong
  *       type?
  *  XXX: Should the "coeffErr[]" be used as well?  Bug ???.  Ignore coeffErr
  *
+ *  XXX: In the various polyAlloc(n) functions, n is really the order of the
+ *  polynomial plus 1.  To create a 2nd-order polynomial, n == 3.
  */
 /*****************************************************************************/
@@ -175,7 +177,7 @@
 static void dPolynomial2DFree(psDPolynomial2D* myPoly)
 {
-    psS32 x = 0;
-
-    for (x = 0; x < myPoly->nX; x++) {
+    //printf("dPolynomial2DFree(): HMMM: myPoly->nX is %d\n", myPoly->nX);
+    //printf("dPolynomial2DFree(): HMMM: myPoly->nY is %d\n", myPoly->nY);
+    for (psS32 x = 0; x < myPoly->nX; x++) {
         psFree(myPoly->coeff[x]);
         psFree(myPoly->coeffErr[x]);
