home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / math / lsqrft13.zip / FIT.H < prev    next >
Text File  |  1993-07-10  |  3KB  |  89 lines

  1. #define NUM_ARGS 256
  2. #define COMMAND_SIZE 512
  3.  
  4.  
  5. /* This structure tells us how the data is represented internally in
  6.      the data matrix.  If order.x = 0, then the 0th column is the x's.
  7. /*     int *x;        independent variables */
  8.  /*    int y;         dependent variable */
  9.  /*    int yfit;      value of function with current parameters */
  10.  /*    int sig;       sigma: an error estimate for y, used in fitting */
  11.  /*    int nsig;     no sigma, column of data full of 1's */
  12.  /*    int ssig;     sigma for statistical weighting */
  13.  /*    int isig;      sigma for instrumental weighting */
  14.  /*    int osig;     sigma for other weighting */
  15.  
  16. struct data_order{
  17.     int *x;
  18.     int y;
  19.     int yfit;
  20.     int sig;
  21.     int nsig;
  22.     int ssig;
  23.     int isig;
  24.     int osig;
  25.     int *xsig;
  26. };
  27.  
  28. /*** a few function declarations ***/
  29.  
  30. double **dmatrix(int,int);/* allocates a two dimensional array of doubles */
  31. double *dvector(int);            /* allocates a one dimensional array of doubles */
  32. int *ivector(int);                   /* allocates a one dimensional array of ints */
  33. void free_dmatrix(double **, int,int);     /* frees a two dimensional array of doubles */
  34. int listfcns(void);                /* lists the functions available for fitting */
  35.  
  36. /* pointer to the fitting function */
  37. int (*func)(double *x, double *a, double *y, double *dyda,
  38.                 int na, int dyda_flag, int *fita, int dydx_flag, 
  39.                 double *dydx, double ydat);
  40.  
  41. /* returns pointer to the fitting function */
  42. int (*getfuncptr())(char *function_name, int *num_indep,
  43.             int linflag, int *num_parameters, char *comment);
  44.  
  45. /* calculates f(x) with current parameter values */
  46. int calc_yfit(int (*func)(), double **data, struct data_order order, 
  47.                 int num_indep, double *a, int ndata, int ma, double *chisqr);
  48.  
  49. int help(char *topic, int maxlines);
  50.  
  51. /* reads the data from a file */
  52. int get_data(double **data, char *command, int num_indep, char *inbuf,
  53.                 struct data_order *order, char *filename,
  54.                 int maxrows, int maxcols);
  55.  
  56. /* does the nonlinear fit */
  57. int mrqfit(double **data,struct data_order order,
  58.                 int num_indep, int ndata, int itmax, double *a,
  59.                 int ma, int *lista, int mfit, double **covar,
  60.                 double *chisq, int (*func)(), 
  61.                 char *filename, char *comment);
  62.  
  63. void solve_for_da();
  64. int alpha_beta_chisq(double **data, struct data_order order,
  65.                 int num_indep, int ndata, double *a, int ma, 
  66.                 int *lista, int mfit, double **alpha, double *beta,
  67.                 double *chisq, int (*funcs)());
  68.  
  69. int plot( int (*func)(), double **data, struct data_order order,
  70.                 int num_indep, int ndata, char *filename, char *comment, 
  71.                 double *a, int ma);
  72.  
  73. int parse(char *command, char cmdarg[30][30]);
  74.  
  75. int make_data(int (*func)(), int num_indep, double *a, int ma, 
  76.                 char *command, char *inbuf);
  77.  
  78. /* nonzero returns 1 if all elements of an array are non-zero */
  79. int nonzero(double *, int ndata);
  80.  
  81. int gnucmd(char *command);
  82.  
  83. int linear_fit(double **data,struct data_order order,
  84.                 int num_indep, int ndata, int itmax, double *a,
  85.                 int ma, int *lista, int mfit, double **covar,
  86.                 double *chisq, int (*func)(),
  87.                 char *filename, char *comment);
  88.  
  89.