#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 2 (of 4)."
# Contents:  ./Doc/simplex.1 ./Ldh/ldhfit.test1 ./Lib/simpfit.c
#   ./Lib/simplib0.c ./Line/linefit.test ./assign/dataset3
#   ./assign/dataset4 ./mmfit/data.sample ./mmfit/mmfit.dat
#   ./mmfit/recip_nowt.c ./mmfit/recipfit.c
# Wrapped by local@rupley on Wed Nov 21 00:30:54 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f './Doc/simplex.1' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'./Doc/simplex.1'\"
else
echo shar: Extracting \"'./Doc/simplex.1'\" \(4922 characters\)
sed "s/^X//" >'./Doc/simplex.1' <<'END_OF_FILE'
X.TH SIMPLEX 1
X.SH SIMPLEX
simplex, simpfit \- Nelder-Mead simplex minimization for parameter estimates with standard deviations
X.SH SYNOPSIS
X.B xxxxfit
X[
X.B -s 
X{a|c|l|n}
X] [
X.B -d 
X{a|c|l|n}
X] [ [
X.B -i
X] 
inputfile ] [ [
X.B -o
X] diskfile ]
X.SH DESCRIPTION
A model function explicitly relating a dependent variable to
one or more independent variables and variable
parameters is fit to a set of data points (observed values of 
dependent and independent variables).  
The Nelder-Mead algorithm
is used to locate the least squares minimum by a simplex search
procedure, giving estimates of the best-fit values of the
parameters of the model function.
Standard deviations of the parameters are estimated
by use of a quadratic approximation of the least squares surface
near the minimum.  
The quadratic approximation, equivalent to
minimization by use of a Taylor's series approximation, 
returns improved parameter estimates.
Thus the
quadratic approximation can be used as part of the minimization
procedure.
X.PP
Alternation of a cycle of simplex
minimization, consisting of perhaps 30 iterations,
with a cycle of quadratic minimization is an effective strategy.
The simplex search
efficiently defines the region of parameter space that contains
the minimum; bounds are easily incorporated; because derivatives
are not used, ill-behaved functions can be handled.  
The quadratic minimization, on the other hand, efficiently finds the
least squares minimum, but it is reliable only when near the minimum.
If the quadratic minimization fails, 
as it often will in the early stages of the search, 
considerable time is wasted, to reduce which, 
the next one or several cycles of quadratic minimization can be skipped 
after a failure.
X.PP
The files
X.B input.doc
and
X.B output.doc
should be read for details of the entry of data and interpretation of
output.
X.PP
Several routines have to be recoded for each new model function.
X(1) 
X.B func()
calculates for a simplex vertex (for the set of parameter values passed
to it): (a) the value of the dependent variable for each data point
and (b) the least squares function (the weighted sum of residuals squared)
over all data points.
Bounds on parameters can be implemented easily, by a test that returns an
excessively large least squares function value (e.g., 1.E38).  
Code should be efficient; most of the minimization is spent in 
X.B func().
X(2) The print statement of  
X.B fdatprint(),
which lists calculated and input values for the set of data points,
may have to
be recoded after change in the function or data.
X.B fdatprint()
calls 
X.B fpointprint(), 
which gives additional customizable data-related output.
X(3) 
X.B fspecial()
controls a customizable display
printed after the standard display at the end of each iteration of the
simplex minimization.
X.SS "COMMAND LINE OPTIONS"
X.B -s 
X{a|c|l|n}  --  control output to terminal; default is all possible output (
X.B a 
X):
X.in +5
X.sp
X.B a 
X= ALL possible output; information tracking each iteration of the
simplex minimization is displayed.
X.sp
X.B c 
X= summary output each CYCLE of perhaps 30 iterations; any output from
a quadratic minimization is displayed at this point.
X.sp
X.B l 
X= summary output on LAST cycle only; 
X.sp
X.B n 
X= NO output;
X.in
X.sp
X.B -d 
X{a|c|l|n}  --  control output to 
X.B diskfile, 
with options as for control of terminal output;
default is summary output (
X.B c 
X):
X.sp
X[
X.B -i
X] 
X.B inputfile  
X--  specify input file; default is stdin.
X.sp
X[
X.B -o
X] 
X.B diskfile  
X--  specify output file; default is /dev/null,
i.e., no output is saved unless requested.
X.sp
The input file has the following structure:
X.in +5
X.sp
one-line title, with no tabs or ctrl characters;
X.sp
lines following give control variables, the starting simplex,
and the data array;
X.sp
the order of entry is fixed by the order in 
X.B read_data();
see sample data file for structure, and also the description in 
X.B input.doc;
X.sp
the one-word descriptors must be present in the data file;
the data format is otherwise free-form;
X.sp
comments at the end of the file are not read by the program
X.SH FILES
The files
X.B linefit.c
and
X.B ldhfit.c
are examples of coding for specific functions.
X.PP
The files
X.B linefit.dat
and
X.B ldhfit.dat
are sample input files, with typical values of the control variables.
X.PP
There are several documentation files:
X.B Simplex.doc 
describes the Nelder-Mead algorithm and the mechanics of the
quadratic fit.
X.B Output.doc 
describes the full (
X.B a 
option)
output for the minimization.
X.B Input.doc
is a template file, showing the style of data entry, with comments.
X.B Data_redn.doc 
contains low-level comments on data reduction and a
description of the model coded in 
X.B ldhfit.c.
X.SH AUTHOR
J. A. Rupley, Tucson, Arizona
X.br
rupley!local@megaron.arizona.edu
X.SH BUGS
There are limits, set in
X.B simpdefs.h,
on the number of parameters, data points, and variables for each data point.
X
END_OF_FILE
if test 4922 -ne `wc -c <'./Doc/simplex.1'`; then
    echo shar: \"'./Doc/simplex.1'\" unpacked with wrong size!
fi
# end of './Doc/simplex.1'
fi
if test -f './Ldh/ldhfit.test1' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'./Ldh/ldhfit.test1'\"
else
echo shar: Extracting \"'./Ldh/ldhfit.test1'\" \(5843 characters\)
sed "s/^X//" >'./Ldh/ldhfit.test1' <<'END_OF_FILE'
X
wednesday 1989, group 3, soaring bear and julianne ruterman
X
summary of simplex fitting results:
iteration number 398
X
simplex:
vertex = 0   function value = 1.41445213821802e-04
X   2.0725372066e-01   2.9591207538e-02   3.8790844029e-01   2.8238485629e-03
X     7.4934730526e-03   1.8932288333e-03   1.0000000000e-10
vertex = 1   function value = 1.41445215483916e-04
X   2.0725236057e-01   2.9591848835e-02   3.8790861304e-01   2.8238380122e-03
X     7.4933965668e-03   1.8931637403e-03   1.0000000000e-10
vertex = 2   function value = 1.41445215648246e-04
X   2.0725210976e-01   2.9591326172e-02   3.8789443032e-01   2.8238909667e-03
X     7.4931593264e-03   1.8934405280e-03   1.0000000000e-10
vertex = 3   function value = 1.41445212623025e-04
X   2.0725253973e-01   2.9591228961e-02   3.8791076926e-01   2.8239131657e-03
X     7.4935660242e-03   1.8929660348e-03   1.0000000000e-10
vertex = 4   function value = 1.41445215152122e-04
X   2.0725218027e-01   2.9591242636e-02   3.8791020011e-01   2.8238760793e-03
X     7.4928081536e-03   1.8934498779e-03   1.0000000000e-10
vertex = 5   function value = 1.41445213818549e-04
X   2.0725211767e-01   2.9591207861e-02   3.8790834587e-01   2.8238545637e-03
X     7.4933664785e-03   1.8935357407e-03   1.0000000000e-10
vertex = 6   function value = 1.41445211834028e-04
X   2.0724805648e-01   2.9590086966e-02   3.8789460139e-01   2.8239192604e-03
X     7.4933492996e-03   1.8932042272e-03   1.0000000000e-10
X
centroid:
function value = 1.41445212067139e-04
X   2.0725186931e-01   2.9591164138e-02   3.8790505719e-01   2.8238772301e-03
X     7.4933027002e-03   1.8932841403e-03   1.0000000000e-10
mean=1.41445214054527e-04 rms=1.35633277181824e-12 test=9.58910332091811e-09
root mean square weighted error of best fit to data = 2.53561192035328e-03
X
X
wednesday 1989, group 3, soaring bear and julianne ruterman
X
iteration number 398
X
X        yobs   ycalc   del-y  weight       a         b         p
X   1   0.024   0.026  -0.002   1.000    0.01100    0.15000    0.00000
X   2   0.025   0.030  -0.005   0.000    0.01500    0.15000    0.00000
X   3   0.036   0.036   0.000   1.000    0.02200    0.15000    0.00000
X   4   0.040   0.042  -0.002   1.000    0.03500    0.15000    0.00000
X   5   0.034   0.031   0.003   1.000    0.01100    0.22000    0.00000
X   6   0.036   0.037  -0.001   1.000    0.01500    0.22000    0.00000
X   7   0.043   0.044  -0.001   1.000    0.02200    0.22000    0.00000
X   8   0.052   0.052   0.000   1.000    0.03500    0.22000    0.00000
X   9   0.039   0.037   0.002   1.000    0.01100    0.35000    0.00000
X  10   0.045   0.045   0.000   1.000    0.01500    0.35000    0.00000
X  11   0.054   0.054   0.000   1.000    0.02200    0.35000    0.00000
X  12   0.067   0.065   0.002   1.000    0.03500    0.35000    0.00000
X  13   0.046   0.045   0.001   1.000    0.01100    0.70000    0.00000
X  14   0.056   0.055   0.001   1.000    0.01500    0.70000    0.00000
X  15   0.065   0.067  -0.002   1.000    0.02200    0.70000    0.00000
X  16   0.087   0.082   0.005   1.000    0.03500    0.70000    0.00000
X  17   0.020   0.026  -0.006   0.000    0.01100    0.15000    0.00000
X  18   0.043   0.042   0.001   1.000    0.03500    0.15000    0.00000
X  19   0.043   0.045  -0.002   1.000    0.01100    0.70000    0.00000
X  20   0.078   0.082  -0.004   1.000    0.03500    0.70000    0.00000
X  21   0.022   0.019   0.003   1.000    0.03500    0.15000  150.00000
X  22   0.020   0.024  -0.004   1.000    0.03500    0.22000  150.00000
X  23   0.030   0.032  -0.002   1.000    0.03500    0.35000  150.00000
X  24   0.041   0.044  -0.003   1.000    0.03500    0.70000  150.00000
X  25   0.021   0.019   0.002   1.000    0.03500    0.15000  150.00000
X  26   0.048   0.044   0.004   1.000    0.03500    0.70000  150.00000
X  27   0.052   0.042   0.010   0.000    0.03500    0.15000    0.00000
X  28   0.035   0.045  -0.010   0.000    0.01100    0.70000    0.00000
X
wednesday 1989, group 3, soaring bear and julianne ruterman
X
iteration number 398
X
XFor primary plot at fixed b = [Pyruvate]:
intersection (1/a = 1/[NADH], 1/V)         -137.37    -14.79
X1/V intercepts at b = (.7,.35,.22,.15)          7.50   10.17   13.33   17.30
X
XFor primary plot at fixed a = [NADH]:
intersection (1/b = 1/[Pyruvate], 1/V)      -10.48    -14.79
X1/V intercepts at a = (.035,.022,.015,.011)     8.90   11.31   14.34   17.80
X
XFor secondary plot:
X1/a = 1/[NADH] and 1/b = 1/[Pyruvate] intercepts    -33.79     -2.58
X1/V intercept     				      4.83
X
XFor lactate inhibition, at a = [NADH] = 0.035
X1/V values at 1/b = 1/[Pyruvate] = 0 and 5.0
X			- Lactate   8.90     20.21
X			+ Lactate  14.33     43.98
X
R(+/-,intercept), R(+/-,slope)      1.61      2.62
X
X
X
X
Values of the kinetic constants
parm(0) = V        2.07251869306e-01
parm(1) = KmA      2.95911641384e-02
parm(2) = KmB      3.87905057185e-01
parm(3) = KmAB     2.82387723013e-03
parm(4) = KmQ/KmPQ 7.49330270024e-03
parm(5) = 1/K(I,P) 1.89328414033e-03
X
wednesday 1989, group 3, soaring bear and julianne ruterman
X
summary of results of quadratic fit
iteration number 398
X
mean=1.41445214054527e-04 rms=1.35633277181824e-12 test=9.58910332091811e-09
X
mse    = 6.42932781063765e-06   rms weighted error = 2.53561192035328e-03
X
yzero  = 1.41445211834028e-04
ymin   = 1.41445211834025e-04
y-pmin = 1.41445211834023e-04
X
free parm    q                centroid         pmin             std_dev
X  0   0 3.81282120851e-06 2.07248056485e-01 2.07248033025e-01 3.64881962673e-02
X  1   1 1.07717240405e-06 2.95900869660e-02 2.95900810289e-02 9.25206494597e-03
X  2   2 1.05046683983e-05 3.87894601394e-01 3.87894518870e-01 1.33650295109e-01
X  3   3 4.20302920380e-08 2.82391926042e-03 2.82391984383e-03 1.34938439219e-03
X  4   4 1.62291834247e-07 7.49334929961e-03 7.49334814915e-03 3.00574172423e-03
X  5   5 1.59535762104e-07 1.89320422725e-03 1.89320534202e-03 3.60113860033e-03
END_OF_FILE
echo shar: 4 control characters may be missing from \"'./Ldh/ldhfit.test1'\"
if test 5843 -ne `wc -c <'./Ldh/ldhfit.test1'`; then
    echo shar: \"'./Ldh/ldhfit.test1'\" unpacked with wrong size!
fi
# end of './Ldh/ldhfit.test1'
fi
if test -f './Lib/simpfit.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'./Lib/simpfit.c'\"
else
echo shar: Extracting \"'./Lib/simpfit.c'\" \(4390 characters\)
sed "s/^X//" >'./Lib/simpfit.c' <<'END_OF_FILE'
X/* SIMPFIT.C */
X/*-
simplex fitting routine			= simpfit()
X  
J.A. Rupley, Tucson, Arizona
rupley!local@megaron.arizona.edu
X*/
X
X#define SIMPFIT
X
X#include "simpdefs.h"
X
X/*-
SIMPFIT
X	SIMPLEX MINIMIZATION BY USE OF NELDER-MEAD ALGORITHM,
X	FOR MODEL DEFINED IN  <FUNC()> .
X*/
X
X#define ILLEGAL		0
X#define REFLECT		1
X#define STARCONTRACT	2
X#define HIGHCONTRACT	3
X#define SHRINK		4
X#define FAILREFLECT	5
X#define STAREXPAND  	6
X
int
simpfit(fptr)
X	FILE           *fptr;
X{
X	register int    j, i;
X
X	int             opcode;
X	int             nlow, nhigh;
X
X	struct pstruct *p_best, pbar, pstar, p2star;
X
X	extern void     qsort();
X	extern double   sqrt();
X
X	extern          pvalcomp();
X	extern          centroid();
X	extern          func();
X	extern          ptrial();
X	extern void     fpprint();
X	extern void     pcopy();
X	extern void     fspecial();
X
X	/* expansion-contraction coefficients */
X	double          alpha;
X	double          beta;
X	double          coef_gamma;
X
X	/* expansion-contraction operations */
X	char           *opname[7];
X	opname[0] = "illegal";
X	opname[1] = "reflect";
X	opname[2] = "reflect & contract";
X	opname[3] = "contract";
X	opname[4] = "shrink on lowest vertex";
X	opname[5] = "reflect after fail to expand";
X	opname[6] = "reflect and expand";
X
X	nlow = 0;
X	nhigh = nvert - 1;
X
X	/*
X	 * initialization of coefficients and pointers 
X	 */
X	alpha = 1;
X	beta = 0.5;
X	coef_gamma = 2;
X	for (j = 0; j < nvert; j++)
X		p_p[j] = &p[j];
X
X	/* MAIN LOOP OF MINIMIZATION */
X	while (++iter) {
X
X		/*
X		 * ascending sort of pointers p_p to struct array p 
X		 */
X		qsort((char *) p_p, (unsigned) nvert,
X		      sizeof(*p_p), pvalcomp);
X
X		/*
X		 * form reduced simplex, pbar, for (nvert - 1) vertices ie
X		 * without high vertex 
X		 */
X		centroid(&pbar, p_p, (nvert - 1));
X
X		/* form pstar, new reflection trial vertex */
X		ptrial(&pstar, &pbar, p_p[nhigh], -alpha);
X		func(&pstar);
X
X		/*
X		 * NELDER-MEAD ALGORITHM = test trial vertex vs old high and
X		 * low vertices; 
X		 *
X		 * construct new trial vertices as appropriate; 
X		 *
X		 * set pointer to best new vertex 
X		 */
X		if (pstar.val < p_p[nlow]->val) {
X			ptrial(&p2star, &pstar, &pbar, -coef_gamma);
X			func(&p2star);
X			if (p2star.val < p_p[nlow]->val) {
X				p_best = &p2star;
X				opcode = STAREXPAND;
X			} else {
X				p_best = &pstar;
X				opcode = FAILREFLECT;
X			}
X		} else if (pstar.val <= p_p[nhigh - 1]->val) {
X			p_best = &pstar;
X			opcode = REFLECT;
X		} else {
X			if (pstar.val <= p_p[nhigh]->val) {
X				pcopy(p_p[nhigh], &pstar);
X				opcode = STARCONTRACT;
X			} else {
X				opcode = HIGHCONTRACT;
X			}
X			ptrial(&p2star, p_p[nhigh], &pbar, (1 - beta));
X			func(&p2star);
X			p_best = &p2star;
X			if (p2star.val > p_p[nhigh]->val)
X				opcode = SHRINK;
X		}
X		/* END OF NELDER-MEAD */
X
X		/* print results */
X		fprintf(fptr, "\n%5d %20.14e %20.14e %s\n",
X			iter, p_p[nhigh]->val, p_best->val, opname[opcode]);
X		fpprint(fptr, p_p[nhigh]);
X		fpprint(fptr, p_best);
X
X		/*
X		 * adjust simplex 
X		 *
X		 * either loop over all vertices > lowest = [0] to shrink on
X		 * lowest else copy best movement into high vertex 
X		 */
X		if (opcode == SHRINK)
X			for (j = 1; j < nvert; j++) {
X				for (i = 0; i < nparm; i++)
X					p_p[j]->parm[i] = (p_p[nlow]->parm[i]
X						     + p_p[j]->parm[i]) / 2;
X				func(p_p[j]);
X			}
X		else
X			pcopy(p_p[nhigh], p_best);
X
X		/* calculate and print new centroid */
X		centroid(&pcent, p_p, nvert);
X		fpprint(fptr, &pcent);
X
X		/*
X		 * calculate and print mean and rms of function values and
X		 * value of exit test 
X		 */
X		mean_func = 0;
X		for (j = 0; j < nvert; j++)
X			mean_func = mean_func + p[j].val;
X		mean_func = mean_func / nvert;
X		rms_func = 0;
X		for (j = 0; j < nvert; j++)
X			rms_func = rms_func
X				+ (p[j].val - mean_func) * (p[j].val - mean_func);
X		rms_func = sqrt(rms_func / nvert);
X		test = rms_func / mean_func;
X		rms_data = sqrt(p_p[nlow]->val / (ndata - nfree));
X		fprintf(fptr, "mean=%20.14e rms=%20.14e test=%20.14e\n",
X			mean_func, rms_func, test);
X		fprintf(fptr,
X			"root mean square weighted error of best fit to data = %20.14e\n\n",
X			rms_data);
X		fspecial(fptr);
X
X		/*
X		 * exit test calculate centroid function value if exit 
X		 */
X		if (iter == maxiter) {
X			func(&pcent);
X			break;
X		}
X		if (test < exit_test) {
X			func(&pcent);
X			if ((pcent.val - mean_func) < (2 * rms_func))
X				break;
X		}
X	}
X	/* END OF MAIN LOOP OF MINIMIZATION */
X
X	return (OK);
X}				/* END OF SIMPFIT      			 */
END_OF_FILE
if test 4390 -ne `wc -c <'./Lib/simpfit.c'`; then
    echo shar: \"'./Lib/simpfit.c'\" unpacked with wrong size!
fi
# end of './Lib/simpfit.c'
fi
if test -f './Lib/simplib0.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'./Lib/simplib0.c'\"
else
echo shar: Extracting \"'./Lib/simplib0.c'\" \(3938 characters\)
sed "s/^X//" >'./Lib/simplib0.c' <<'END_OF_FILE'
X/* SIMPLIB0.C */
X/*-
supporting functions for simplex fitting:
X  
J.A. Rupley, Tucson, Arizona
rupley!local@megaron.arizona.edu
X*/
X
X#define SIMPLIB0
X
X#include "simpdefs.h"
X
int
centroid(pdest, psrc, xvert)
X	struct pstruct *pdest, *psrc[];
int             xvert;
X{
X	register int    i, j;
X
X	for (i = 0; i < nparm; i++) {
X		pdest->parm[i] = psrc[0]->parm[i];
X		for (j = 1; j < xvert; j++)
X			pdest->parm[i] = pdest->parm[i]
X				+ (psrc[j]->parm[i]
X				   - psrc[0]->parm[i]) / xvert;
X	}
X	return (OK);
X
X}				/* END OF CENTROID    			 */
X
int
ptrial(pnew, p1, p2, coef2)
X	struct pstruct *pnew, *p1, *p2;
X	double          coef2;
X{
X	register int    i;
X
X	for (i = 0; i < nparm; i++)
X		pnew->parm[i] = p1->parm[i] +
X			coef2 * (p2->parm[i] - p1->parm[i]);
X	return (OK);
X}				/* END OF PTRIAL			 */
X
void
pcopy(pdest, psrc)
X	struct pstruct *pdest, *psrc;
X{
X	register int    i;
X
X	pdest->val = psrc->val;
X	for (i = 0; i < nparm; i++)
X		pdest->parm[i] = psrc->parm[i];
X
X}				/* END OF PCOPY				 */
X
X/*
X * compare float contents of a structure member for records x and y 
X */
int
pvalcomp(p_px, p_py)
X	struct pstruct **p_px, **p_py;
X{
X
X	if ((*p_px)->val < (*p_py)->val)
X		return (-1);
X	else if ((*p_px)->val > (*p_py)->val)
X		return (1);
X	else
X		return (0);
X}				/* END OF PVALCOMP			 */
X
void
ffitprint(fptr)
X	FILE           *fptr;
X{
X	extern void     fpprint();
X	extern void     fsprint();
X
X	/* first all vertices of simplex */
X	fprintf(fptr,
X		"\1\f\n%-s\n\nsummary of simplex fitting results:\niteration number %d\n",
X		title, iter);
X	fsprint(fptr, "\nsimplex:\n");
X
X	/* then centroid */
X	fprintf(fptr,
X		"\ncentroid:\nfunction value = %20.14e\n", pcent.val);
X	fpprint(fptr, &pcent);
X
X	/* then test for exit, etc */
X	fprintf(fptr,
X		"mean=%20.14e rms=%20.14e test=%20.14e\n", mean_func, rms_func, test);
X	fprintf(fptr,
X		"root mean square weighted error of best fit to data = %20.14e\n\n", rms_data);
X
X}				/* END OF FFITPRINT			 */
X
void
fquadprint(fptr)
X	FILE           *fptr;
X{
X	register int    i, k;
X
X	extern void     fsprint();
X
X	fprintf(fptr,
X		"\1\f\n%-s\n\nsummary of results of quadratic fit\niteration number %d\n",
X		title, iter);
X	fprintf(fptr, "\nmean=%20.14e rms=%20.14e test=%20.14e\n",
X		mean_func, rms_func, test);
X	fprintf(fptr,
X		"\nmse    = %20.14e   rms weighted error = %20.14e\n", mse, rms_data);
X	fprintf(fptr,
X		"\nyzero  = %20.14e\nymin   = %20.14e\ny-pmin = %20.14e\n\n",
X		yzero, ymin, ypmin);
X
X	fprintf(fptr,
X		"free parm    q                centroid         pmin             std_dev\n");
X
X	for (i = 0; i < nfree; i++) {
X		k = q.parmndx[i];
X		fprintf(fptr, "%3d %3d %17.11e %17.11e %17.11e %17.11e\n",
X		   k, i, q.q[i], pcent.parm[k], pmin.parm[k], q.std_dev[i]);
X	}
X}				/* END OF FQUADPRINT			 */
X
X/*
X * print nfree x nfree matrix; calls fqprint()				 
X */
void
fmatprint(fptr, g)
X	FILE           *fptr;
X	double          g[][NPARM];
X{
X	register int    i;
X
X	extern void     fqprint();
X
X	for (i = 0; i < nfree; i++)
X		fqprint(fptr, g[i]);
X}				/* END OF FMATPRINT			 */
X
void
fqprint(fptr, g)
X	FILE           *fptr;
X	double         *g;
X{
X	register int    i;
X
X	for (i = 0; i < nfree; i++) {
X		if ((i > 0) && ((i % 4) == NULL))
X			fprintf(fptr, "\n  ");
X		fprintf(fptr, "%19.10e", g[i]);
X	}
X	fprintf(fptr, "\n");
X}				/* END OF FQPRINT			 */
X
void
fpprint(fptr, g)
X	FILE           *fptr;
X	struct pstruct *g;
X{
X	register int    i;
X
X	for (i = 0; i < nparm; i++) {
X		if (i > 0 && (i % 4) == NULL)
X			fprintf(fptr, "\n  ");
X		fprintf(fptr, "%19.10e", g->parm[i]);
X	}
X	fprintf(fptr, "\n");
X}				/* END OF FPPRINT			 */
X
void
fsprint(fptr, string)
X	char           *string;
X	FILE           *fptr;
X{
X	register int    j;
X
X	extern void     fpprint();
X
X	fprintf(fptr, "%s", string);
X	for (j = 0; j < nvert; j++) {
X		fprintf(fptr, "vertex = %d   function value = %20.14e\n",
X			j, p[j].val);
X		fpprint(fptr, &p[j]);
X	}
X}				/* END OF FSPRINT			 */
X
void
enditall()
X{
X	void            exit();
X
X	exit(0);
X}				/* END OF ENDITALL			 */
END_OF_FILE
if test 3938 -ne `wc -c <'./Lib/simplib0.c'`; then
    echo shar: \"'./Lib/simplib0.c'\" unpacked with wrong size!
fi
# end of './Lib/simplib0.c'
fi
if test -f './Line/linefit.test' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'./Line/linefit.test'\"
else
echo shar: Extracting \"'./Line/linefit.test'\" \(5690 characters\)
sed "s/^X//" >'./Line/linefit.test' <<'END_OF_FILE'
X
linear least squares on set of data previously done by hand
X
summary of simplex fitting results:
iteration number 30
X
simplex:
vertex = 0   function value = 2.29878244160065e+03
X  -1.0000000000e-06  -1.0000000000e-06
vertex = 1   function value = 3.27453433991122e+04
X  -7.2221941763e+01   1.7824664714e+01
vertex = 2   function value = 1.04045580026644e+05
X   9.2617563014e+01   2.9321831706e+00
X
centroid:
function value = 1.63806065128366e+04
X   6.7985400839e+00   6.9189489614e+00
mean=4.63632352891191e+04 rms=4.26394804482802e+04 test=9.19683024326975e-01
root mean square weighted error of best fit to data = 1.59818732096385e+01
X
X
linear least squares on set of data previously done by hand
X
iteration number 30
X
X        yobs   ycalc   del-y  weight       x
X   1   3.100  13.717 -10.617   1.000    1.00000
X   2   4.900  20.636 -15.736   1.000    2.00000
X   3   7.300  27.555 -20.255   1.000    3.00000
X   4   8.700  34.474 -25.774   1.000    4.00000
X   5  10.700  41.393 -30.693   1.000    5.00000
X   6  13.000  48.312 -35.312   1.000    6.00000
X   7  15.300  55.231 -39.931   1.000    7.00000
X   8  17.300  62.150 -44.850   1.000    8.00000
X   9  18.700  69.069 -50.369   1.000    9.00000
X  10  21.100  75.988 -54.888   1.000   10.00000
X  11  22.900  82.907 -60.007   1.000   11.00000
X
linear least squares on set of data previously done by hand
X
summary of results of quadratic fit
iteration number 30
X
mean=4.63632352891191e+04 rms=4.26394804482802e+04 test=9.19683024326975e-01
X
mse    = 2.55420271288961e+02   rms weighted error = 1.59818732096385e+01
X
yzero  = 2.29878244160065e+03
ymin   = 5.79636363638201e-01
y-pmin = 5.79636363636367e-01
X
free parm    q                centroid         pmin             std_dev
X  0   0 5.49465015924e+01 -1.00000000000e-06 1.01090909091e+00 1.03349946032e+01
X  1   1 6.91894996138e+00 -1.00000000000e-06 1.99818181818e+00 1.52381182115e+00
X
linear least squares on set of data previously done by hand
X
summary of simplex fitting results:
iteration number 60
X
simplex:
vertex = 0   function value = 5.79662722281170e-01
X   1.0092438688e+00   1.9982015687e+00
vertex = 1   function value = 5.79649162752061e-01
X   1.0123395026e+00   1.9978702422e+00
vertex = 2   function value = 5.79636363636367e-01
X   1.0109090909e+00   1.9981818182e+00
X
centroid:
function value = 5.79642224041685e-01
X   1.0108308208e+00   1.9980845430e+00
mean=5.79649416223199e-01 rms=1.07623641972829e-05 test=1.85670232662474e-05
root mean square weighted error of best fit to data = 2.53779511395307e-01
X
X
linear least squares on set of data previously done by hand
X
iteration number 60
X
X        yobs   ycalc   del-y  weight       x
X   1   3.100   3.009   0.091   1.000    1.00000
X   2   4.900   5.007  -0.107   1.000    2.00000
X   3   7.300   7.005   0.295   1.000    3.00000
X   4   8.700   9.003  -0.303   1.000    4.00000
X   5  10.700  11.001  -0.301   1.000    5.00000
X   6  13.000  12.999   0.001   1.000    6.00000
X   7  15.300  14.997   0.303   1.000    7.00000
X   8  17.300  16.996   0.304   1.000    8.00000
X   9  18.700  18.994  -0.294   1.000    9.00000
X  10  21.100  20.992   0.108   1.000   10.00000
X  11  22.900  22.990  -0.090   1.000   11.00000
X
linear least squares on set of data previously done by hand
X
summary of results of quadratic fit
iteration number 60
X
mean=5.79649416223199e-01 rms=1.07623641972829e-05 test=1.85670232662474e-05
X
mse    = 6.44040404040408e-02   rms weighted error = 2.53779511395307e-01
X
yzero  = 5.79636363636367e-01
ymin   = 5.79636363636367e-01
y-pmin = 5.79636363636365e-01
X
free parm    q                centroid         pmin             std_dev
X  0   0 1.03187791523e-03 1.01090909091e+00 1.01090909091e+00 1.64111543528e-01
X  1   1 1.10442171689e-04 1.99818181818e+00 1.99818181818e+00 2.41969270053e-02
X
linear least squares on set of data previously done by hand
X
summary of simplex fitting results:
iteration number 84
X
simplex:
vertex = 0   function value = 5.79636363637241e-01
X   1.0109088967e+00   1.9981818829e+00
vertex = 1   function value = 5.79636363636699e-01
X   1.0109093420e+00   1.9981818045e+00
vertex = 2   function value = 5.79636363636365e-01
X   1.0109090909e+00   1.9981818182e+00
X
centroid:
function value = 5.79636363636558e-01
X   1.0109091099e+00   1.9981818352e+00
mean=5.79636363636768e-01 rms=3.60999676637164e-13 test=6.22803708125162e-13
root mean square weighted error of best fit to data = 2.53779511395307e-01
X
X
linear least squares on set of data previously done by hand
X
iteration number 84
X
X        yobs   ycalc   del-y  weight       x
X   1   3.100   3.009   0.091   1.000    1.00000
X   2   4.900   5.007  -0.107   1.000    2.00000
X   3   7.300   7.005   0.295   1.000    3.00000
X   4   8.700   9.004  -0.304   1.000    4.00000
X   5  10.700  11.002  -0.302   1.000    5.00000
X   6  13.000  13.000   0.000   1.000    6.00000
X   7  15.300  14.998   0.302   1.000    7.00000
X   8  17.300  16.996   0.304   1.000    8.00000
X   9  18.700  18.995  -0.295   1.000    9.00000
X  10  21.100  20.993   0.107   1.000   10.00000
X  11  22.900  22.991  -0.091   1.000   11.00000
X
linear least squares on set of data previously done by hand
X
summary of results of quadratic fit
iteration number 84
X
mean=5.79636363636768e-01 rms=3.60999676637164e-13 test=6.22803708125162e-13
X
mse    = 6.44040404040405e-02   rms weighted error = 2.53779511395307e-01
X
yzero  = 5.79636363636365e-01
ymin   = 5.79636363636365e-01
y-pmin = 5.79636363636364e-01
X
free parm    q                centroid         pmin             std_dev
X  0   0 1.48444727177e-07 1.01090909091e+00 1.01090909152e+00 1.62447392041e-01
X  1   1 2.61436228222e-08 1.99818181818e+00 1.99818181809e+00 2.38776239771e-02
END_OF_FILE
echo shar: 9 control characters may be missing from \"'./Line/linefit.test'\"
if test 5690 -ne `wc -c <'./Line/linefit.test'`; then
    echo shar: \"'./Line/linefit.test'\" unpacked with wrong size!
fi
# end of './Line/linefit.test'
fi
if test -f './assign/dataset3' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'./assign/dataset3'\"
else
echo shar: Extracting \"'./assign/dataset3'\" \(3521 characters\)
sed "s/^X//" >'./assign/dataset3' <<'END_OF_FILE'
dataset3: ldh, fixed nadh=.035 mM, pyruvate varied mM, fixed lactate=150 mM
X
nvert= 3	nparm= 2
X
ndata= 6	ndatval= 4
X
iter= 0			maxquad_skip= 4		exit_test= 1.E-12
X
prt_cycle= 30		quad_test= 30
X 
X
starting-simplex[nvert][nparm=list_starting_parameter_values]= 
X 
X1.e-6	1.e-6
X1e6	1.e-6
X1.e-6	1e6
X
data[ndata][ndatval=y,yc,w,list_independent_variable_values]=
X
X24.8	0	1	.15
X23.7	0	1	.15
X32.5	0	1	.22
X40.2    0	1	.35
X57.5	0	1	.70
X53.8	0	1	.70
X
X
X-----------------------end of data-------------------------------
XFor a very large simplex, try:
X
simplex[nvert][nparm=a,b]= 
X
X1.e-5	1.e-1
X1.e-6	1.e-1
X1.e-5	1.e-0
X
X----------------------------------------------------------------------
Comments:
X
the first line, a ONE-LINE title, can have no control characters or
tabs;
X
the ONE-WORD (there can be NO white space within them) mnemonic
identifiers ("data[ndata][ndatval=y,yc,w,...]=", "nvert=", etc.) must
ALL be present;
X
the identifier must be separated by white space from the value(s)
following for it;
X
the order of presentation of the identifier-value sets is fixed, but the
number of spaces or tabs or newlines, etc., between tokens is not
important (i.e., there are no format fields);
X
the number of values read after "simplex.." is <nvert> x <nparm>; there
are <nvert> vertices of the simplex, one more than the number of "free"
parameters; there are <nparm> values given for each vertex, each value
being an estimate of a parameter value; not all of the <nparm>
parameters need be "free"; a "fixed" parameter has the same value for
all vertices; for a parameter to be "free", at least one vertex must
differ from other vertices in the value for that parameter; the high and
low values for a "free" parameter, comparing all vertices, should
determine a range that includes the best-fit value of that parameter;
the fitting procedure may be able to find a best-fit value outside the 
initial range.
X
the number of values read in the set of values after "data.." is <ndata>
x <ndatval>; <ndatval> is greater than or equal to 4, because the
aggregate <data> must store for each data point values for y(observed),
y(calculated), the statistical weight, and one or more independent
variables;
X
descriptive comments (like these) can be placed at the end of the data
file.
X
X
NOTE:
X
set the starting simplex large, to include any reasonable best-fit
values of the principal parameters;
X
set exit_test tight, to minimize problems with the quadratic fit;
X
set prt_cycle and quad_test at 30, so that every 30 iterations the
intermediate results are stored on disk and selectively a quadratic
fitting is carried out, to speed convergence;
X
set maxquad_skip nonzero; then if a quadratic fit fails, the next one or
more quadratic fit attempts are passed over; the number passed over is
incremented at each successive failure, up to maxquad_skip; a successful
quadratic fit resets the skip counter;
X
set iter, the starting iteration number, at 0;
X
minimization continues until the value of <test> is less than
X<exit_test>:
X
X     <exit_test> = input value
X     <test>      = <rms_func> / <mean_func>
X     <rms_func>  = (root mean square of the deviations
X                              of the least squares values
X                              at the simplex vertices)
X     <mean_func> = (mean of the least squares values)
X
on exit from the minimization, a pass through simpdev() gives the
final estimates of the standard deviations of the parameters;
X
read_data() has code for reading in parameter bounds; please consult
the source code.
X
END_OF_FILE
if test 3521 -ne `wc -c <'./assign/dataset3'`; then
    echo shar: \"'./assign/dataset3'\" unpacked with wrong size!
fi
# end of './assign/dataset3'
fi
if test -f './assign/dataset4' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'./assign/dataset4'\"
else
echo shar: Extracting \"'./assign/dataset4'\" \(3521 characters\)
sed "s/^X//" >'./assign/dataset4' <<'END_OF_FILE'
dataset4: ldh, fixed nadh=.035 mM, pyruvate varied mM, fixed lactate=150 mM
X
nvert= 3	nparm= 2
X
ndata= 6	ndatval= 4
X
iter= 0			maxquad_skip= 4		exit_test= 1.E-12
X
prt_cycle= 30		quad_test= 30
X 
X
starting-simplex[nvert][nparm=list_starting_parameter_values]= 
X 
X1.e-6	1.e-6
X1e6	1.e-6
X1.e-6	1e6
X
data[ndata][ndatval=y,yc,w,list_independent_variable_values]=
X
X21.0	0	1	.15
X19.6	0	1	.15
X22.8	0	1	.22
X31.5    0	1	.35
X41.0	0	1	.70
X45.4	0	1	.70
X
X
X-----------------------end of data-------------------------------
XFor a very large simplex, try:
X
simplex[nvert][nparm=a,b]= 
X
X1.e-5	1.e-1
X1.e-6	1.e-1
X1.e-5	1.e-0
X
X----------------------------------------------------------------------
Comments:
X
the first line, a ONE-LINE title, can have no control characters or
tabs;
X
the ONE-WORD (there can be NO white space within them) mnemonic
identifiers ("data[ndata][ndatval=y,yc,w,...]=", "nvert=", etc.) must
ALL be present;
X
the identifier must be separated by white space from the value(s)
following for it;
X
the order of presentation of the identifier-value sets is fixed, but the
number of spaces or tabs or newlines, etc., between tokens is not
important (i.e., there are no format fields);
X
the number of values read after "simplex.." is <nvert> x <nparm>; there
are <nvert> vertices of the simplex, one more than the number of "free"
parameters; there are <nparm> values given for each vertex, each value
being an estimate of a parameter value; not all of the <nparm>
parameters need be "free"; a "fixed" parameter has the same value for
all vertices; for a parameter to be "free", at least one vertex must
differ from other vertices in the value for that parameter; the high and
low values for a "free" parameter, comparing all vertices, should
determine a range that includes the best-fit value of that parameter;
the fitting procedure may be able to find a best-fit value outside the 
initial range.
X
the number of values read in the set of values after "data.." is <ndata>
x <ndatval>; <ndatval> is greater than or equal to 4, because the
aggregate <data> must store for each data point values for y(observed),
y(calculated), the statistical weight, and one or more independent
variables;
X
descriptive comments (like these) can be placed at the end of the data
file.
X
X
NOTE:
X
set the starting simplex large, to include any reasonable best-fit
values of the principal parameters;
X
set exit_test tight, to minimize problems with the quadratic fit;
X
set prt_cycle and quad_test at 30, so that every 30 iterations the
intermediate results are stored on disk and selectively a quadratic
fitting is carried out, to speed convergence;
X
set maxquad_skip nonzero; then if a quadratic fit fails, the next one or
more quadratic fit attempts are passed over; the number passed over is
incremented at each successive failure, up to maxquad_skip; a successful
quadratic fit resets the skip counter;
X
set iter, the starting iteration number, at 0;
X
minimization continues until the value of <test> is less than
X<exit_test>:
X
X     <exit_test> = input value
X     <test>      = <rms_func> / <mean_func>
X     <rms_func>  = (root mean square of the deviations
X                              of the least squares values
X                              at the simplex vertices)
X     <mean_func> = (mean of the least squares values)
X
on exit from the minimization, a pass through simpdev() gives the
final estimates of the standard deviations of the parameters;
X
read_data() has code for reading in parameter bounds; please consult
the source code.
X
END_OF_FILE
if test 3521 -ne `wc -c <'./assign/dataset4'`; then
    echo shar: \"'./assign/dataset4'\" unpacked with wrong size!
fi
# end of './assign/dataset4'
fi
if test -f './mmfit/data.sample' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'./mmfit/data.sample'\"
else
echo shar: Extracting \"'./mmfit/data.sample'\" \(3585 characters\)
sed "s/^X//" >'./mmfit/data.sample' <<'END_OF_FILE'
nonlinear least squares on michaelis-menten function -- TEW (bannerjee) data
X
nvert= 3	nparm= 2
X
ndata= 9	ndatval= 4
X
iter= 0			maxquad_skip= 4		exit_test= 1.E-12
X
prt_cycle= 30		quad_test= 30
X 
X
starting-simplex[nvert][nparm=list_starting_parameter_values]= 
X
X1.e-5	1.e-1
X1.e-6	1.e-1
X1.e-5	1.e-0
X 
X
data[ndata][ndatval=y,yc,w,list_independent_variable_values]=
X
X.105	0	1	.00015
X.100	0	1	.00009
X.095	0	1	.00006
X.083	0	1	.00006
X.080	0	1	.00004
X.074	0	1	.00004
X.061	0	1	.00003
X.054	0	1	.00002
X.051	0	1	.00002
X
X
X-----------------------end of data-------------------------------
XFor a very large simplex, try:
X
simplex[nvert][nparm=a,b]= 
X1.e-6	1.e-6
X1e6	1.e-6
X1.e-6	1e6
X
X----------------------------------------------------------------------
Comments:
X
the first line, a ONE-LINE title, can have no control characters or
tabs;
X
the ONE-WORD (there can be NO white space within them) mnemonic
identifiers ("data[ndata][ndatval=y,yc,w,...]=", "nvert=", etc.) must
ALL be present;
X
the identifier must be separated by white space from the value(s)
following for it;
X
the order of presentation of the identifier-value sets is fixed, but the
number of spaces or tabs or newlines, etc., between tokens is not
important (i.e., there are no format fields);
X
the number of values read after "simplex.." is <nvert> x <nparm>; there
are <nvert> vertices of the simplex, one more than the number of "free"
parameters; there are <nparm> values given for each vertex, each value
being an estimate of a parameter value; not all of the <nparm>
parameters need be "free"; a "fixed" parameter has the same value for
all vertices; for a parameter to be "free", at least one vertex must
differ from other vertices in the value for that parameter; the high and
low values for a "free" parameter, comparing all vertices, should
determine a range that includes the best-fit value of that parameter;
the fitting procedure may be able to find a best-fit value outside the 
initial range.
X
the number of values read in the set of values after "data.." is <ndata>
x <ndatval>; <ndatval> is greater than or equal to 4, because the
aggregate <data> must store for each data point values for y(observed),
y(calculated), the statistical weight, and one or more independent
variables;
X
descriptive comments (like these) can be placed at the end of the data
file.
X
X
NOTE:
X
set the starting simplex large, to include any reasonable best-fit
values of the principal parameters;
X
set exit_test tight, to minimize problems with the quadratic fit;
X
set prt_cycle and quad_test at 30, so that every 30 iterations the
intermediate results are stored on disk and selectively a quadratic
fitting is carried out, to speed convergence;
X
set maxquad_skip nonzero; then if a quadratic fit fails, the next one or
more quadratic fit attempts are passed over; the number passed over is
incremented at each successive failure, up to maxquad_skip; a successful
quadratic fit resets the skip counter;
X
set iter, the starting iteration number, at 0;
X
minimization continues until the value of <test> is less than
X<exit_test>:
X
X     <exit_test> = input value
X     <test>      = <rms_func> / <mean_func>
X     <rms_func>  = (root mean square of the deviations
X                              of the least squares values
X                              at the simplex vertices)
X     <mean_func> = (mean of the least squares values)
X
on exit from the minimization, a pass through simpdev() gives the
final estimates of the standard deviations of the parameters;
X
read_data() has code for reading in parameter bounds; please consult
the source code.
X
END_OF_FILE
if test 3585 -ne `wc -c <'./mmfit/data.sample'`; then
    echo shar: \"'./mmfit/data.sample'\" unpacked with wrong size!
fi
# end of './mmfit/data.sample'
fi
if test -f './mmfit/mmfit.dat' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'./mmfit/mmfit.dat'\"
else
echo shar: Extracting \"'./mmfit/mmfit.dat'\" \(3585 characters\)
sed "s/^X//" >'./mmfit/mmfit.dat' <<'END_OF_FILE'
nonlinear least squares on michaelis-menten function -- TEW (bannerjee) data
X
nvert= 3	nparm= 2
X
ndata= 9	ndatval= 4
X
iter= 0			maxquad_skip= 4		exit_test= 1.E-12
X
prt_cycle= 30		quad_test= 30
X 
X
starting-simplex[nvert][nparm=list_starting_parameter_values]= 
X
X1.e-5	1.e-1
X1.e-6	1.e-1
X1.e-5	1.e-0
X 
X
data[ndata][ndatval=y,yc,w,list_independent_variable_values]=
X
X.105	0	1	.00015
X.100	0	1	.00009
X.095	0	1	.00006
X.083	0	1	.00006
X.080	0	1	.00004
X.074	0	1	.00004
X.061	0	1	.00003
X.054	0	1	.00002
X.051	0	1	.00002
X
X
X-----------------------end of data-------------------------------
XFor a very large simplex, try:
X
simplex[nvert][nparm=a,b]= 
X1.e-6	1.e-6
X1e6	1.e-6
X1.e-6	1e6
X
X----------------------------------------------------------------------
Comments:
X
the first line, a ONE-LINE title, can have no control characters or
tabs;
X
the ONE-WORD (there can be NO white space within them) mnemonic
identifiers ("data[ndata][ndatval=y,yc,w,...]=", "nvert=", etc.) must
ALL be present;
X
the identifier must be separated by white space from the value(s)
following for it;
X
the order of presentation of the identifier-value sets is fixed, but the
number of spaces or tabs or newlines, etc., between tokens is not
important (i.e., there are no format fields);
X
the number of values read after "simplex.." is <nvert> x <nparm>; there
are <nvert> vertices of the simplex, one more than the number of "free"
parameters; there are <nparm> values given for each vertex, each value
being an estimate of a parameter value; not all of the <nparm>
parameters need be "free"; a "fixed" parameter has the same value for
all vertices; for a parameter to be "free", at least one vertex must
differ from other vertices in the value for that parameter; the high and
low values for a "free" parameter, comparing all vertices, should
determine a range that includes the best-fit value of that parameter;
the fitting procedure may be able to find a best-fit value outside the 
initial range.
X
the number of values read in the set of values after "data.." is <ndata>
x <ndatval>; <ndatval> is greater than or equal to 4, because the
aggregate <data> must store for each data point values for y(observed),
y(calculated), the statistical weight, and one or more independent
variables;
X
descriptive comments (like these) can be placed at the end of the data
file.
X
X
NOTE:
X
set the starting simplex large, to include any reasonable best-fit
values of the principal parameters;
X
set exit_test tight, to minimize problems with the quadratic fit;
X
set prt_cycle and quad_test at 30, so that every 30 iterations the
intermediate results are stored on disk and selectively a quadratic
fitting is carried out, to speed convergence;
X
set maxquad_skip nonzero; then if a quadratic fit fails, the next one or
more quadratic fit attempts are passed over; the number passed over is
incremented at each successive failure, up to maxquad_skip; a successful
quadratic fit resets the skip counter;
X
set iter, the starting iteration number, at 0;
X
minimization continues until the value of <test> is less than
X<exit_test>:
X
X     <exit_test> = input value
X     <test>      = <rms_func> / <mean_func>
X     <rms_func>  = (root mean square of the deviations
X                              of the least squares values
X                              at the simplex vertices)
X     <mean_func> = (mean of the least squares values)
X
on exit from the minimization, a pass through simpdev() gives the
final estimates of the standard deviations of the parameters;
X
read_data() has code for reading in parameter bounds; please consult
the source code.
X
END_OF_FILE
if test 3585 -ne `wc -c <'./mmfit/mmfit.dat'`; then
    echo shar: \"'./mmfit/mmfit.dat'\" unpacked with wrong size!
fi
# end of './mmfit/mmfit.dat'
fi
if test -f './mmfit/recip_nowt.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'./mmfit/recip_nowt.c'\"
else
echo shar: Extracting \"'./mmfit/recip_nowt.c'\" \(3805 characters\)
sed "s/^X//" >'./mmfit/recip_nowt.c' <<'END_OF_FILE'
X/* RECIP_NOWTS.C */
X/*-
VERSION OF XXXXFIT, for:
X  
nonlinear least squares fit by simplex minimizaton (Nelder-Mead algorithm).
X  
test:
X	Lineweaver-Burke equation, with wrong weighting (all wts equal)
X */
X/*-
contents of the XXXXFIT module  =  
declarations and routines for simplex fitting special to function to be fit
X(no other functions/files need to be rewritten or adapted for a new model):
X  
X	mnemonic defines for members of data and parameter structures
X  
X	function for calculation of dependent variable and
X		weighted sum of residuals squared		= func()
X  
X	print of <data> records					= fdatprint()
X  
X	additional display called by fdatprint(), 
X		specially written for this model 		= fpointprint()
X  
X	customizable display called by <simpfit()>, 
X		following the output tracking each cycle
X		of minimization					= fspecial()
X  
J.A. Rupley, Tucson, Arizona
rupley!local@megaron.arizona.edu
X*/
X
X#define XXXXFIT
X
X#include "simpdefs.h"		/* externals are read from <simpdefs> */
X
X/* DEFINES SPECIAL TO FITTING FUNCTION */
X
X#define Y	0		/* defines for elements of struct dat */
X#define YC	1		/* (mnemonic) */
X#define W	2
X#define X	3
X
X#define A	0		/* defines for elements of struct pstruct */
X#define B	1		/* (mnemonic) */
X
X/*-
XFUNC
X	CALCULATION OF LEAST SQUARES FUNCTION
X	CODED ACCORDING TO MODEL BEING FIT
X	IT SHOULD BE EFFICIENT
X	DURING THE FIT, TIME IS MOSTLY SPENT HERE
X*/
X
int	firstflag;
X
int
func(pnam)
X	struct pstruct *pnam;
X{
X	register int    n;
X
X	extern struct dat data[];
X	extern int      nparm;
X	extern int      ndata;
X
X	/*
X	 * execute some changes in input data for first pass through func 
X	 */
X
X	if (!firstflag) {
X		firstflag = 1;
X		for (n = 0; n < ndata; n++) {
X			data[n].datval[Y] = 1 / data[n].datval[Y];
X			data[n].datval[X] = 1 / data[n].datval[X];
X/* 			data[n].datval[W] = 1 / data[n].datval[Y] * */
X/* 						1 / data[n].datval[Y]; */
X		}
X	}
X
X	/*
X	 * here set/test bounds on parms...may not be needed
X	 */
X
X	pnam->val = 0;
X	for (n = 0; n < ndata; n++) {
X		/* evaluation of dependent variable */
X		data[n].datval[YC] =  pnam->parm[A] * data[n].datval[X]
X			+ pnam->parm[B] ;
X		/* evaluation of weighted sum of residuals squared */
X		pnam->val = pnam->val
X			+ (data[n].datval[Y] - data[n].datval[YC])
X			* (data[n].datval[Y] - data[n].datval[YC])
X			* data[n].datval[W]
X			* data[n].datval[W];
X	}
X	return (OK);
X}				/* END OF FUNC        			 */
X
X/*-
XFDATPRINT
X	PRINT DATA AND COMPARE WITH CALCULATED VALUES
X	CODED ACCORDING TO MODEL AND DATA
X*/
X
void
fdatprint(fptr)
X	FILE           *fptr;
X{
X	register int    j;
X
X	extern void     fpointprint();
X
X	extern int      iter, ndata, maxiter;
X	extern struct dat data[];
X	extern char     title[];
X
X	fprintf(fptr, "\1\f\n%-s\n\niteration number %d\n\n", title, iter);
X	fprintf(fptr,
X		"        yobs   ycalc   del-y  weight       x\n");
X	for (j = 0; j < ndata; j++)
X		fprintf(fptr,
X			"%4d %7.3f %7.3f %7.3f %7.3f %10.5f\n",
X			(j + 1), data[j].datval[Y], data[j].datval[YC],
X			(data[j].datval[Y] - data[j].datval[YC]),
X			data[j].datval[W], data[j].datval[X]);
X
X	if (maxiter != 0)
X		fpointprint(fptr);
X}				/* END OF FDATPRINT			 */
X
X/*-
XFPOINTPRINT
X	CODE FOR SPECIAL OUTPUT, IF ANY
X*/
X
void
fpointprint(fptr)
X	FILE           *fptr;
X{
X}				/* END OF FPOINTPRINT			 */
X
X
X/*-
XFSPECIAL
X	DISPLAY ADDITIONAL INFORMATION DURING
X	TRACKING OF MINIMIZATION, IN SIMPFIT()
X*/
X
void
fspecial(fptr)
X	FILE           *fptr;
X{
X	register        j;
X
X	extern int      maxiter;
X	extern double   ypmin, yzero, quad_test;
X
X	if (ypmin > 0.99E38) {
X		fprintf(fptr, "y-pmin error");
X		for (j = 0; j < nvert; j++)
X			if (pmin.parm[j] < 0)
X				fprintf(fptr, " (parm(%d) < 0)", j);
X	} else if (ypmin > yzero)
X		fprintf(fptr, "y-pmin > yzero");
X
X	fprintf(fptr, "    next_prt= %d  next_quad= %7.2e\n",
X		maxiter, quad_test);
X
X	return;
X}				/* END OF FSPECIAL			 */
END_OF_FILE
if test 3805 -ne `wc -c <'./mmfit/recip_nowt.c'`; then
    echo shar: \"'./mmfit/recip_nowt.c'\" unpacked with wrong size!
fi
# end of './mmfit/recip_nowt.c'
fi
if test -f './mmfit/recipfit.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'./mmfit/recipfit.c'\"
else
echo shar: Extracting \"'./mmfit/recipfit.c'\" \(3752 characters\)
sed "s/^X//" >'./mmfit/recipfit.c' <<'END_OF_FILE'
X/* RECIPFIT.C */
X/*-
VERSION OF XXXXFIT, for:
X  
nonlinear least squares fit by simplex minimizaton (Nelder-Mead algorithm).
X  
test:
X	Lineweaver-Burke equation
X */
X/*-
contents of the XXXXFIT module  =  
declarations and routines for simplex fitting special to function to be fit
X(no other functions/files need to be rewritten or adapted for a new model):
X  
X	mnemonic defines for members of data and parameter structures
X  
X	function for calculation of dependent variable and
X		weighted sum of residuals squared		= func()
X  
X	print of <data> records					= fdatprint()
X  
X	additional display called by fdatprint(), 
X		specially written for this model 		= fpointprint()
X  
X	customizable display called by <simpfit()>, 
X		following the output tracking each cycle
X		of minimization					= fspecial()
X  
J.A. Rupley, Tucson, Arizona
rupley!local@megaron.arizona.edu
X*/
X
X#define XXXXFIT
X
X#include "simpdefs.h"		/* externals are read from <simpdefs> */
X
X/* DEFINES SPECIAL TO FITTING FUNCTION */
X
X#define Y	0		/* defines for elements of struct dat */
X#define YC	1		/* (mnemonic) */
X#define W	2
X#define X	3
X
X#define A	0		/* defines for elements of struct pstruct */
X#define B	1		/* (mnemonic) */
X
X/*-
XFUNC
X	CALCULATION OF LEAST SQUARES FUNCTION
X	CODED ACCORDING TO MODEL BEING FIT
X	IT SHOULD BE EFFICIENT
X	DURING THE FIT, TIME IS MOSTLY SPENT HERE
X*/
X
int	firstflag;
X
int
func(pnam)
X	struct pstruct *pnam;
X{
X	register int    n;
X
X	extern struct dat data[];
X	extern int      nparm;
X	extern int      ndata;
X
X	/*
X	 * execute some changes in input data for first pass through func 
X	 */
X
X	if (!firstflag) {
X		firstflag = 1;
X		for (n = 0; n < ndata; n++) {
X			data[n].datval[Y] = 1 / data[n].datval[Y];
X			data[n].datval[X] = 1 / data[n].datval[X];
X			data[n].datval[W] = 1 / data[n].datval[Y] *
X						1 / data[n].datval[Y];
X		}
X	}
X
X	/*
X	 * here set/test bounds on parms...may not be needed
X	 */
X
X	pnam->val = 0;
X	for (n = 0; n < ndata; n++) {
X		/* evaluation of dependent variable */
X		data[n].datval[YC] =  pnam->parm[A] * data[n].datval[X]
X			+ pnam->parm[B] ;
X		/* evaluation of weighted sum of residuals squared */
X		pnam->val = pnam->val
X			+ (data[n].datval[Y] - data[n].datval[YC])
X			* (data[n].datval[Y] - data[n].datval[YC])
X			* data[n].datval[W]
X			* data[n].datval[W];
X	}
X	return (OK);
X}				/* END OF FUNC        			 */
X
X/*-
XFDATPRINT
X	PRINT DATA AND COMPARE WITH CALCULATED VALUES
X	CODED ACCORDING TO MODEL AND DATA
X*/
X
void
fdatprint(fptr)
X	FILE           *fptr;
X{
X	register int    j;
X
X	extern void     fpointprint();
X
X	extern int      iter, ndata, maxiter;
X	extern struct dat data[];
X	extern char     title[];
X
X	fprintf(fptr, "\1\f\n%-s\n\niteration number %d\n\n", title, iter);
X	fprintf(fptr,
X		"        yobs   ycalc   del-y  weight       x\n");
X	for (j = 0; j < ndata; j++)
X		fprintf(fptr,
X			"%4d %7.3f %7.3f %7.3f %7.3f %10.5f\n",
X			(j + 1), data[j].datval[Y], data[j].datval[YC],
X			(data[j].datval[Y] - data[j].datval[YC]),
X			data[j].datval[W], data[j].datval[X]);
X
X	if (maxiter != 0)
X		fpointprint(fptr);
X}				/* END OF FDATPRINT			 */
X
X/*-
XFPOINTPRINT
X	CODE FOR SPECIAL OUTPUT, IF ANY
X*/
X
void
fpointprint(fptr)
X	FILE           *fptr;
X{
X}				/* END OF FPOINTPRINT			 */
X
X
X/*-
XFSPECIAL
X	DISPLAY ADDITIONAL INFORMATION DURING
X	TRACKING OF MINIMIZATION, IN SIMPFIT()
X*/
X
void
fspecial(fptr)
X	FILE           *fptr;
X{
X	register        j;
X
X	extern int      maxiter;
X	extern double   ypmin, yzero, quad_test;
X
X	if (ypmin > 0.99E38) {
X		fprintf(fptr, "y-pmin error");
X		for (j = 0; j < nvert; j++)
X			if (pmin.parm[j] < 0)
X				fprintf(fptr, " (parm(%d) < 0)", j);
X	} else if (ypmin > yzero)
X		fprintf(fptr, "y-pmin > yzero");
X
X	fprintf(fptr, "    next_prt= %d  next_quad= %7.2e\n",
X		maxiter, quad_test);
X
X	return;
X}				/* END OF FSPECIAL			 */
END_OF_FILE
if test 3752 -ne `wc -c <'./mmfit/recipfit.c'`; then
    echo shar: \"'./mmfit/recipfit.c'\" unpacked with wrong size!
fi
# end of './mmfit/recipfit.c'
fi
echo shar: End of archive 2 \(of 4\).
cp /dev/null ark2isdone
MISSING=""
for I in 1 2 3 4 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 4 archives.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0


