# test_functions.c

Go to the documentation of this file.
```00001
00007 /*==========================================================================*/
00008 double mgaussian_area(double x, double *a, \
00009                      unsigned int dataset, unsigned int function)
00010 {
00011   double tmp1, tmp2;
00012 /*
00013 **  a[0] = area
00014 **  a[1] = center
00015 **  a[2] = std dev width
00016 */
00017   tmp1 = ((x-a[1])/a[2])*((x-a[1])/a[2]);
00018   tmp2 = a[0] * exp(-tmp1/2.0) / (sqrt(2.0*M_PI) * a[2]);
00019
00020   /*
00021   ** In this example, \c d contains the information about how the different
00022   ** datasets are related:
00023   ** For dataset i, multiply the amplitude of peak number j by d[i][j]
00024   */
00025   tmp2 *= d[dataset][function];
00026   return tmp2;
00027 }
00028 double mlorentzian_area(double x, double *a, \
00029                        unsigned int dataset, unsigned int function)
00030 {
00031   double tmp1, tmp2;
00032 /*
00033 **  a[0] = area
00034 **  a[1] = center
00035 **  a[2] = std dev width
00036 */
00037   tmp1 = ((x - a[1]) / a[2]);
00038   tmp2 = a[0] / (M_PI * a[2] * (1.0 + (tmp1*tmp1)));
00039
00040   /*
00041   ** In this example, \c d contains the information about how the different
00042   ** datasets are related:
00043   ** For dataset i, multiply the amplitude of peak number j by d[i][j]
00044   */
00045   tmp2 *= d[dataset][function];
00046   return tmp2;
00047 }
00048 double mpearson_area(double x, double *a, \
00049                     unsigned int dataset, unsigned int function)
00050 {
00051   double tmp1, tmp2, tmp3, tmp4;
00052 /*
00053 **  a[0] = area
00054 **  a[1] = center
00055 **  a[2] = std dev width
00056 **  a[3] = shape ~1 lorenztian, >3 gaussian
00057 */
00058   if ((a[3] < 0.0) || (a[3] >= GSL_SF_GAMMA_XMAX))
00059   {
00060     return 0.0;
00061   }
00062
00063   tmp1 = pow(2.0, (1.0/a[3]))-1.0;
00064   tmp2 = a[0] * a[3] * gsl_sf_gamma(a[3]) * sqrt(tmp1/a[3]);
00065   tmp3 = 1.0+(4.0*((x-a[1])/a[2])*((x-a[1])/a[2])*tmp1);
00066   tmp3 = pow(tmp3, a[3]);
00067   tmp4 = a[2] * sqrt(M_PI*a[3]) * gsl_sf_gamma(a[3]-0.5) * tmp3;
00068   tmp1 = tmp2/tmp4;
00069
00070   /*
00071   ** In this example, \c d contains the information about how the different
00072   ** datasets are related:
00073   ** For dataset i, multiply the amplitude of peak number j by d[i][j]
00074   */
00075   tmp1 *= d[dataset][function];
00076   return tmp1;
00077 }
00078 double mline(double x, double *a, \
00079             unsigned int dataset, unsigned int function)
00080 {
00081   double tmp;
00082 /*
00083 **  a[0] = slope
00084 **  a[1] = intercept
00085 */
00086   tmp = a[0] * x + a[1];
00087   return tmp;
00088 }
00089 double sgaussian_area(double x, double *a)
00090 {
00091   double tmp1, tmp2;
00092 /*
00093 **  a[0] = area
00094 **  a[1] = center
00095 **  a[2] = std dev width
00096 */
00097   tmp1 = ((x-a[1])/a[2])*((x-a[1])/a[2]);
00098   tmp2 = a[0] * exp(-tmp1/2.0) / (sqrt(2.0*M_PI) * a[2]);
00099   return tmp2;
00100 }
00101 double slorentzian_area(double x, double *a)
00102 {
00103   double tmp1, tmp2;
00104 /*
00105 **  a[0] = area
00106 **  a[1] = center
00107 **  a[2] = std dev width
00108 */
00109   tmp1 = ((x - a[1]) / a[2]);
00110   tmp2 = a[0] / (M_PI * a[2] * (1.0 + (tmp1*tmp1)));
00111   return tmp2;
00112 }
00113 double spearson_area(double x, double *a)
00114 {
00115   double tmp1, tmp2, tmp3, tmp4;
00116 /*
00117 **  a[0] = area
00118 **  a[1] = center
00119 **  a[2] = std dev width
00120 **  a[3] = shape ~1 lorenztian, >3 gaussian
00121 */
00122   if ((a[3] < 0.0) || (a[3] >= GSL_SF_GAMMA_XMAX))
00123   {
00124     return 0.0;
00125   }
00126
00127   tmp1 = pow(2.0, (1.0/a[3]))-1.0;
00128   tmp2 = a[0] * a[3] * gsl_sf_gamma(a[3]) * sqrt(tmp1/a[3]);
00129   tmp3 = 1.0+(4.0*((x-a[1])/a[2])*((x-a[1])/a[2])*tmp1);
00130   tmp3 = pow(tmp3, a[3]);
00131   tmp4 = a[2] * sqrt(M_PI*a[3]) * gsl_sf_gamma(a[3]-0.5) * tmp3;
00132   tmp1 = tmp2/tmp4;
00133   return tmp1;
00134 }
00135 double sline(double x, double *a)
00136 {
00137   double tmp;
00138 /*
00139 **  a[0] = slope
00140 **  a[1] = intercept
00141 */
00142   tmp = a[0] * x + a[1];
00143   return tmp;
00144 }
```

Generated on Fri Jan 19 14:54:26 2007 for gsl_fit by  1.4.7