Index: trunk/psLib/src/math/psMinimizeLMM.c
===================================================================
--- trunk/psLib/src/math/psMinimizeLMM.c	(revision 6215)
+++ trunk/psLib/src/math/psMinimizeLMM.c	(revision 6226)
@@ -10,6 +10,6 @@
  *  @author EAM, IfA
  *
- *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-01-26 21:10:22 $
+ *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-01-27 20:08:58 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -277,4 +277,6 @@
 NOTES: EAM: this is my re-implementation of MinLM
  
+XXX: Must implement code to handle the constrain->min, ->max, ->delta members.
+ 
 XXX: Put the ASSERTS in.
  
@@ -283,4 +285,5 @@
      will have to convert all F32 input vectors to F64 regardless.  So,
      the F64 port might be.
+ 
   *****************************************************************************/
 psBool psMinimizeLMChi2(
@@ -288,5 +291,5 @@
     psImage *covar,
     psVector *params,
-    const psVector *paramMask,
+    psMinConstrain *constrain,
     const psArray *x,
     const psVector *y,
@@ -300,7 +303,20 @@
     PS_ASSERT_VECTOR_NON_EMPTY(params, false);
     PS_ASSERT_VECTOR_TYPE(params, PS_TYPE_F32, false);
-    if (paramMask != NULL) {
-        PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_U8, false);
-        PS_ASSERT_VECTORS_SIZE_EQUAL(params, paramMask, false);
+    psVector *paramMask = NULL;
+    if (constrain != NULL) {
+        paramMask = constrain->paramMask;
+        if (paramMask != NULL) {
+            PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_U8, false);
+            PS_ASSERT_VECTORS_SIZE_EQUAL(params, paramMask, false);
+        }
+        if (constrain->paramMin != NULL) {
+            psLogMsg(__func__, PS_LOG_WARN, "WARNING: the constrain->paramMin vector is currently ignored.\n");
+        }
+        if (constrain->paramMax != NULL) {
+            psLogMsg(__func__, PS_LOG_WARN, "WARNING: the constrain->paramMax vector is currently ignored.\n");
+        }
+        if (constrain->paramDelta != NULL) {
+            psLogMsg(__func__, PS_LOG_WARN, "WARNING: the constrain->paramDelta vector is currently ignored.\n");
+        }
     }
     PS_ASSERT_PTR_NON_NULL(x, false);
@@ -592,2 +608,24 @@
     return( psMemGetDeallocator(ptr) == (psFreeFunc)minimizationFree );
 }
+
+
+static void constrainFree(psMinConstrain *tmp)
+{
+    // There are no dynamically allocated items
+}
+
+psMinConstrain* psMinConstrainAlloc()
+{
+    psMinConstrain *tmp = psAlloc(sizeof(psMinConstrain));
+    tmp->paramMask = NULL;
+    tmp->paramMax = NULL;
+    tmp->paramMin = NULL;
+    tmp->paramDelta = NULL;
+
+    return(tmp);
+}
+
+bool psMemCheckConstrain(psPtr tmp)
+{
+    return( psMemGetDeallocator(tmp) == (psFreeFunc)constrainFree );
+}
Index: trunk/psLib/src/math/psMinimizeLMM.h
===================================================================
--- trunk/psLib/src/math/psMinimizeLMM.h	(revision 6215)
+++ trunk/psLib/src/math/psMinimizeLMM.h	(revision 6226)
@@ -8,6 +8,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-01-23 20:44:29 $
+ *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-01-27 20:08:58 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -52,7 +52,22 @@
 psMinimization;
 
+
+/** A data structure for minimization routines.
+ *
+ *  
+ */
+typedef struct
+{
+    psVector *paramMask;                ///< valid / invalid parameters
+    psVector *paramMax;                 ///< max allowed parameters
+    psVector *paramMin;                 ///< min allowed parameters
+    psVector *paramDelta;               ///< max allowed param swing
+}
+psMinConstrain;
+
+psMinConstrain *psMinConstrainAlloc();
+
 #define P_PSMINIMIZATION_SET_MAXITER(m,val) *(int*)&m->maxIter = val
         #define P_PSMINIMIZATION_SET_TOL(m,val) *(float*)&m->tol = val
-
 
                 /** Allocates a psMinimization structure.
@@ -97,5 +112,5 @@
     psImage *covar,                    ///< Covariance matrix
     psVector *params,                  ///< "Best Guess" for the parameters that minimize func
-    const psVector *paramMask,         ///< Parameters to be held fixed by the minimizer
+    psMinConstrain *constrain,         ///< Constraints on the parameters
     const psArray *x,                  ///< Measurement ordinates of multiple vectors
     const psVector *y,                 ///< Measurement coordinates
Index: trunk/psLib/src/math/psMinimizePolyFit.c
===================================================================
--- trunk/psLib/src/math/psMinimizePolyFit.c	(revision 6215)
+++ trunk/psLib/src/math/psMinimizePolyFit.c	(revision 6226)
@@ -10,6 +10,6 @@
  *  @author EAM, IfA
  *
- *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-01-26 21:10:22 $
+ *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-01-27 20:08:58 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -1032,13 +1032,13 @@
     psF32 minClipSigma;
     psF32 maxClipSigma;
-    if (isnan(stats->max) || isfinite(stats->max)) {
+    if (isfinite(stats->max)) {
+        maxClipSigma = fabs(stats->max);
+    } else {
         maxClipSigma = fabs(stats->clipSigma);
-    } else {
-        maxClipSigma = fabs(stats->max);
-    }
-    if (isnan(stats->min) || isfinite(stats->min)) {
+    }
+    if (isfinite(stats->min)) {
+        minClipSigma = fabs(stats->min);
+    } else {
         minClipSigma = fabs(stats->clipSigma);
-    } else {
-        minClipSigma = fabs(stats->min);
     }
 
