1 | /* This is Ecf.h, the public header file for the 2003 version of the |
---|
2 | ECF library. */ |
---|
3 | |
---|
4 | #ifndef _GCI_ECF |
---|
5 | #define _GCI_ECF |
---|
6 | |
---|
7 | /* #defines which are publically needed */ |
---|
8 | |
---|
9 | typedef enum { NOISE_CONST, NOISE_GIVEN, NOISE_POISSON_DATA, |
---|
10 | NOISE_POISSON_FIT, NOISE_GAUSSIAN_FIT, NOISE_MLE } noise_type; |
---|
11 | |
---|
12 | typedef enum { FIT_GLOBAL_MULTIEXP, FIT_GLOBAL_STRETCHEDEXP } fit_type; |
---|
13 | |
---|
14 | typedef enum { ECF_RESTRAIN_DEFAULT, ECF_RESTRAIN_USER } restrain_type; |
---|
15 | |
---|
16 | /* Single transient analysis functions */ |
---|
17 | |
---|
18 | // the next fn uses GCI_triple_integral_*() to fit repeatedly until chisq_target is met |
---|
19 | int GCI_triple_integral_fitting_engine(float xincr, float y[], int fit_start, int fit_end, |
---|
20 | float instr[], int ninstr, noise_type noise, float sig[], |
---|
21 | float *Z, float *A, float *tau, float *fitted, float *residuals, |
---|
22 | float *chisq, float chisq_target); |
---|
23 | // the next fn uses GCI_marquardt_instr() to fit repeatedly until chisq_target is met |
---|
24 | int GCI_marquardt_fitting_engine(float xincr, float *trans, int ndata, int fit_start, int fit_end, |
---|
25 | float prompt[], int nprompt, |
---|
26 | noise_type noise, float sig[], |
---|
27 | float param[], int paramfree[], |
---|
28 | int nparam, restrain_type restrain, |
---|
29 | void (*fitfunc)(float, float [], float *, float [], int), |
---|
30 | float *fitted, float *residuals, float *chisq, |
---|
31 | float **covar, float **alpha, float **erraxes, |
---|
32 | float chisq_target, float chisq_delta, int chisq_percent); |
---|
33 | |
---|
34 | int GCI_triple_integral(float xincr, float y[], |
---|
35 | int fit_start, int fit_end, |
---|
36 | noise_type noise, float sig[], |
---|
37 | float *Z, float *A, float *tau, |
---|
38 | float *fitted, float *residuals, |
---|
39 | float *chisq, int division); |
---|
40 | int GCI_triple_integral_instr(float xincr, float y[], |
---|
41 | int fit_start, int fit_end, |
---|
42 | float instr[], int ninstr, |
---|
43 | noise_type noise, float sig[], |
---|
44 | float *Z, float *A, float *tau, |
---|
45 | float *fitted, float *residuals, |
---|
46 | float *chisq, int division); |
---|
47 | |
---|
48 | int GCI_marquardt(float x[], float y[], int ndata, |
---|
49 | noise_type noise, float sig[], |
---|
50 | float param[], int paramfree[], int nparam, |
---|
51 | restrain_type restrain, |
---|
52 | void (*fitfunc)(float, float [], float *, float [], int), |
---|
53 | float *fitted, float *residuals, |
---|
54 | float **covar, float **alpha, float *chisq, |
---|
55 | float chisq_delta, float chisq_percent, float **erraxes); |
---|
56 | int GCI_marquardt_instr(float xincr, float y[], |
---|
57 | int ndata, int fit_start, int fit_end, |
---|
58 | float instr[], int ninstr, |
---|
59 | noise_type noise, float sig[], |
---|
60 | float param[], int paramfree[], int nparam, |
---|
61 | restrain_type restrain, |
---|
62 | void (*fitfunc)(float, float [], float *, float [], int), |
---|
63 | float *fitted, float *residuals, |
---|
64 | float **covar, float **alpha, float *chisq, |
---|
65 | float chisq_delta, float chisq_percent, float **erraxes); |
---|
66 | void GCI_marquardt_cleanup(void); |
---|
67 | |
---|
68 | /* Global analysis analysis functions */ |
---|
69 | |
---|
70 | int GCI_marquardt_global_exps_instr(float xincr, float **trans, |
---|
71 | int ndata, int ntrans, int fit_start, int fit_end, |
---|
72 | float instr[], int ninstr, |
---|
73 | noise_type noise, float sig[], int ftype, |
---|
74 | float **param, int paramfree[], int nparam, |
---|
75 | restrain_type restrain, float chisq_delta, |
---|
76 | float **fitted, float **residuals, |
---|
77 | float chisq_trans[], float *chisq_global, int *df, |
---|
78 | int drop_bad_transients); |
---|
79 | int GCI_marquardt_global_generic_instr(float xincr, float **trans, |
---|
80 | int ndata, int ntrans, int fit_start, int fit_end, |
---|
81 | float instr[], int ninstr, |
---|
82 | noise_type noise, float sig[], |
---|
83 | float **param, int paramfree[], int nparam, int gparam[], |
---|
84 | restrain_type restrain, float chisq_delta, |
---|
85 | void (*fitfunc)(float, float [], float *, float [], int), |
---|
86 | float **fitted, float **residuals, |
---|
87 | float chisq_trans[], float *chisq_global, int *df); |
---|
88 | |
---|
89 | /* Support plane analysis functions */ |
---|
90 | |
---|
91 | int GCI_SPA_1D_marquardt( |
---|
92 | float x[], float y[], int ndata, |
---|
93 | noise_type noise, float sig[], |
---|
94 | float param[], int paramfree[], int nparam, |
---|
95 | restrain_type restrain, float chisq_delta, |
---|
96 | void (*fitfunc)(float, float [], float *, float [], int), |
---|
97 | int spa_param, int spa_nvalues, |
---|
98 | float spa_low, float spa_high, |
---|
99 | float chisq[], void (*progressfunc)(float)); |
---|
100 | int GCI_SPA_2D_marquardt( |
---|
101 | float x[], float y[], int ndata, |
---|
102 | noise_type noise, float sig[], |
---|
103 | float param[], int paramfree[], int nparam, |
---|
104 | restrain_type restrain, float chisq_delta, |
---|
105 | void (*fitfunc)(float, float [], float *, float [], int), |
---|
106 | int spa_param1, int spa_nvalues1, |
---|
107 | float spa_low1, float spa_high1, |
---|
108 | int spa_param2, int spa_nvalues2, |
---|
109 | float spa_low2, float spa_high2, |
---|
110 | float **chisq, void (*progressfunc)(float)); |
---|
111 | int GCI_SPA_1D_marquardt_instr( |
---|
112 | float xincr, float y[], |
---|
113 | int ndata, int fit_start, int fit_end, |
---|
114 | float instr[], int ninstr, |
---|
115 | noise_type noise, float sig[], |
---|
116 | float param[], int paramfree[], int nparam, |
---|
117 | restrain_type restrain, float chisq_delta, |
---|
118 | void (*fitfunc)(float, float [], float *, float [], int), |
---|
119 | int spa_param, int spa_nvalues, |
---|
120 | float spa_low, float spa_high, |
---|
121 | float chisq[], float chisq_target, void (*progressfunc)(float)); |
---|
122 | int GCI_SPA_2D_marquardt_instr( |
---|
123 | float xincr, float y[], |
---|
124 | int ndata, int fit_start, int fit_end, |
---|
125 | float instr[], int ninstr, |
---|
126 | noise_type noise, float sig[], |
---|
127 | float param[], int paramfree[], int nparam, |
---|
128 | restrain_type restrain, float chisq_delta, |
---|
129 | void (*fitfunc)(float, float [], float *, float [], int), |
---|
130 | int spa_param1, int spa_nvalues1, |
---|
131 | float spa_low1, float spa_high1, |
---|
132 | int spa_param2, int spa_nvalues2, |
---|
133 | float spa_low2, float spa_high2, |
---|
134 | float **chisq, float chisq_target, void (*progressfunc)(float)); |
---|
135 | int GCI_SPA_1D_marquardt_global_exps_instr( |
---|
136 | float xincr, float **trans, |
---|
137 | int ndata, int ntrans, int fit_start, int fit_end, |
---|
138 | float instr[], int ninstr, |
---|
139 | noise_type noise, float sig[], int ftype, |
---|
140 | float **param, int paramfree[], int nparam, |
---|
141 | restrain_type restrain, float chisq_delta, int drop_bad_transients, |
---|
142 | int spa_param, int spa_nvalues, |
---|
143 | float spa_low, float spa_high, |
---|
144 | float chisq_global[], int df[], void (*progressfunc)(float)); |
---|
145 | int GCI_SPA_2D_marquardt_global_exps_instr( |
---|
146 | float xincr, float **trans, |
---|
147 | int ndata, int ntrans, int fit_start, int fit_end, |
---|
148 | float instr[], int ninstr, |
---|
149 | noise_type noise, float sig[], int ftype, |
---|
150 | float **param, int paramfree[], int nparam, |
---|
151 | restrain_type restrain, float chisq_delta, int drop_bad_transients, |
---|
152 | int spa_param1, int spa_nvalues1, |
---|
153 | float spa_low1, float spa_high1, |
---|
154 | int spa_param2, int spa_nvalues2, |
---|
155 | float spa_low2, float spa_high2, |
---|
156 | float **chisq_global, int **df, void (*progressfunc)(float)); |
---|
157 | int GCI_SPA_1D_marquardt_global_generic_instr( |
---|
158 | float xincr, float **trans, |
---|
159 | int ndata, int ntrans, int fit_start, int fit_end, |
---|
160 | float instr[], int ninstr, |
---|
161 | noise_type noise, float sig[], |
---|
162 | float **param, int paramfree[], int nparam, int gparam[], |
---|
163 | restrain_type restrain, float chisq_delta, |
---|
164 | void (*fitfunc)(float, float [], float *, float [], int), |
---|
165 | int spa_param, int spa_nvalues, |
---|
166 | float spa_low, float spa_high, |
---|
167 | float chisq_global[], int df[], void (*progressfunc)(float)); |
---|
168 | int GCI_SPA_2D_marquardt_global_generic_instr( |
---|
169 | float xincr, float **trans, |
---|
170 | int ndata, int ntrans, int fit_start, int fit_end, |
---|
171 | float instr[], int ninstr, |
---|
172 | noise_type noise, float sig[], |
---|
173 | float **param, int paramfree[], int nparam, int gparam[], |
---|
174 | restrain_type restrain, float chisq_delta, |
---|
175 | void (*fitfunc)(float, float [], float *, float [], int), |
---|
176 | int spa_param1, int spa_nvalues1, |
---|
177 | float spa_low1, float spa_high1, |
---|
178 | int spa_param2, int spa_nvalues2, |
---|
179 | float spa_low2, float spa_high2, |
---|
180 | float **chisq_global, int **df, void (*progressfunc)(float)); |
---|
181 | |
---|
182 | /* Setting restraints */ |
---|
183 | |
---|
184 | int GCI_set_restrain_limits(int nparam, int restrain[], |
---|
185 | float minval[], float maxval[]); |
---|
186 | |
---|
187 | /* Predefined fitting models */ |
---|
188 | |
---|
189 | void GCI_multiexp_lambda(float x, float param[], |
---|
190 | float *y, float dy_dparam[], int nparam); |
---|
191 | void GCI_multiexp_tau(float x, float param[], |
---|
192 | float *y, float dy_dparam[], int nparam); |
---|
193 | void GCI_stretchedexp(float x, float param[], |
---|
194 | float *y, float dy_dparam[], int nparam); |
---|
195 | |
---|
196 | /* Utility functions */ |
---|
197 | float **GCI_ecf_matrix(long nrows, long ncols); |
---|
198 | void GCI_ecf_free_matrix(float **m); |
---|
199 | |
---|
200 | void ECF_ExportParams_start (char path[]); |
---|
201 | void ECF_ExportParams_stop (void); |
---|
202 | |
---|
203 | #endif /* _GCI_ECF */ |
---|
204 | |
---|
205 | // Emacs settings: |
---|
206 | // Local variables: |
---|
207 | // mode: c |
---|
208 | // c-basic-offset: 4 |
---|
209 | // tab-width: 4 |
---|
210 | // End: |
---|