Index: /trunk/psLib/src/astro/psCoord.c
===================================================================
--- /trunk/psLib/src/astro/psCoord.c	(revision 2205)
+++ /trunk/psLib/src/astro/psCoord.c	(revision 2206)
@@ -10,6 +10,6 @@
 *  @author George Gusciora, MHPCC
 *
-*  @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-10-27 00:57:30 $
+*  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-10-27 01:15:47 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -81,6 +81,6 @@
                                const psPlane* coords)
 {
-    PS_CHECK_NULL_PTR_RETURN_NULL(transform);
-    PS_CHECK_NULL_PTR_RETURN_NULL(coords);
+    PS_CHECK_NULL_PTR(transform, NULL);
+    PS_CHECK_NULL_PTR(coords, NULL);
     if (out == NULL) {
         out = (psPlane* ) psAlloc(sizeof(psPlane));
@@ -117,6 +117,6 @@
                              float magnitude)
 {
-    PS_CHECK_NULL_PTR_RETURN_NULL(transform);
-    PS_CHECK_NULL_PTR_RETURN_NULL(coords);
+    PS_CHECK_NULL_PTR(transform, NULL);
+    PS_CHECK_NULL_PTR(coords, NULL);
     if (out == NULL) {
         out = (psPlane* ) psAlloc(sizeof(psPlane));
@@ -156,6 +156,6 @@
                                  const psSphere* coord)
 {
-    PS_CHECK_NULL_PTR_RETURN_NULL(transform);
-    PS_CHECK_NULL_PTR_RETURN_NULL(coord);
+    PS_CHECK_NULL_PTR(transform, NULL);
+    PS_CHECK_NULL_PTR(coord, NULL);
     double sinY = 0.0;
     double cosY = 0.0;
@@ -228,6 +228,6 @@
                    const psProjection* projection)
 {
-    PS_CHECK_NULL_PTR_RETURN_NULL(coord);
-    PS_CHECK_NULL_PTR_RETURN_NULL(projection);
+    PS_CHECK_NULL_PTR(coord, NULL);
+    PS_CHECK_NULL_PTR(projection, NULL);
 
     float R = 0.0;
@@ -280,6 +280,6 @@
                       const psProjection* projection)
 {
-    PS_CHECK_NULL_PTR_RETURN_NULL(coord);
-    PS_CHECK_NULL_PTR_RETURN_NULL(projection);
+    PS_CHECK_NULL_PTR(coord, NULL);
+    PS_CHECK_NULL_PTR(projection, NULL);
 
     float R = 0.0;
@@ -348,6 +348,6 @@
                             psSphereOffsetUnit unit)
 {
-    PS_CHECK_NULL_PTR_RETURN_NULL(position1);
-    PS_CHECK_NULL_PTR_RETURN_NULL(position2);
+    PS_CHECK_NULL_PTR(position1, NULL);
+    PS_CHECK_NULL_PTR(position2, NULL);
 
     psPlane* lin;
@@ -416,6 +416,6 @@
                             psSphereOffsetUnit unit)
 {
-    PS_CHECK_NULL_PTR_RETURN_NULL(position);
-    PS_CHECK_NULL_PTR_RETURN_NULL(offset);
+    PS_CHECK_NULL_PTR(position, NULL);
+    PS_CHECK_NULL_PTR(offset, NULL);
 
     psPlane lin;
Index: /trunk/psLib/src/astronomy/psAstrometry.c
===================================================================
--- /trunk/psLib/src/astronomy/psAstrometry.c	(revision 2205)
+++ /trunk/psLib/src/astronomy/psAstrometry.c	(revision 2206)
@@ -8,6 +8,6 @@
  *  @author George Gusciora, MHPCC
  *
- *  @version $Revision: 1.43 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:30 $
+ *  @version $Revision: 1.44 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-10-27 01:15:47 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -58,6 +58,6 @@
 static psS32 isProjectionLinear(psPlaneTransform *transform)
 {
-    psS32 i = 0;
-    PS_CHECK_NULL_PTR_RETURN_ZERO(transform);
+    int i = 0;
+    PS_CHECK_NULL_PTR(transform, 0);
 
     for (i=2;i<(transform->x->nX);i++) {
@@ -114,5 +114,5 @@
     double F = transform->y->coeff[0][1];
 
-    PS_CHECK_NULL_PTR_RETURN_NULL(transform);
+    PS_CHECK_NULL_PTR(transform, NULL);
     psPlaneTransform *out = psAlloc(sizeof(psPlaneTransform));
 
@@ -286,5 +286,5 @@
                             const psObservatory* observatory)
 {
-    PS_CHECK_NULL_PTR_RETURN_NULL(observatory);
+    PS_CHECK_NULL_PTR(observatory, NULL);
     psExposure* exp = psAlloc(sizeof(psExposure));
 
@@ -463,5 +463,5 @@
 psGrommit* psGrommitAlloc(const psExposure* exp)
 {
-    PS_CHECK_NULL_PTR_RETURN_NULL(exp);
+    PS_CHECK_NULL_PTR(exp, NULL);
 
     double date = psTimeToMJD(exp->time);
@@ -493,6 +493,6 @@
                     const psFPA* FPA)
 {
-    PS_CHECK_NULL_PTR_RETURN_NULL(fpaCoord);
-    PS_CHECK_NULL_PTR_RETURN_NULL(FPA);
+    PS_CHECK_NULL_PTR(fpaCoord, NULL);
+    PS_CHECK_NULL_PTR(FPA, NULL);
     psChip* tmpChip = NULL;
     psPlane chipCoord;
@@ -517,7 +517,7 @@
                     const psFPA* FPA)
 {
-    PS_CHECK_NULL_PTR_RETURN_NULL(fpaCoord);
-    PS_CHECK_NULL_PTR_RETURN_NULL(FPA);
-    PS_CHECK_NULL_PTR_RETURN_NULL(FPA->chips);
+    PS_CHECK_NULL_PTR(fpaCoord, NULL);
+    PS_CHECK_NULL_PTR(FPA, NULL);
+    PS_CHECK_NULL_PTR(FPA->chips, NULL);
     psArray* chips = FPA->chips;
     psS32 nChips = chips->n;
@@ -545,6 +545,6 @@
                      const psChip* chip)
 {
-    PS_CHECK_NULL_PTR_RETURN_NULL(chipCoord);
-    PS_CHECK_NULL_PTR_RETURN_NULL(chip);
+    PS_CHECK_NULL_PTR(chipCoord, NULL);
+    PS_CHECK_NULL_PTR(chip, NULL);
 
     psPlane cellCoord;
@@ -588,6 +588,6 @@
                            const psCell* cell)
 {
-    PS_CHECK_NULL_PTR_RETURN_NULL(inCoord);
-    PS_CHECK_NULL_PTR_RETURN_NULL(cell);
+    PS_CHECK_NULL_PTR(inCoord, NULL);
+    PS_CHECK_NULL_PTR(cell, NULL);
 
     return (psPlaneTransformApply(outCoord, cell->toChip, inCoord));
@@ -598,6 +598,6 @@
                           const psChip* chip)
 {
-    PS_CHECK_NULL_PTR_RETURN_NULL(inCoord);
-    PS_CHECK_NULL_PTR_RETURN_NULL(chip);
+    PS_CHECK_NULL_PTR(inCoord, NULL);
+    PS_CHECK_NULL_PTR(chip, NULL);
 
     return (psPlaneTransformApply(outCoord, chip->toFPA, inCoord));
@@ -610,6 +610,6 @@
                         const psFPA* fpa)
 {
-    PS_CHECK_NULL_PTR_RETURN_NULL(inCoord);
-    PS_CHECK_NULL_PTR_RETURN_NULL(fpa);
+    PS_CHECK_NULL_PTR(inCoord, NULL);
+    PS_CHECK_NULL_PTR(fpa, NULL);
 
     return(psPlaneDistortApply(outCoord, fpa->toTangentPlane, inCoord,
@@ -624,6 +624,6 @@
                          const psGrommit* grommit)
 {
-    PS_CHECK_NULL_PTR_RETURN_NULL(tpCoord);
-    PS_CHECK_NULL_PTR_RETURN_NULL(grommit);
+    PS_CHECK_NULL_PTR(tpCoord, NULL);
+    PS_CHECK_NULL_PTR(grommit, NULL);
 
     double AOB = 0.0;
@@ -644,6 +644,6 @@
                           const psCell* cell)
 {
-    PS_CHECK_NULL_PTR_RETURN_NULL(cellCoord);
-    PS_CHECK_NULL_PTR_RETURN_NULL(cell);
+    PS_CHECK_NULL_PTR(cellCoord, NULL);
+    PS_CHECK_NULL_PTR(cell, NULL);
 
     return (psPlaneTransformApply(fpaCoord, cell->toFPA, cellCoord));
@@ -656,6 +656,6 @@
                            const psCell* cell)
 {
-    PS_CHECK_NULL_PTR_RETURN_NULL(cellCoord);
-    PS_CHECK_NULL_PTR_RETURN_NULL(cell);
+    PS_CHECK_NULL_PTR(cellCoord, NULL);
+    PS_CHECK_NULL_PTR(cell, NULL);
 
     psPlane* fpaCoord = NULL;
@@ -688,6 +688,6 @@
                                 const psCell* cell)
 {
-    PS_CHECK_NULL_PTR_RETURN_NULL(cellCoord);
-    PS_CHECK_NULL_PTR_RETURN_NULL(cell);
+    PS_CHECK_NULL_PTR(cellCoord, NULL);
+    PS_CHECK_NULL_PTR(cell, NULL);
 
     psPlane *tpCoord = NULL;
@@ -724,6 +724,6 @@
                         const psGrommit* grommit)
 {
-    PS_CHECK_NULL_PTR_RETURN_NULL(in);
-    PS_CHECK_NULL_PTR_RETURN_NULL(grommit);
+    PS_CHECK_NULL_PTR(in, NULL);
+    PS_CHECK_NULL_PTR(grommit, NULL);
 
     char* type = "RA";
@@ -745,6 +745,6 @@
                         const psFPA* fpa)
 {
-    PS_CHECK_NULL_PTR_RETURN_NULL(tpCoord);
-    PS_CHECK_NULL_PTR_RETURN_NULL(fpa);
+    PS_CHECK_NULL_PTR(tpCoord, NULL);
+    PS_CHECK_NULL_PTR(fpa, NULL);
 
     return (psPlaneDistortApply(fpaCoord, fpa->fromTangentPlane,
@@ -756,7 +756,7 @@
                           const psChip* chip)
 {
-    PS_CHECK_NULL_PTR_RETURN_NULL(fpaCoord);
-    PS_CHECK_NULL_PTR_RETURN_NULL(chip);
-    PS_CHECK_NULL_PTR_RETURN_NULL(chip->parent);
+    PS_CHECK_NULL_PTR(fpaCoord, NULL);
+    PS_CHECK_NULL_PTR(chip, NULL);
+    PS_CHECK_NULL_PTR(chip->parent, NULL);
 
     chipCoord = psPlaneTransformApply(chipCoord, chip->fromFPA, fpaCoord);
@@ -768,7 +768,7 @@
                            const psCell* cell)
 {
-    PS_CHECK_NULL_PTR_RETURN_NULL(chipCoord);
-    PS_CHECK_NULL_PTR_RETURN_NULL(cell);
-    PS_CHECK_NULL_PTR_RETURN_NULL(cell->parent);
+    PS_CHECK_NULL_PTR(chipCoord, NULL);
+    PS_CHECK_NULL_PTR(cell, NULL);
+    PS_CHECK_NULL_PTR(cell->parent, NULL);
 
     cellCoord = psPlaneTransformApply(cellCoord, cell->fromChip, chipCoord);
@@ -782,6 +782,6 @@
                           const psCell* cell)
 {
-    PS_CHECK_NULL_PTR_RETURN_NULL(skyCoord);
-    PS_CHECK_NULL_PTR_RETURN_NULL(cell);
+    PS_CHECK_NULL_PTR(skyCoord, NULL);
+    PS_CHECK_NULL_PTR(cell, NULL);
 
     psChip *parChip = cell->parent;
@@ -813,6 +813,6 @@
                                const psCell* cell)
 {
-    PS_CHECK_NULL_PTR_RETURN_NULL(skyCoord);
-    PS_CHECK_NULL_PTR_RETURN_NULL(cell);
+    PS_CHECK_NULL_PTR(skyCoord, NULL);
+    PS_CHECK_NULL_PTR(cell, NULL);
 
     psPlane *tpCoord = NULL;
Index: /trunk/psLib/src/astronomy/psCoord.c
===================================================================
--- /trunk/psLib/src/astronomy/psCoord.c	(revision 2205)
+++ /trunk/psLib/src/astronomy/psCoord.c	(revision 2206)
@@ -10,6 +10,6 @@
 *  @author George Gusciora, MHPCC
 *
-*  @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-10-27 00:57:30 $
+*  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-10-27 01:15:47 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -81,6 +81,6 @@
                                const psPlane* coords)
 {
-    PS_CHECK_NULL_PTR_RETURN_NULL(transform);
-    PS_CHECK_NULL_PTR_RETURN_NULL(coords);
+    PS_CHECK_NULL_PTR(transform, NULL);
+    PS_CHECK_NULL_PTR(coords, NULL);
     if (out == NULL) {
         out = (psPlane* ) psAlloc(sizeof(psPlane));
@@ -117,6 +117,6 @@
                              float magnitude)
 {
-    PS_CHECK_NULL_PTR_RETURN_NULL(transform);
-    PS_CHECK_NULL_PTR_RETURN_NULL(coords);
+    PS_CHECK_NULL_PTR(transform, NULL);
+    PS_CHECK_NULL_PTR(coords, NULL);
     if (out == NULL) {
         out = (psPlane* ) psAlloc(sizeof(psPlane));
@@ -156,6 +156,6 @@
                                  const psSphere* coord)
 {
-    PS_CHECK_NULL_PTR_RETURN_NULL(transform);
-    PS_CHECK_NULL_PTR_RETURN_NULL(coord);
+    PS_CHECK_NULL_PTR(transform, NULL);
+    PS_CHECK_NULL_PTR(coord, NULL);
     double sinY = 0.0;
     double cosY = 0.0;
@@ -228,6 +228,6 @@
                    const psProjection* projection)
 {
-    PS_CHECK_NULL_PTR_RETURN_NULL(coord);
-    PS_CHECK_NULL_PTR_RETURN_NULL(projection);
+    PS_CHECK_NULL_PTR(coord, NULL);
+    PS_CHECK_NULL_PTR(projection, NULL);
 
     float R = 0.0;
@@ -280,6 +280,6 @@
                       const psProjection* projection)
 {
-    PS_CHECK_NULL_PTR_RETURN_NULL(coord);
-    PS_CHECK_NULL_PTR_RETURN_NULL(projection);
+    PS_CHECK_NULL_PTR(coord, NULL);
+    PS_CHECK_NULL_PTR(projection, NULL);
 
     float R = 0.0;
@@ -348,6 +348,6 @@
                             psSphereOffsetUnit unit)
 {
-    PS_CHECK_NULL_PTR_RETURN_NULL(position1);
-    PS_CHECK_NULL_PTR_RETURN_NULL(position2);
+    PS_CHECK_NULL_PTR(position1, NULL);
+    PS_CHECK_NULL_PTR(position2, NULL);
 
     psPlane* lin;
@@ -416,6 +416,6 @@
                             psSphereOffsetUnit unit)
 {
-    PS_CHECK_NULL_PTR_RETURN_NULL(position);
-    PS_CHECK_NULL_PTR_RETURN_NULL(offset);
+    PS_CHECK_NULL_PTR(position, NULL);
+    PS_CHECK_NULL_PTR(offset, NULL);
 
     psPlane lin;
Index: /trunk/psLib/src/dataManip/psConstants.h
===================================================================
--- /trunk/psLib/src/dataManip/psConstants.h	(revision 2205)
+++ /trunk/psLib/src/dataManip/psConstants.h	(revision 2206)
@@ -6,6 +6,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:31 $
+ *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-10-27 01:15:47 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -94,44 +94,25 @@
 
 /** Preprocessor macro to generate error on an incorrect type */
-#define PS_CHECK_VECTOR_TYPE_RETURN_NULL(NAME, TYPE) \
+#define PS_CHECK_VECTOR_TYPE(NAME, TYPE, RVAL) \
 if (NAME->type.type != TYPE) { \
     psError(__func__,"Unallowable operation: %s has incorrect type.", #NAME); \
-    return(NULL); \
+    return(RVAL); \
 }
 
 /** Preprocessor macro to generate error on a NULL vector */
-#define PS_CHECK_NULL_VECTOR_RETURN_NULL(NAME) \
+#define PS_CHECK_NULL_VECTOR(NAME, RVAL) \
 if (NAME == NULL || NAME->data.V == NULL) { \
     psError(__func__,"Unallowable operation: %s or its data is NULL.", #NAME); \
-    return(NULL); \
-} \
-
-/** Preprocessor macro to generate error on a NULL vector */
-#define PS_CHECK_NULL_VECTOR_RETURN_F0(NAME) \
-if (NAME == NULL || NAME->data.V == NULL) { \
-    psError(__func__,"Unallowable operation: %s or its data is NULL.", #NAME); \
-    return(0.0); \
+    return(RVAL); \
 } \
 
 /** Preprocessor macro to generate error on a NULL poniter */
-#define PS_CHECK_NULL_PTR_RETURN_NULL(NAME) \
+#define PS_CHECK_NULL_PTR(NAME, RVAL) \
 if (NAME == NULL) { \
     psError(__func__,"Unallowable operation: %s is NULL.", #NAME); \
-    return(NULL); \
-}
-
-/** Preprocessor macro to generate error on a NULL poniter */
-#define PS_CHECK_NULL_PTR_RETURN_F0(NAME) \
-if (NAME == NULL) { \
-    psError(__func__,"Unallowable operation: %s is NULL.", #NAME); \
-    return(0.0); \
-}
-
-/** Preprocessor macro to generate error on a NULL poniter */
-#define PS_CHECK_NULL_PTR_RETURN_ZERO(NAME) \
-if (NAME == NULL) { \
-    psError(__func__,"Unallowable operation: %s is NULL.", #NAME); \
-    return(0); \
-}
+    return(RVAL); \
+}
+
+
 
 /** Preprocessor macro to generate error for zero length vector */
Index: /trunk/psLib/src/dataManip/psMinimize.c
===================================================================
--- /trunk/psLib/src/dataManip/psMinimize.c	(revision 2205)
+++ /trunk/psLib/src/dataManip/psMinimize.c	(revision 2206)
@@ -7,8 +7,8 @@
  *  fit a 1-D polynomial to a set of data points.
  *
- *  @author GLF, MHPCC
+ *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.61 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:31 $
+ *  @version $Revision: 1.62 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-10-27 01:15:47 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -252,6 +252,6 @@
     static psVector *yErr32Static = NULL;
 
-    PS_CHECK_NULL_PTR_RETURN_NULL(mySpline);
-    PS_CHECK_NULL_PTR_RETURN_NULL(y);
+    PS_CHECK_NULL_PTR(mySpline, NULL);
+    PS_CHECK_NULL_PTR(y, NULL);
     VECTOR_CHECK_TYPE_F32_OR_F64_RETURN_NULL(y);
     CONVERT_VECTOR_F64_TO_F32(y, y32, y32Static);
@@ -425,9 +425,9 @@
                         psMinimizeLMChi2Func func)
 {
-    PS_CHECK_NULL_PTR_RETURN_NULL(min);
-    PS_CHECK_NULL_VECTOR_RETURN_NULL(params);
+    PS_CHECK_NULL_PTR(min, NULL);
+    PS_CHECK_NULL_VECTOR(params, NULL);
     PS_CHECK_EMPTY_VECTOR_RETURN_NULL(params);
-    PS_CHECK_NULL_PTR_RETURN_NULL(x);
-    PS_CHECK_NULL_VECTOR_RETURN_NULL(y);
+    PS_CHECK_NULL_PTR(x, NULL);
+    PS_CHECK_NULL_VECTOR(y, NULL);
     PS_CHECK_EMPTY_VECTOR_RETURN_NULL(y);
     PS_CHECK_VECTOR_SIZE_EQUAL_RETURN_NULL(x, y);
@@ -856,5 +856,5 @@
     psPolynomial1D *tmpPoly;
     PS_CHECK_NULL_1DPOLY_RETURN_NULL(myPoly);
-    PS_CHECK_NULL_VECTOR_RETURN_NULL(y);
+    PS_CHECK_NULL_VECTOR(y, NULL);
     PS_CHECK_EMPTY_VECTOR_RETURN_NULL(y);
     psVector *x64 = NULL;
@@ -1319,9 +1319,9 @@
                         psMinimizePowellFunc func)
 {
-    PS_CHECK_NULL_VECTOR_RETURN_NULL(params);
+    PS_CHECK_NULL_VECTOR(params, NULL);
     PS_CHECK_EMPTY_VECTOR_RETURN_NULL(params);
-    PS_CHECK_NULL_PTR_RETURN_NULL(min);
-    PS_CHECK_NULL_PTR_RETURN_NULL(coords);
-    PS_CHECK_NULL_PTR_RETURN_NULL(func);
+    PS_CHECK_NULL_PTR(min, NULL);
+    PS_CHECK_NULL_PTR(coords, NULL);
+    PS_CHECK_NULL_PTR(func, NULL);
 
     psS32 numDims = params->n;
Index: /trunk/psLib/src/dataManip/psMinimize.h
===================================================================
--- /trunk/psLib/src/dataManip/psMinimize.h	(revision 2205)
+++ /trunk/psLib/src/dataManip/psMinimize.h	(revision 2206)
@@ -8,6 +8,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:31 $
+ *  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-10-27 01:15:47 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -88,4 +88,41 @@
                                   const psArray *x);
 
+/*
+psVector *psMinimizeLMChi2Gauss1D(psImage *deriv,
+                                  const psVector *params,
+                                  const psArray *coords)
+{
+    psVector *x = (psVector *) coords->data[0];
+    psVector *y = (psVector *) coords->data[1];
+    psVector *yErr = NULL;
+    int i;
+    int j;
+    float normalization = params->data.F32[0];
+    float center = params->data.F32[1];
+    float stdev = params->data.F32[2];
+    psVector *out = psVectorAlloc(x->n, PS_TYPE_F32);
+ 
+ 
+    if (deriv == NULL) {
+        deriv = psImageAlloc(params->n, x->n, PS_TYPE_F32);
+    }
+ 
+    if (coords->n == 2) {
+        yErr = (psVector *) coords->data[2];
+    }
+ 
+    for (i=0;i<x->n;i++) {
+        out->data.F32[i] = psGaussian(x->data.F32[i], center, stdev, 1);
+    }
+ 
+    for (i=0;i<x->n;i++) {
+        for (j=0;j<params->n;j++) {
+            deriv->data.F32[i][j] = the derivative of the gaussian w.r.t. the j-th parameter at the coord x[i]
+        }
+    }
+    return(out);
+}
+*/
+
 psBool psMinimizeLMChi2(psMinimization *min,
                         psImage *covar,
Index: /trunk/psLib/src/dataManip/psStats.c
===================================================================
--- /trunk/psLib/src/dataManip/psStats.c	(revision 2205)
+++ /trunk/psLib/src/dataManip/psStats.c	(revision 2206)
@@ -9,6 +9,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.69 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:31 $
+ *  @version $Revision: 1.70 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-10-27 01:15:47 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -1733,5 +1733,5 @@
         return(stats);
     }
-    PS_CHECK_NULL_PTR_RETURN_NULL(stats);
+    PS_CHECK_NULL_PTR(stats, NULL);
 
     inF32 = p_psConvertToF32((psVector *) in);
@@ -1747,5 +1747,5 @@
     if (mask != NULL) {
         PS_CHECK_VECTOR_SIZE_EQUAL_RETURN_NULL(mask, in);
-        PS_CHECK_VECTOR_TYPE_RETURN_NULL(mask, PS_TYPE_U8);
+        PS_CHECK_VECTOR_TYPE(mask, PS_TYPE_U8, NULL);
     }
     // ************************************************************************
Index: /trunk/psLib/src/image/psImageStats.c
===================================================================
--- /trunk/psLib/src/image/psImageStats.c	(revision 2205)
+++ /trunk/psLib/src/image/psImageStats.c	(revision 2206)
@@ -9,6 +9,6 @@
 *  @author GLG, MHPCC
 *
-*  @version $Revision: 1.44 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-10-27 00:57:31 $
+*  @version $Revision: 1.45 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-10-27 01:15:47 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -101,5 +101,5 @@
     NOTE: We assume that the psHistogram structure out has already been
     allocated and initialized.
-    NOTE: verify that image/mask have the, correct types and  sizes.
+    NOTE: verify that image/mask have the correct types and sizes.
  *****************************************************************************/
 psHistogram* psImageHistogram(psHistogram* out,
@@ -112,6 +112,6 @@
 
     // NOTE: Verify this action.
-    PS_CHECK_NULL_PTR_RETURN_NULL(out);
-    PS_CHECK_NULL_PTR_RETURN_NULL(in);
+    PS_CHECK_NULL_PTR(out, NULL);
+    PS_CHECK_NULL_PTR(in, NULL);
 
     junkData = psAlloc(sizeof(psVector));
@@ -171,5 +171,5 @@
 p_psCalcScaleFactorsEval(n): The Chebyshev polynomials are defined over the
 interval [-1.0 : 1.0].  Images typically have sizes of 512x512 or more.  In
-order to use Chebyshev polynomials, we must scales the coordinates from
+order to use Chebyshev polynomials, we must scale the coordinates from
 0:512 to -1:1.  This routine takes as input an integer N and produces as
 output a vector of evenly spaced floating point values between -1.0:1.0.
Index: /trunk/psLib/src/imageops/psImageStats.c
===================================================================
--- /trunk/psLib/src/imageops/psImageStats.c	(revision 2205)
+++ /trunk/psLib/src/imageops/psImageStats.c	(revision 2206)
@@ -9,6 +9,6 @@
 *  @author GLG, MHPCC
 *
-*  @version $Revision: 1.44 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-10-27 00:57:31 $
+*  @version $Revision: 1.45 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-10-27 01:15:47 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -101,5 +101,5 @@
     NOTE: We assume that the psHistogram structure out has already been
     allocated and initialized.
-    NOTE: verify that image/mask have the, correct types and  sizes.
+    NOTE: verify that image/mask have the correct types and sizes.
  *****************************************************************************/
 psHistogram* psImageHistogram(psHistogram* out,
@@ -112,6 +112,6 @@
 
     // NOTE: Verify this action.
-    PS_CHECK_NULL_PTR_RETURN_NULL(out);
-    PS_CHECK_NULL_PTR_RETURN_NULL(in);
+    PS_CHECK_NULL_PTR(out, NULL);
+    PS_CHECK_NULL_PTR(in, NULL);
 
     junkData = psAlloc(sizeof(psVector));
@@ -171,5 +171,5 @@
 p_psCalcScaleFactorsEval(n): The Chebyshev polynomials are defined over the
 interval [-1.0 : 1.0].  Images typically have sizes of 512x512 or more.  In
-order to use Chebyshev polynomials, we must scales the coordinates from
+order to use Chebyshev polynomials, we must scale the coordinates from
 0:512 to -1:1.  This routine takes as input an integer N and produces as
 output a vector of evenly spaced floating point values between -1.0:1.0.
Index: /trunk/psLib/src/math/psConstants.h
===================================================================
--- /trunk/psLib/src/math/psConstants.h	(revision 2205)
+++ /trunk/psLib/src/math/psConstants.h	(revision 2206)
@@ -6,6 +6,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:31 $
+ *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-10-27 01:15:47 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -94,44 +94,25 @@
 
 /** Preprocessor macro to generate error on an incorrect type */
-#define PS_CHECK_VECTOR_TYPE_RETURN_NULL(NAME, TYPE) \
+#define PS_CHECK_VECTOR_TYPE(NAME, TYPE, RVAL) \
 if (NAME->type.type != TYPE) { \
     psError(__func__,"Unallowable operation: %s has incorrect type.", #NAME); \
-    return(NULL); \
+    return(RVAL); \
 }
 
 /** Preprocessor macro to generate error on a NULL vector */
-#define PS_CHECK_NULL_VECTOR_RETURN_NULL(NAME) \
+#define PS_CHECK_NULL_VECTOR(NAME, RVAL) \
 if (NAME == NULL || NAME->data.V == NULL) { \
     psError(__func__,"Unallowable operation: %s or its data is NULL.", #NAME); \
-    return(NULL); \
-} \
-
-/** Preprocessor macro to generate error on a NULL vector */
-#define PS_CHECK_NULL_VECTOR_RETURN_F0(NAME) \
-if (NAME == NULL || NAME->data.V == NULL) { \
-    psError(__func__,"Unallowable operation: %s or its data is NULL.", #NAME); \
-    return(0.0); \
+    return(RVAL); \
 } \
 
 /** Preprocessor macro to generate error on a NULL poniter */
-#define PS_CHECK_NULL_PTR_RETURN_NULL(NAME) \
+#define PS_CHECK_NULL_PTR(NAME, RVAL) \
 if (NAME == NULL) { \
     psError(__func__,"Unallowable operation: %s is NULL.", #NAME); \
-    return(NULL); \
-}
-
-/** Preprocessor macro to generate error on a NULL poniter */
-#define PS_CHECK_NULL_PTR_RETURN_F0(NAME) \
-if (NAME == NULL) { \
-    psError(__func__,"Unallowable operation: %s is NULL.", #NAME); \
-    return(0.0); \
-}
-
-/** Preprocessor macro to generate error on a NULL poniter */
-#define PS_CHECK_NULL_PTR_RETURN_ZERO(NAME) \
-if (NAME == NULL) { \
-    psError(__func__,"Unallowable operation: %s is NULL.", #NAME); \
-    return(0); \
-}
+    return(RVAL); \
+}
+
+
 
 /** Preprocessor macro to generate error for zero length vector */
Index: /trunk/psLib/src/math/psMinimize.c
===================================================================
--- /trunk/psLib/src/math/psMinimize.c	(revision 2205)
+++ /trunk/psLib/src/math/psMinimize.c	(revision 2206)
@@ -7,8 +7,8 @@
  *  fit a 1-D polynomial to a set of data points.
  *
- *  @author GLF, MHPCC
+ *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.61 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:31 $
+ *  @version $Revision: 1.62 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-10-27 01:15:47 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -252,6 +252,6 @@
     static psVector *yErr32Static = NULL;
 
-    PS_CHECK_NULL_PTR_RETURN_NULL(mySpline);
-    PS_CHECK_NULL_PTR_RETURN_NULL(y);
+    PS_CHECK_NULL_PTR(mySpline, NULL);
+    PS_CHECK_NULL_PTR(y, NULL);
     VECTOR_CHECK_TYPE_F32_OR_F64_RETURN_NULL(y);
     CONVERT_VECTOR_F64_TO_F32(y, y32, y32Static);
@@ -425,9 +425,9 @@
                         psMinimizeLMChi2Func func)
 {
-    PS_CHECK_NULL_PTR_RETURN_NULL(min);
-    PS_CHECK_NULL_VECTOR_RETURN_NULL(params);
+    PS_CHECK_NULL_PTR(min, NULL);
+    PS_CHECK_NULL_VECTOR(params, NULL);
     PS_CHECK_EMPTY_VECTOR_RETURN_NULL(params);
-    PS_CHECK_NULL_PTR_RETURN_NULL(x);
-    PS_CHECK_NULL_VECTOR_RETURN_NULL(y);
+    PS_CHECK_NULL_PTR(x, NULL);
+    PS_CHECK_NULL_VECTOR(y, NULL);
     PS_CHECK_EMPTY_VECTOR_RETURN_NULL(y);
     PS_CHECK_VECTOR_SIZE_EQUAL_RETURN_NULL(x, y);
@@ -856,5 +856,5 @@
     psPolynomial1D *tmpPoly;
     PS_CHECK_NULL_1DPOLY_RETURN_NULL(myPoly);
-    PS_CHECK_NULL_VECTOR_RETURN_NULL(y);
+    PS_CHECK_NULL_VECTOR(y, NULL);
     PS_CHECK_EMPTY_VECTOR_RETURN_NULL(y);
     psVector *x64 = NULL;
@@ -1319,9 +1319,9 @@
                         psMinimizePowellFunc func)
 {
-    PS_CHECK_NULL_VECTOR_RETURN_NULL(params);
+    PS_CHECK_NULL_VECTOR(params, NULL);
     PS_CHECK_EMPTY_VECTOR_RETURN_NULL(params);
-    PS_CHECK_NULL_PTR_RETURN_NULL(min);
-    PS_CHECK_NULL_PTR_RETURN_NULL(coords);
-    PS_CHECK_NULL_PTR_RETURN_NULL(func);
+    PS_CHECK_NULL_PTR(min, NULL);
+    PS_CHECK_NULL_PTR(coords, NULL);
+    PS_CHECK_NULL_PTR(func, NULL);
 
     psS32 numDims = params->n;
Index: /trunk/psLib/src/math/psMinimize.h
===================================================================
--- /trunk/psLib/src/math/psMinimize.h	(revision 2205)
+++ /trunk/psLib/src/math/psMinimize.h	(revision 2206)
@@ -8,6 +8,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:31 $
+ *  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-10-27 01:15:47 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -88,4 +88,41 @@
                                   const psArray *x);
 
+/*
+psVector *psMinimizeLMChi2Gauss1D(psImage *deriv,
+                                  const psVector *params,
+                                  const psArray *coords)
+{
+    psVector *x = (psVector *) coords->data[0];
+    psVector *y = (psVector *) coords->data[1];
+    psVector *yErr = NULL;
+    int i;
+    int j;
+    float normalization = params->data.F32[0];
+    float center = params->data.F32[1];
+    float stdev = params->data.F32[2];
+    psVector *out = psVectorAlloc(x->n, PS_TYPE_F32);
+ 
+ 
+    if (deriv == NULL) {
+        deriv = psImageAlloc(params->n, x->n, PS_TYPE_F32);
+    }
+ 
+    if (coords->n == 2) {
+        yErr = (psVector *) coords->data[2];
+    }
+ 
+    for (i=0;i<x->n;i++) {
+        out->data.F32[i] = psGaussian(x->data.F32[i], center, stdev, 1);
+    }
+ 
+    for (i=0;i<x->n;i++) {
+        for (j=0;j<params->n;j++) {
+            deriv->data.F32[i][j] = the derivative of the gaussian w.r.t. the j-th parameter at the coord x[i]
+        }
+    }
+    return(out);
+}
+*/
+
 psBool psMinimizeLMChi2(psMinimization *min,
                         psImage *covar,
Index: /trunk/psLib/src/math/psStats.c
===================================================================
--- /trunk/psLib/src/math/psStats.c	(revision 2205)
+++ /trunk/psLib/src/math/psStats.c	(revision 2206)
@@ -9,6 +9,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.69 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:31 $
+ *  @version $Revision: 1.70 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-10-27 01:15:47 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -1733,5 +1733,5 @@
         return(stats);
     }
-    PS_CHECK_NULL_PTR_RETURN_NULL(stats);
+    PS_CHECK_NULL_PTR(stats, NULL);
 
     inF32 = p_psConvertToF32((psVector *) in);
@@ -1747,5 +1747,5 @@
     if (mask != NULL) {
         PS_CHECK_VECTOR_SIZE_EQUAL_RETURN_NULL(mask, in);
-        PS_CHECK_VECTOR_TYPE_RETURN_NULL(mask, PS_TYPE_U8);
+        PS_CHECK_VECTOR_TYPE(mask, PS_TYPE_U8, NULL);
     }
     // ************************************************************************
