Added script front-end for primer-design code
[htsworkflow.git] / htswanalysis / MACS / lib / gsl / gsl-1.11 / multifit / test_enso.c
1 const size_t enso_N = 168;
2 const size_t enso_P = 9;
3
4 double enso_x0[9] = { 10.0, 3.0, 0.5, 44.0, -1.5, 0.5, 26.0, 0.1, 1.5 };
5
6 double enso_x[9] = {
7   1.0510749193E+01, 
8   3.0762128085E+00,
9   5.3280138227E-01,
10   4.4311088700E+01,
11  -1.6231428586E+00,
12   5.2554493756E-01,
13   2.6887614440E+01,
14   2.1232288488E-01,
15   1.4966870418E+00
16 };
17
18 double enso_sumsq = 7.8853978668E+02;
19
20 double enso_sigma[9] = {
21  1.7488832467E-01,
22  2.4310052139E-01,
23  2.4354686618E-01,
24  9.4408025976E-01,
25  2.8078369611E-01,
26  4.8073701119E-01,
27  4.1612939130E-01,
28  5.1460022911E-01,
29  2.5434468893E-01
30 };
31
32 double enso_F[168] = {
33     12.90000, 
34     11.30000, 
35     10.60000, 
36     11.20000, 
37     10.90000, 
38     7.500000, 
39     7.700000, 
40     11.70000, 
41     12.90000, 
42     14.30000, 
43     10.90000, 
44     13.70000, 
45     17.10000, 
46     14.00000, 
47     15.30000, 
48     8.500000, 
49     5.700000, 
50     5.500000, 
51     7.600000, 
52     8.600000, 
53     7.300000, 
54     7.600000, 
55     12.70000, 
56     11.00000, 
57     12.70000, 
58     12.90000, 
59     13.00000, 
60     10.90000, 
61    10.400000, 
62    10.200000, 
63     8.000000, 
64     10.90000, 
65     13.60000, 
66    10.500000, 
67     9.200000, 
68     12.40000, 
69     12.70000, 
70     13.30000, 
71    10.100000, 
72     7.800000, 
73     4.800000, 
74     3.000000, 
75     2.500000, 
76     6.300000, 
77     9.700000, 
78     11.60000, 
79     8.600000, 
80     12.40000, 
81    10.500000, 
82     13.30000, 
83    10.400000, 
84     8.100000, 
85     3.700000, 
86     10.70000, 
87     5.100000, 
88    10.400000, 
89     10.90000, 
90     11.70000, 
91     11.40000, 
92     13.70000, 
93     14.10000, 
94     14.00000, 
95     12.50000, 
96     6.300000, 
97     9.600000, 
98     11.70000, 
99     5.000000, 
100     10.80000, 
101     12.70000, 
102     10.80000, 
103     11.80000, 
104     12.60000, 
105     15.70000, 
106     12.60000, 
107     14.80000, 
108     7.800000, 
109     7.100000, 
110     11.20000, 
111     8.100000, 
112     6.400000, 
113     5.200000, 
114     12.00000, 
115    10.200000, 
116     12.70000, 
117    10.200000, 
118     14.70000, 
119     12.20000, 
120     7.100000, 
121     5.700000, 
122     6.700000, 
123     3.900000, 
124     8.500000, 
125     8.300000, 
126     10.80000, 
127     16.70000, 
128     12.60000, 
129     12.50000, 
130     12.50000, 
131     9.800000, 
132     7.200000, 
133     4.100000, 
134     10.60000, 
135    10.100000, 
136    10.100000, 
137     11.90000, 
138     13.60000, 
139     16.30000, 
140     17.60000, 
141     15.50000, 
142     16.00000, 
143     15.20000, 
144     11.20000, 
145     14.30000, 
146     14.50000, 
147     8.500000, 
148     12.00000, 
149     12.70000, 
150     11.30000, 
151     14.50000, 
152     15.10000, 
153    10.400000, 
154     11.50000, 
155     13.40000, 
156     7.500000, 
157    0.6000000, 
158    0.3000000, 
159     5.500000, 
160     5.000000, 
161     4.600000, 
162     8.200000, 
163     9.900000, 
164     9.200000, 
165     12.50000, 
166     10.90000, 
167     9.900000, 
168     8.900000, 
169     7.600000, 
170     9.500000, 
171     8.400000, 
172     10.70000, 
173     13.60000, 
174     13.70000, 
175     13.70000, 
176     16.50000, 
177     16.80000, 
178     17.10000, 
179     15.40000, 
180     9.500000, 
181     6.100000, 
182    10.100000, 
183     9.300000, 
184     5.300000, 
185     11.20000, 
186     16.60000, 
187     15.60000, 
188     12.00000, 
189     11.50000, 
190     8.600000, 
191     13.80000, 
192     8.700000, 
193     8.600000, 
194     8.600000, 
195     8.700000, 
196     12.80000, 
197     13.20000, 
198     14.00000, 
199     13.40000, 
200     14.80000
201 };
202
203
204 int
205 enso_f (const gsl_vector * x, void *params, gsl_vector * f)
206 {
207   double b[9];
208   size_t i;
209
210   for (i = 0; i < 9; i++)
211     {
212       b[i] = gsl_vector_get(x, i);
213     }
214
215   for (i = 0; i < 168; i++)
216     {
217       double t = (i + 1.0);
218       double y;
219       y = b[0];
220       y += b[1] * cos(2*M_PI*t/12);
221       y += b[2] * sin(2*M_PI*t/12);
222       y += b[4] * cos(2*M_PI*t/b[3]);
223       y += b[5] * sin(2*M_PI*t/b[3]);
224       y += b[7] * cos(2*M_PI*t/b[6]);
225       y += b[8] * sin(2*M_PI*t/b[6]);
226
227       gsl_vector_set (f, i, enso_F[i] - y);
228     }
229
230   return GSL_SUCCESS;
231 }
232
233 int
234 enso_df (const gsl_vector * x, void *params, gsl_matrix * df)
235 {
236   double b[9];
237   size_t i;
238
239   for (i = 0; i < 9; i++)
240     {
241       b[i] = gsl_vector_get(x, i);
242     }
243
244   for (i = 0; i < 168; i++)
245     {
246       double t = (i + 1.0);
247
248       gsl_matrix_set (df, i, 0, -1.0);
249       gsl_matrix_set (df, i, 1, -cos(2*M_PI*t/12));
250       gsl_matrix_set (df, i, 2, -sin(2*M_PI*t/12));
251       gsl_matrix_set (df, i, 3, 
252                       -b[4]*(2*M_PI*t/(b[3]*b[3]))*sin(2*M_PI*t/b[3])
253                       +b[5]*(2*M_PI*t/(b[3]*b[3]))*cos(2*M_PI*t/b[3]));
254       gsl_matrix_set (df, i, 4, -cos(2*M_PI*t/b[3]));
255       gsl_matrix_set (df, i, 5, -sin(2*M_PI*t/b[3]));
256       gsl_matrix_set (df, i, 6, 
257                      -b[7] * (2*M_PI*t/(b[6]*b[6])) * sin(2*M_PI*t/b[6])
258                      +b[8] * (2*M_PI*t/(b[6]*b[6])) * cos(2*M_PI*t/b[6]));
259       gsl_matrix_set (df, i, 7, -cos(2*M_PI*t/b[6]));
260       gsl_matrix_set (df, i, 8, -sin(2*M_PI*t/b[6]));
261     }
262
263   return GSL_SUCCESS;
264 }
265
266 int
267 enso_fdf (const gsl_vector * x, void *params,
268            gsl_vector * f, gsl_matrix * df)
269 {
270   enso_f (x, params, f);
271   enso_df (x, params, df);
272
273   return GSL_SUCCESS;
274 }
275
276
277
278
279