home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 12 / CD_ASCQ_12_0294.iso / vrac / lsqrft15.zip / FIT.H < prev    next >
Text File  |  1993-12-11  |  4KB  |  102 lines

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