-
Notifications
You must be signed in to change notification settings - Fork 7
/
curvefit.h
75 lines (62 loc) · 1.82 KB
/
curvefit.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#ifndef _CURVEFIT_H_
#define _CURVEFIT_H_
#include "mpfit.h"
#include "common.h"
#include "compcontainer.h"
#include <string.h>
#include <time.h>
#include <gsl/gsl_rng.h>
#include <gsl/gsl_randist.h>
#include <gsl/gsl_sort.h>
#include <gsl/gsl_statistics.h>
struct struct_data_model
{
int n;
double *x;
double *y;
double *err;
compcontainer *model;
};
//struct struct_data_model_par
//{
// struct struct_data_model *data_model;
// double *par;
// struct struct_parlimit *parlimit;
// int nparlimit;
//};
struct struct_parlimit
{
int p; // number in par array;
double val; // limit value
double limit; // 0: lower limit, 1: upper limit
};
int fitfunc_mpfit(int ny, int np, double *p, double *deviates, double **derivs
, struct struct_data_model *data_model);
double fitfunc_siman(int np, double *p, struct struct_data_model *data_model);
class curvefit
{
public:
curvefit();
//~curvefit();
struct struct_data_model data_model;
double *par0; // initial guess of parameters
double *pout, *perrout; // output parameters and errors
double *pout_tot, *perrout_tot; // output parameters and errors
int nplimit, npout, npout_tot;
struct struct_parlimit *plimit;
int iternum;
double chisq, reduced_chisq;
double DOF;
int status;
void setdata(int num, double *x, double *y, double *err);
void setmodel(compcontainer *m);
void setinitp(double *p);
void setlimit(int n, double p, int limit);
void lmfit(int nitermax = 200);
void siman(int ntmax = 1000, int ninner = 500, double jump = 0.03,
int ninit = 1000, double Tratio = 0.02, double delta = 1.0e-6, int nstable = 25);
void mix_fit(int ntmax, int ninner, double jump, int ninit, double Tratio, double delta,
int nstable);
void info();
};
#endif