home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Science / Science.zip / sfit110.zip / DEMO / INTERP.C < prev    next >
C/C++ Source or Header  |  1994-09-28  |  905b  |  43 lines

  1. #define NPARAM 5
  2. #define NADD 0
  3.  
  4. /* Example Interpreted function */
  5. char firsttime = 1;
  6. int Ndat;
  7. /* consider the data arrays to be datx[Ndat] etc. */
  8. double *datx,*daty,*datt;
  9.  
  10. /* The parameters  */
  11. double *P1;     // x shift  
  12. double *P2;     // y constant 
  13. double *P3;     // y ^ 1 
  14. double *P4;     // y ^ 2 
  15. double *P5;     // y ^ 3 
  16.  
  17. main()
  18.    {
  19.    if (!verify(Ndat,NPARAM,NADD)) exit(1);
  20.    /* do not put anything else in here */
  21.    }
  22.  
  23. fitfunc()
  24.    {
  25.    int i;
  26.    double x[Ndat];
  27.    if (firsttime)
  28.       {
  29.       /* start up code goes in here */
  30.       firsttime = 0;
  31.       }
  32.    for (i = 0;i < Ndat;i++)
  33.       {
  34.       /* edit the contents of this loop as necessary */
  35.       /* to calculate datt as a function of the data */
  36.       /* and parameters */
  37.       x[i] = datx[i] - *P1;
  38.       datt[i] = x[i] * (x[i] * (x[i] * *P5 + *P4) + *P3) + *P2;
  39.       }
  40.    }
  41.  
  42.  
  43.