int nllsqfit(xdat, xdim, ydat, wdat, ddat, ndat, fpar, epar, mpar, npar, tol, its, lab, f, df) int nr_nllsqfit(xdat, xdim, ydat, wdat, ddat, ndat, fpar, epar, mpar, npar, tol, its, lab, f, df) real *xdat, *ydat, *wdat, *ddat, *fpar, *epar, tol, lab; int xdim, ndat, *mpar, npar, its; rproc f; iproc df;
nllsqfit returns number
of iterations needed to achieve convergence according to tol.  When this
number is negative, the fitting was not continued because a fatal error
occurred: 
    -1     Too many free parameters, maximum "#define MAXPAR 32".
    -2     No free parameters.
    -3     Not enough degrees of freedom.
    -4     Too many iterations to get a solution which satisfies tol.
    -5     Diagonal of matrix contains elements which are zero, or less.
    -6     Determinant of the coefficient matrix is zero.
    -7     Square root of negative number.
A linear fit (lab=0) returns 0. nr_nllsqfit is a wrapper routine with the same calling sequence, but calls the (NEMO adapted) Numerical Recipes routine mrqmin() and its helper functions.
      real func(xdat, fpar, npar)
      func          returns the function value of the function to be fitted.
      real xdat[]   (input) coordinate(s) of data point.
      real fpar[]   (input) parameter list.
      int  npar     (input) number of parameters.
      void derv(xdat, fpar, dpar, npar)
 
       real xdat[]   (input) coordinate(s) of data point.
       real fpar[]   (input) parameter list.
       real dpar[]   (output) partial derivatives to the parameters of
the
                              function to be fitted.
       int  npar     (input) number of parameters.
 
    real func(real *xdat, real *fpar, int npar)
    {
        return fpar[0] * (*xdat) + fpar[1];
    }
              
    void derv(real *xdat, real *fpar, real *dpar, int npar)
    {
        dpar[0] = *xdat;
        dpar[1] = 1.0;
    }
May 7, 1990 Document created(KGB), document refereed(MXV) Apr 30, 1991 NEMO version written for rotcur, as old PJT July 23, 1992 manual page written PJT Aug 20, 1992 turbocharged getvec() considerably PJT July 12, 2002 allow ’wdat’ to be a NULL vector if all weights the same PJT