Index: trunk/psLib/src/math/psMinimize.h
===================================================================
--- trunk/psLib/src/math/psMinimize.h	(revision 1992)
+++ trunk/psLib/src/math/psMinimize.h	(revision 2197)
@@ -8,6 +8,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-06 23:38:49 $
+ *  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-10-26 21:24:43 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -84,5 +84,82 @@
 
 
+/*
+   Bug 203:
+ 
+typedef float (*psMinimizeLMChi2Func)(psVector *deriv, const psVector *params,
+const psVector *x);
+ 
+This function takes the current guess for the parameters for which we are
+trying to get the best values (params), and a single vector (x) of
+conditions from the array of x values fed into the minimiser.
+ 
+    bool psMinimizeLMChi2(psMinimization *min,
+                          psImage *covar,
+                          psVector *params,
+                          const psVector *paramMask,
+                          const psArray *x,
+                          const psVector *y,
+                          const psVector *yErr,
+                          psMinimizeLMChi2Func func);
+ 
+This takes the minimization specs (min), returns the covariance matrix
+(covar), takes the best guess of initial parameters (params), the parameter
+mask (paramMask), and takes multiple vectors of conditions in an array (x),
+the corresponding measured values (y) and errors (yErr) and the function to
+fit (func).
+ 
+For example, for GRB afterglows, I have flux as a function of time and
+frequency.  So I stuff into the "psArray *x" all my time and frequency values
+(so a whole heap of vectors of size 2), I have the measured values in "y" and
+errors in "yErr".  Then each of the time-frequency pairs are passed to my model
+function with the current parameters, and the model function returns the flux
+for that time-frequency pair, and the derivative with respect to each of the
+parameters.
+ 
+This seems reasonable.  The only thing we could change would be to have the
+function be defined:
+ 
+typedef psVector* (*psMinimizeLMChi2Func)(psImage *deriv,
+                                          const psVector *params,
+                                          const psArray *x);
+ 
+So it would return the model value for each of the measurements at once, and
+return for each the derivatives (so that it returns a matrix).
+ 
+What do you think?
+ 
+ 
+ 
+I'm not sure I understand how LM chi-squared minimization will work with the
+following function that you define:
+ 
+    typedef psVector* (*psMinimizeLMChi2Func)(psImage *deriv,
+                                              const psVector *params,
+                                              const psArray *x);
+ 
+The chi-squared minimization algorithm, as defined in NR, requires that
+function to be minimized be evaluated at each data point, and that all
+derivatives, with respect to each parameter, be calculated at each data
+point.  In the above, can I assume that
+ 
+    x is an array of psVectors, with each vector corresponding to a single
+ data point.
+ 
+    The returned value has the same length as x.  It contains the value of
+ the function at each data point in x.
+ 
+    deriv: an n-by-p matrix where "n" is the number of data points, and "p"
+ is the number of parameters.  The [i][j] element of this matrix
+ holds the derivative of the function at the i-th data point with
+ respect to the j-th parameter.
+ 
+ 
+ 
+*/
+
+
 // XXX: What if any of these arguments are NULL?
+
+
 typedef
 float (*psMinimizeLMChi2Func)(psVector *deriv,
@@ -98,4 +175,19 @@
                       psMinimizeLMChi2Func func);
 
+
+typedef
+psVector* (*psMyMinimizeLMChi2Func)(psImage *deriv,
+                                    const psVector *params,
+                                    const psArray *x);
+
+bool psMyMinimizeLMChi2(psMinimization *min,
+                        psImage *covar,
+                        psVector *params,
+                        const psVector *paramMask,
+                        const psArray *x,
+                        const psVector *y,
+                        const psVector *yErr,
+                        psMyMinimizeLMChi2Func func);
+
 typedef
 float (*psMinimizePowellFunc)(const psVector *params,
