/* SIMPDEFS.H */
/*-
defines, includes, structures, externals
common to most or all files for simplex fitting

J.A. Rupley, Tucson, Arizona
rupley!local@cs.arizona.edu
*/

#include <stdio.h>
#include <math.h>
#include <ctype.h>

#define ERROR		-1
#define OK		0
#define TRUE		1
#define FALSE		0

#define MAX(X,Y)	((X) >  (Y) ?  (X) : (Y))
#define MIN(X,Y)	((X) <= (Y) ?  (X) : (Y))
#define ABS(X)		((X) <   0  ? -(X) : (X))

#define NPARM		20	/* limit no. parms in pstruct */
#define NVERT		(NPARM + 1)

#define SILENT		0	/* verbosity levels, for output control */
#define NEAR_SILENT	1
#define SLIGHTLY	2
#define VERY		3

struct pstruct {
	double          val;
	double          parm[NPARM];
};
struct qstruct {
	int             parmndx[NPARM];
	double          q[NPARM];
	double          yplus[NPARM];
	double          yminus[NPARM];
	double          a[NPARM];
	double          bdiag[NPARM];
	double          inv_bdiag[NPARM];
	double          std_dev[NPARM];
};

#ifdef STANDALONE
/* for data storage in standalone version */
#define NDATVAL		20	/* limit no. indep. variables = NDATVAL - 3 */
#define NDATA		10000	/* limit no. data pts */

struct dat {
	double          datval[NDATVAL];
};
#endif

#ifdef XXXXFIT
/* EXTERNAL DEFINITIONS */
struct pstruct  p[NVERT];
struct pstruct  pcent;
struct pstruct *p_p[NVERT];
struct pstruct  pmin;
struct qstruct  q;

double          hessian[NPARM][NPARM];
double          qmat[NPARM][NPARM];
double          mean_func, rms_func, test, rms_data;
double          yzero, ymin, ypmin, mse;
double          quad_test, exit_test;

int             iter, maxiter, nparm, nvert, maxquad_skip, prt_cycle;
int             nfree;
int             verbose, prog_done;
int             ndata;
int             ratio_exit_test;

#else
/* EXTERNAL DECLARATIONS */
extern struct pstruct p[NVERT];
extern struct pstruct pcent;
extern struct pstruct *p_p[NVERT];
extern struct pstruct pmin;
extern struct qstruct q;

extern double   hessian[NPARM][NPARM];
extern double   qmat[NPARM][NPARM];
extern double   mean_func, rms_func, test, rms_data;
extern double   yzero, ymin, ypmin, mse;
extern double   quad_test, exit_test;

extern int      iter, maxiter, nparm, nvert, maxquad_skip, prt_cycle;
extern int      nfree;
extern int      verbose, prog_done;
extern int      ndata;
extern int      ratio_exit_test;

#endif
