Debian Codegraph @

external/gsl/gsl_multiroots__hybridj.c

raw symbols SCIP
1 /* multiroots/hybridj.c
2 *
3 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Brian Gough
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or (at
8 * your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20 #include "gsl__config.h"cxx . . $ `<file>/external/gsl/gsl__config.h`/
21
22 #include <stddef.h>
23 #include <stdlib.h>
24 #include <stdio.h>
25 #include <math.h>
26 #include <float.h>
27
28 #include "gsl_math.h"cxx . . $ `<file>/external/gsl/gsl_math.h`/
29 #include "gsl_errno.h"cxx . . $ `<file>/external/gsl/gsl_errno.h`/
30 #include "gsl_multiroots.h"cxx . . $ `<file>/external/gsl/gsl_multiroots.h`/
31 #include "gsl_linalg.h"cxx . . $ `<file>/external/gsl/gsl_linalg.h`/
32
33 #include "gsl_multiroots__dogleg.c"cxx . . $ `<file>/external/gsl/gsl_multiroots__dogleg.c`/
34
35 typedef structcxx . . $ $anonymous_type_2ea9c544160e9de4_0#
36 {
37 size_t itercxx . . $ $anonymous_type_2ea9c544160e9de4_0#iter.;
38 size_t ncfailcxx . . $ $anonymous_type_2ea9c544160e9de4_0#ncfail.;
39 size_t ncsuccxx . . $ $anonymous_type_2ea9c544160e9de4_0#ncsuc.;
40 size_t nslow1cxx . . $ $anonymous_type_2ea9c544160e9de4_0#nslow1.;
41 size_t nslow2cxx . . $ $anonymous_type_2ea9c544160e9de4_0#nslow2.;
42 double fnormcxx . . $ $anonymous_type_2ea9c544160e9de4_0#fnorm.;
43 double deltacxx . . $ $anonymous_type_2ea9c544160e9de4_0#delta.;
44 gsl_matrixcxx . . $ gsl_matrix# *qcxx . . $ $anonymous_type_2ea9c544160e9de4_0#q.;
45 gsl_matrixcxx . . $ gsl_matrix# *rcxx . . $ $anonymous_type_2ea9c544160e9de4_0#r.;
46 gsl_vectorcxx . . $ gsl_vector# *taucxx . . $ $anonymous_type_2ea9c544160e9de4_0#tau.;
47 gsl_vectorcxx . . $ gsl_vector# *diagcxx . . $ $anonymous_type_2ea9c544160e9de4_0#diag.;
48 gsl_vectorcxx . . $ gsl_vector# *qtfcxx . . $ $anonymous_type_2ea9c544160e9de4_0#qtf.;
49 gsl_vectorcxx . . $ gsl_vector# *newtoncxx . . $ $anonymous_type_2ea9c544160e9de4_0#newton.;
50 gsl_vectorcxx . . $ gsl_vector# *gradientcxx . . $ $anonymous_type_2ea9c544160e9de4_0#gradient.;
51 gsl_vectorcxx . . $ gsl_vector# *x_trialcxx . . $ $anonymous_type_2ea9c544160e9de4_0#x_trial.;
52 gsl_vectorcxx . . $ gsl_vector# *f_trialcxx . . $ $anonymous_type_2ea9c544160e9de4_0#f_trial.;
53 gsl_vectorcxx . . $ gsl_vector# *dfcxx . . $ $anonymous_type_2ea9c544160e9de4_0#df.;
54 gsl_vectorcxx . . $ gsl_vector# *qtdfcxx . . $ $anonymous_type_2ea9c544160e9de4_0#qtdf.;
55 gsl_vectorcxx . . $ gsl_vector# *rdxcxx . . $ $anonymous_type_2ea9c544160e9de4_0#rdx.;
56 gsl_vectorcxx . . $ gsl_vector# *wcxx . . $ $anonymous_type_2ea9c544160e9de4_0#w.;
57 gsl_vectorcxx . . $ gsl_vector# *vcxx . . $ $anonymous_type_2ea9c544160e9de4_0#v.;
58 }
59 hybridj_state_tcxx . . $ hybridj_state_t#;
60
61 static int hybridj_alloccxx . . $ hybridj_alloc(c0a5f96701d3f89). (void *vstate, size_t n);
62 static int hybridj_setcxx . . $ hybridj_set(36a4c1ecdfe5d338). (void *vstate, gsl_multiroot_function_fdfcxx . . $ gsl_multiroot_function_fdf# * fdf, gsl_vectorcxx . . $ gsl_vector# * x, gsl_vectorcxx . . $ gsl_vector# * f, gsl_matrixcxx . . $ gsl_matrix# * J, gsl_vectorcxx . . $ gsl_vector# * dx);
63 static int hybridsj_setcxx . . $ hybridsj_set(36a4c1ecdfe5d338). (void *vstate, gsl_multiroot_function_fdfcxx . . $ gsl_multiroot_function_fdf# * fdf, gsl_vectorcxx . . $ gsl_vector# * x, gsl_vectorcxx . . $ gsl_vector# * f, gsl_matrixcxx . . $ gsl_matrix# * J, gsl_vectorcxx . . $ gsl_vector# * dx);
64 static int setcxx . . $ set(28cb5f2468bf5719). (void *vstate, gsl_multiroot_function_fdfcxx . . $ gsl_multiroot_function_fdf# * fdf, gsl_vectorcxx . . $ gsl_vector# * x, gsl_vectorcxx . . $ gsl_vector# * f, gsl_matrixcxx . . $ gsl_matrix# * J, gsl_vectorcxx . . $ gsl_vector# * dx, int scale);
65 static int hybridj_iteratecxx . . $ hybridj_iterate(36a4c1ecdfe5d338). (void *vstate, gsl_multiroot_function_fdfcxx . . $ gsl_multiroot_function_fdf# * fdf, gsl_vectorcxx . . $ gsl_vector# * x, gsl_vectorcxx . . $ gsl_vector# * f, gsl_matrixcxx . . $ gsl_matrix# * J, gsl_vectorcxx . . $ gsl_vector# * dx);
66 static void hybridj_freecxx . . $ hybridj_free(5d22bdacc48458e8). (void *vstate);
67 static int iteratecxx . . $ iterate(28cb5f2468bf5719). (void *vstate, gsl_multiroot_function_fdfcxx . . $ gsl_multiroot_function_fdf# * fdf, gsl_vectorcxx . . $ gsl_vector# * x, gsl_vectorcxx . . $ gsl_vector# * f, gsl_matrixcxx . . $ gsl_matrix# * J, gsl_vectorcxx . . $ gsl_vector# * dx, int scale);
68
69 static int
70 hybridj_alloccxx . . $ hybridj_alloc(c0a5f96701d3f89). (void *vstate, size_t n)
71 {
72 hybridj_state_tcxx . . $ hybridj_state_t# *state = (hybridj_state_tcxx . . $ hybridj_state_t# *) vstate;
73 gsl_matrixcxx . . $ gsl_matrix# *q, *r;
74 gsl_vectorcxx . . $ gsl_vector# *tau, *diag, *qtf, *newton, *gradient, *x_trial, *f_trial,
75 *df, *qtdf, *rdx, *w, *v;
76
77 q = gsl_matrix_calloccxx . . $ gsl_matrix_calloc(5a4d020b4836594). (n, n);
78
79 if (q == 0)
80 {
81 GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("failed to allocate space for q", GSL_ENOMEM);
82 }
83
84 state->qcxx . . $ $anonymous_type_2ea9c544160e9de4_0#q. = q;
85
86 r = gsl_matrix_calloccxx . . $ gsl_matrix_calloc(5a4d020b4836594). (n, n);
87
88 if (r == 0)
89 {
90 gsl_matrix_freecxx . . $ gsl_matrix_free(ab29a617cccd3636). (q);
91
92 GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("failed to allocate space for r", GSL_ENOMEM);
93 }
94
95 state->rcxx . . $ $anonymous_type_2ea9c544160e9de4_0#r. = r;
96
97 tau = gsl_vector_calloccxx . . $ gsl_vector_calloc(71d9e095f27e8ea9). (n);
98
99 if (tau == 0)
100 {
101 gsl_matrix_freecxx . . $ gsl_matrix_free(ab29a617cccd3636). (q);
102 gsl_matrix_freecxx . . $ gsl_matrix_free(ab29a617cccd3636). (r);
103
104 GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("failed to allocate space for tau", GSL_ENOMEM);
105 }
106
107 state->taucxx . . $ $anonymous_type_2ea9c544160e9de4_0#tau. = tau;
108
109 diag = gsl_vector_calloccxx . . $ gsl_vector_calloc(71d9e095f27e8ea9). (n);
110
111 if (diag == 0)
112 {
113 gsl_matrix_freecxx . . $ gsl_matrix_free(ab29a617cccd3636). (q);
114 gsl_matrix_freecxx . . $ gsl_matrix_free(ab29a617cccd3636). (r);
115 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (tau);
116
117 GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("failed to allocate space for diag", GSL_ENOMEM);
118 }
119
120 state->diagcxx . . $ $anonymous_type_2ea9c544160e9de4_0#diag. = diag;
121
122 qtf = gsl_vector_calloccxx . . $ gsl_vector_calloc(71d9e095f27e8ea9). (n);
123
124 if (qtf == 0)
125 {
126 gsl_matrix_freecxx . . $ gsl_matrix_free(ab29a617cccd3636). (q);
127 gsl_matrix_freecxx . . $ gsl_matrix_free(ab29a617cccd3636). (r);
128 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (tau);
129 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (diag);
130
131 GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("failed to allocate space for qtf", GSL_ENOMEM);
132 }
133
134 state->qtfcxx . . $ $anonymous_type_2ea9c544160e9de4_0#qtf. = qtf;
135
136 newton = gsl_vector_calloccxx . . $ gsl_vector_calloc(71d9e095f27e8ea9). (n);
137
138 if (newton == 0)
139 {
140 gsl_matrix_freecxx . . $ gsl_matrix_free(ab29a617cccd3636). (q);
141 gsl_matrix_freecxx . . $ gsl_matrix_free(ab29a617cccd3636). (r);
142 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (tau);
143 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (diag);
144 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (qtf);
145
146 GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("failed to allocate space for newton", GSL_ENOMEM);
147 }
148
149 state->newtoncxx . . $ $anonymous_type_2ea9c544160e9de4_0#newton. = newton;
150
151 gradient = gsl_vector_calloccxx . . $ gsl_vector_calloc(71d9e095f27e8ea9). (n);
152
153 if (gradient == 0)
154 {
155 gsl_matrix_freecxx . . $ gsl_matrix_free(ab29a617cccd3636). (q);
156 gsl_matrix_freecxx . . $ gsl_matrix_free(ab29a617cccd3636). (r);
157 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (tau);
158 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (diag);
159 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (qtf);
160 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (newton);
161
162 GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("failed to allocate space for gradient", GSL_ENOMEM);
163 }
164
165 state->gradientcxx . . $ $anonymous_type_2ea9c544160e9de4_0#gradient. = gradient;
166
167 x_trial = gsl_vector_calloccxx . . $ gsl_vector_calloc(71d9e095f27e8ea9). (n);
168
169 if (x_trial == 0)
170 {
171 gsl_matrix_freecxx . . $ gsl_matrix_free(ab29a617cccd3636). (q);
172 gsl_matrix_freecxx . . $ gsl_matrix_free(ab29a617cccd3636). (r);
173 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (tau);
174 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (diag);
175 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (qtf);
176 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (newton);
177 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (gradient);
178
179 GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("failed to allocate space for x_trial", GSL_ENOMEM);
180 }
181
182 state->x_trialcxx . . $ $anonymous_type_2ea9c544160e9de4_0#x_trial. = x_trial;
183
184 f_trial = gsl_vector_calloccxx . . $ gsl_vector_calloc(71d9e095f27e8ea9). (n);
185
186 if (f_trial == 0)
187 {
188 gsl_matrix_freecxx . . $ gsl_matrix_free(ab29a617cccd3636). (q);
189 gsl_matrix_freecxx . . $ gsl_matrix_free(ab29a617cccd3636). (r);
190 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (tau);
191 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (diag);
192 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (qtf);
193 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (newton);
194 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (gradient);
195 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (x_trial);
196
197 GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("failed to allocate space for f_trial", GSL_ENOMEM);
198 }
199
200 state->f_trialcxx . . $ $anonymous_type_2ea9c544160e9de4_0#f_trial. = f_trial;
201
202 df = gsl_vector_calloccxx . . $ gsl_vector_calloc(71d9e095f27e8ea9). (n);
203
204 if (df == 0)
205 {
206 gsl_matrix_freecxx . . $ gsl_matrix_free(ab29a617cccd3636). (q);
207 gsl_matrix_freecxx . . $ gsl_matrix_free(ab29a617cccd3636). (r);
208 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (tau);
209 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (diag);
210 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (qtf);
211 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (newton);
212 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (gradient);
213 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (x_trial);
214 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (f_trial);
215
216 GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("failed to allocate space for df", GSL_ENOMEM);
217 }
218
219 state->dfcxx . . $ $anonymous_type_2ea9c544160e9de4_0#df. = df;
220
221 qtdf = gsl_vector_calloccxx . . $ gsl_vector_calloc(71d9e095f27e8ea9). (n);
222
223 if (qtdf == 0)
224 {
225 gsl_matrix_freecxx . . $ gsl_matrix_free(ab29a617cccd3636). (q);
226 gsl_matrix_freecxx . . $ gsl_matrix_free(ab29a617cccd3636). (r);
227 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (tau);
228 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (diag);
229 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (qtf);
230 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (newton);
231 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (gradient);
232 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (x_trial);
233 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (f_trial);
234 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (df);
235
236 GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("failed to allocate space for qtdf", GSL_ENOMEM);
237 }
238
239 state->qtdfcxx . . $ $anonymous_type_2ea9c544160e9de4_0#qtdf. = qtdf;
240
241
242 rdx = gsl_vector_calloccxx . . $ gsl_vector_calloc(71d9e095f27e8ea9). (n);
243
244 if (rdx == 0)
245 {
246 gsl_matrix_freecxx . . $ gsl_matrix_free(ab29a617cccd3636). (q);
247 gsl_matrix_freecxx . . $ gsl_matrix_free(ab29a617cccd3636). (r);
248 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (tau);
249 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (diag);
250 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (qtf);
251 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (newton);
252 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (gradient);
253 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (x_trial);
254 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (f_trial);
255 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (df);
256 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (qtdf);
257
258 GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("failed to allocate space for rdx", GSL_ENOMEM);
259 }
260
261 state->rdxcxx . . $ $anonymous_type_2ea9c544160e9de4_0#rdx. = rdx;
262
263 w = gsl_vector_calloccxx . . $ gsl_vector_calloc(71d9e095f27e8ea9). (n);
264
265 if (w == 0)
266 {
267 gsl_matrix_freecxx . . $ gsl_matrix_free(ab29a617cccd3636). (q);
268 gsl_matrix_freecxx . . $ gsl_matrix_free(ab29a617cccd3636). (r);
269 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (tau);
270 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (diag);
271 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (qtf);
272 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (newton);
273 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (gradient);
274 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (x_trial);
275 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (f_trial);
276 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (df);
277 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (qtdf);
278 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (rdx);
279
280 GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("failed to allocate space for w", GSL_ENOMEM);
281 }
282
283 state->wcxx . . $ $anonymous_type_2ea9c544160e9de4_0#w. = w;
284
285 v = gsl_vector_calloccxx . . $ gsl_vector_calloc(71d9e095f27e8ea9). (n);
286
287 if (v == 0)
288 {
289 gsl_matrix_freecxx . . $ gsl_matrix_free(ab29a617cccd3636). (q);
290 gsl_matrix_freecxx . . $ gsl_matrix_free(ab29a617cccd3636). (r);
291 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (tau);
292 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (diag);
293 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (qtf);
294 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (newton);
295 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (gradient);
296 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (x_trial);
297 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (f_trial);
298 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (df);
299 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (qtdf);
300 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (rdx);
301 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (w);
302
303 GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("failed to allocate space for v", GSL_ENOMEM);
304 }
305
306 state->vcxx . . $ $anonymous_type_2ea9c544160e9de4_0#v. = v;
307
308 return GSL_SUCCESScxx . . $ GSL_SUCCESS.;
309 }
310
311 static int
312 hybridj_setcxx . . $ hybridj_set(36a4c1ecdfe5d338). (void *vstate, gsl_multiroot_function_fdfcxx . . $ gsl_multiroot_function_fdf# * fdf, gsl_vectorcxx . . $ gsl_vector# * x, gsl_vectorcxx . . $ gsl_vector# * f, gsl_matrixcxx . . $ gsl_matrix# * J, gsl_vectorcxx . . $ gsl_vector# * dx)
313 {
314 int status = setcxx . . $ set(28cb5f2468bf5719). (vstate, fdf, x, f, J, dx, 0);
315 return status ;
316 }
317
318 static int
319 hybridsj_setcxx . . $ hybridsj_set(36a4c1ecdfe5d338). (void *vstate, gsl_multiroot_function_fdfcxx . . $ gsl_multiroot_function_fdf# * fdf, gsl_vectorcxx . . $ gsl_vector# * x, gsl_vectorcxx . . $ gsl_vector# * f, gsl_matrixcxx . . $ gsl_matrix# * J, gsl_vectorcxx . . $ gsl_vector# * dx)
320 {
321 int status = setcxx . . $ set(28cb5f2468bf5719). (vstate, fdf, x, f, J, dx, 1);
322 return status ;
323 }
324
325 static int
326 setcxx . . $ set(28cb5f2468bf5719). (void *vstate, gsl_multiroot_function_fdfcxx . . $ gsl_multiroot_function_fdf# * fdf, gsl_vectorcxx . . $ gsl_vector# * x, gsl_vectorcxx . . $ gsl_vector# * f, gsl_matrixcxx . . $ gsl_matrix# * J, gsl_vectorcxx . . $ gsl_vector# * dx, int scale)
327 {
328 hybridj_state_tcxx . . $ hybridj_state_t# *state = (hybridj_state_tcxx . . $ hybridj_state_t# *) vstate;
329
330 gsl_matrixcxx . . $ gsl_matrix# *q = state->qcxx . . $ $anonymous_type_2ea9c544160e9de4_0#q.;
331 gsl_matrixcxx . . $ gsl_matrix# *r = state->rcxx . . $ $anonymous_type_2ea9c544160e9de4_0#r.;
332 gsl_vectorcxx . . $ gsl_vector# *tau = state->taucxx . . $ $anonymous_type_2ea9c544160e9de4_0#tau.;
333 gsl_vectorcxx . . $ gsl_vector# *diag = state->diagcxx . . $ $anonymous_type_2ea9c544160e9de4_0#diag.;
334
335 GSL_MULTIROOT_FN_EVAL_F_DFcxx . . $ `external/gsl/gsl_multiroots.h:114:9`! (fdf, x, f, J);
336
337 state->itercxx . . $ $anonymous_type_2ea9c544160e9de4_0#iter. = 1;
338 state->fnormcxx . . $ $anonymous_type_2ea9c544160e9de4_0#fnorm. = enormcxx . . $ enorm(1b712e435b5359e9). (f);
339 state->ncfailcxx . . $ $anonymous_type_2ea9c544160e9de4_0#ncfail. = 0;
340 state->ncsuccxx . . $ $anonymous_type_2ea9c544160e9de4_0#ncsuc. = 0;
341 state->nslow1cxx . . $ $anonymous_type_2ea9c544160e9de4_0#nslow1. = 0;
342 state->nslow2cxx . . $ $anonymous_type_2ea9c544160e9de4_0#nslow2. = 0;
343
344 gsl_vector_set_allcxx . . $ gsl_vector_set_all(ef7f49ca852b379a). (dx, 0.0);
345
346 /* Store column norms in diag */
347
348 if (scale)
349 compute_diagcxx . . $ compute_diag(3663f5842c4582d6). (J, diag);
350 else
351 gsl_vector_set_allcxx . . $ gsl_vector_set_all(ef7f49ca852b379a). (diag, 1.0);
352
353 /* Set delta to factor |D x| or to factor if |D x| is zero */
354
355 state->deltacxx . . $ $anonymous_type_2ea9c544160e9de4_0#delta. = compute_deltacxx . . $ compute_delta(1175237e67c478b0). (diag, x);
356
357 /* Factorize J into QR decomposition */
358
359 gsl_linalg_QR_decompcxx . . $ gsl_linalg_QR_decomp(2b074ddc1e11e0af). (J, tau);
360 gsl_linalg_QR_unpackcxx . . $ gsl_linalg_QR_unpack(b59274c26d5d73d6). (J, tau, q, r);
361
362 return GSL_SUCCESScxx . . $ GSL_SUCCESS.;
363 }
364
365 static int
366 hybridj_iteratecxx . . $ hybridj_iterate(36a4c1ecdfe5d338). (void *vstate, gsl_multiroot_function_fdfcxx . . $ gsl_multiroot_function_fdf# * fdf, gsl_vectorcxx . . $ gsl_vector# * x, gsl_vectorcxx . . $ gsl_vector# * f, gsl_matrixcxx . . $ gsl_matrix# * J, gsl_vectorcxx . . $ gsl_vector# * dx)
367 {
368 int status = iteratecxx . . $ iterate(28cb5f2468bf5719). (vstate, fdf, x, f, J, dx, 0);
369 return status;
370 }
371
372 static int
373 hybridsj_iteratecxx . . $ hybridsj_iterate(36a4c1ecdfe5d338). (void *vstate, gsl_multiroot_function_fdfcxx . . $ gsl_multiroot_function_fdf# * fdf, gsl_vectorcxx . . $ gsl_vector# * x, gsl_vectorcxx . . $ gsl_vector# * f, gsl_matrixcxx . . $ gsl_matrix# * J, gsl_vectorcxx . . $ gsl_vector# * dx)
374 {
375 int status = iteratecxx . . $ iterate(28cb5f2468bf5719). (vstate, fdf, x, f, J, dx, 1);
376 return status;
377 }
378
379 static int
380 iteratecxx . . $ iterate(28cb5f2468bf5719). (void *vstate, gsl_multiroot_function_fdfcxx . . $ gsl_multiroot_function_fdf# * fdf, gsl_vectorcxx . . $ gsl_vector# * x, gsl_vectorcxx . . $ gsl_vector# * f, gsl_matrixcxx . . $ gsl_matrix# * J, gsl_vectorcxx . . $ gsl_vector# * dx, int scale)
381 {
382 hybridj_state_tcxx . . $ hybridj_state_t# *state = (hybridj_state_tcxx . . $ hybridj_state_t# *) vstate;
383
384 const double fnorm = state->fnormcxx . . $ $anonymous_type_2ea9c544160e9de4_0#fnorm.;
385
386 gsl_matrixcxx . . $ gsl_matrix# *q = state->qcxx . . $ $anonymous_type_2ea9c544160e9de4_0#q.;
387 gsl_matrixcxx . . $ gsl_matrix# *r = state->rcxx . . $ $anonymous_type_2ea9c544160e9de4_0#r.;
388 gsl_vectorcxx . . $ gsl_vector# *tau = state->taucxx . . $ $anonymous_type_2ea9c544160e9de4_0#tau.;
389 gsl_vectorcxx . . $ gsl_vector# *diag = state->diagcxx . . $ $anonymous_type_2ea9c544160e9de4_0#diag.;
390 gsl_vectorcxx . . $ gsl_vector# *qtf = state->qtfcxx . . $ $anonymous_type_2ea9c544160e9de4_0#qtf.;
391 gsl_vectorcxx . . $ gsl_vector# *x_trial = state->x_trialcxx . . $ $anonymous_type_2ea9c544160e9de4_0#x_trial.;
392 gsl_vectorcxx . . $ gsl_vector# *f_trial = state->f_trialcxx . . $ $anonymous_type_2ea9c544160e9de4_0#f_trial.;
393 gsl_vectorcxx . . $ gsl_vector# *df = state->dfcxx . . $ $anonymous_type_2ea9c544160e9de4_0#df.;
394 gsl_vectorcxx . . $ gsl_vector# *qtdf = state->qtdfcxx . . $ $anonymous_type_2ea9c544160e9de4_0#qtdf.;
395 gsl_vectorcxx . . $ gsl_vector# *rdx = state->rdxcxx . . $ $anonymous_type_2ea9c544160e9de4_0#rdx.;
396 gsl_vectorcxx . . $ gsl_vector# *w = state->wcxx . . $ $anonymous_type_2ea9c544160e9de4_0#w.;
397 gsl_vectorcxx . . $ gsl_vector# *v = state->vcxx . . $ $anonymous_type_2ea9c544160e9de4_0#v.;
398
399 double prered, actred;
400 double pnorm, fnorm1, fnorm1p;
401 double ratio;
402 double p1 = 0.1, p5 = 0.5, p001 = 0.001, p0001 = 0.0001;
403
404 /* Compute qtf = Q^T f */
405
406 compute_qtfcxx . . $ compute_qtf(2dce5d0446e62af0). (q, f, qtf);
407
408 /* Compute dogleg step */
409
410 doglegcxx . . $ dogleg(e51e1346f7cff99c). (r, qtf, diag, state->deltacxx . . $ $anonymous_type_2ea9c544160e9de4_0#delta., state->newtoncxx . . $ $anonymous_type_2ea9c544160e9de4_0#newton., state->gradientcxx . . $ $anonymous_type_2ea9c544160e9de4_0#gradient., dx);
411
412 /* Take a trial step */
413
414 compute_trial_stepcxx . . $ compute_trial_step(8bd3db731690f6c2). (x, dx, state->x_trialcxx . . $ $anonymous_type_2ea9c544160e9de4_0#x_trial.);
415
416 pnorm = scaled_enormcxx . . $ scaled_enorm(d7a1c0a0f7c25398). (diag, dx);
417
418 if (state->itercxx . . $ $anonymous_type_2ea9c544160e9de4_0#iter. == 1)
419 {
420 if (pnorm < state->deltacxx . . $ $anonymous_type_2ea9c544160e9de4_0#delta.)
421 {
422 state->deltacxx . . $ $anonymous_type_2ea9c544160e9de4_0#delta. = pnorm;
423 }
424 }
425
426 /* Evaluate function at x + p */
427
428 {
429 int status = GSL_MULTIROOT_FN_EVAL_Fcxx . . $ `external/gsl/gsl_multiroots.h:112:9`! (fdf, x_trial, f_trial);
430
431 if (status != GSL_SUCCESScxx . . $ GSL_SUCCESS.)
432 {
433 return GSL_EBADFUNCcxx . . $ GSL_EBADFUNC.;
434 }
435 }
436
437 /* Set df = f_trial - f */
438
439 compute_dfcxx . . $ compute_df(b69a9b699bde7eae). (f_trial, f, df);
440
441 /* Compute the scaled actual reduction */
442
443 fnorm1 = enormcxx . . $ enorm(1b712e435b5359e9). (f_trial);
444
445 actred = compute_actual_reductioncxx . . $ compute_actual_reduction(d8e7e0733fa41c87). (fnorm, fnorm1);
446
447 /* Compute rdx = R dx */
448
449 compute_rdxcxx . . $ compute_rdx(2dce5d0446e62af0). (r, dx, rdx);
450
451 /* Compute the scaled predicted reduction phi1p = |Q^T f + R dx| */
452
453 fnorm1p = enorm_sumcxx . . $ enorm_sum(d7a1c0a0f7c25398). (qtf, rdx);
454
455 prered = compute_predicted_reductioncxx . . $ compute_predicted_reduction(d8e7e0733fa41c87). (fnorm, fnorm1p);
456
457 /* Compute the ratio of the actual to predicted reduction */
458
459 if (prered > 0)
460 {
461 ratio = actred / prered;
462 }
463 else
464 {
465 ratio = 0;
466 }
467
468 /* Update the step bound */
469
470 if (ratio < p1)
471 {
472 state->ncsuccxx . . $ $anonymous_type_2ea9c544160e9de4_0#ncsuc. = 0;
473 state->ncfailcxx . . $ $anonymous_type_2ea9c544160e9de4_0#ncfail.++;
474 state->deltacxx . . $ $anonymous_type_2ea9c544160e9de4_0#delta. *= p5;
475 }
476 else
477 {
478 state->ncfailcxx . . $ $anonymous_type_2ea9c544160e9de4_0#ncfail. = 0;
479 state->ncsuccxx . . $ $anonymous_type_2ea9c544160e9de4_0#ncsuc.++;
480
481 if (ratio >= p5 || state->ncsuccxx . . $ $anonymous_type_2ea9c544160e9de4_0#ncsuc. > 1)
482 state->deltacxx . . $ $anonymous_type_2ea9c544160e9de4_0#delta. = GSL_MAXcxx . . $ `external/gsl/gsl_math.h:122:9`! (state->delta, pnorm / p5);
483 if (fabscxx . . $ fabs(447c67c6676f75c3). (ratio - 1) <= p1)
484 state->deltacxx . . $ $anonymous_type_2ea9c544160e9de4_0#delta. = pnorm / p5;
485 }
486
487 /* Test for successful iteration */
488
489 if (ratio >= p0001)
490 {
491 gsl_vector_memcpycxx . . $ gsl_vector_memcpy(950c164c4e50c555). (x, x_trial);
492 gsl_vector_memcpycxx . . $ gsl_vector_memcpy(950c164c4e50c555). (f, f_trial);
493 state->fnormcxx . . $ $anonymous_type_2ea9c544160e9de4_0#fnorm. = fnorm1;
494 state->itercxx . . $ $anonymous_type_2ea9c544160e9de4_0#iter.++;
495 }
496
497 /* Determine the progress of the iteration */
498
499 state->nslow1cxx . . $ $anonymous_type_2ea9c544160e9de4_0#nslow1.++;
500 if (actred >= p001)
501 state->nslow1cxx . . $ $anonymous_type_2ea9c544160e9de4_0#nslow1. = 0;
502
503 if (actred >= p1)
504 state->nslow2cxx . . $ $anonymous_type_2ea9c544160e9de4_0#nslow2. = 0;
505
506 if (state->ncfailcxx . . $ $anonymous_type_2ea9c544160e9de4_0#ncfail. == 2)
507 {
508 {
509 int status = GSL_MULTIROOT_FN_EVAL_DFcxx . . $ `external/gsl/gsl_multiroots.h:113:9`! (fdf, x, J);
510
511 if (status != GSL_SUCCESScxx . . $ GSL_SUCCESS.)
512 {
513 return GSL_EBADFUNCcxx . . $ GSL_EBADFUNC.;
514 }
515 }
516
517 state->nslow2cxx . . $ $anonymous_type_2ea9c544160e9de4_0#nslow2.++;
518
519 if (state->itercxx . . $ $anonymous_type_2ea9c544160e9de4_0#iter. == 1)
520 {
521 if (scale)
522 compute_diagcxx . . $ compute_diag(3663f5842c4582d6). (J, diag);
523 state->deltacxx . . $ $anonymous_type_2ea9c544160e9de4_0#delta. = compute_deltacxx . . $ compute_delta(1175237e67c478b0). (diag, x);
524 }
525 else
526 {
527 if (scale)
528 update_diagcxx . . $ update_diag(3663f5842c4582d6). (J, diag);
529 }
530
531 /* Factorize J into QR decomposition */
532
533 gsl_linalg_QR_decompcxx . . $ gsl_linalg_QR_decomp(2b074ddc1e11e0af). (J, tau);
534 gsl_linalg_QR_unpackcxx . . $ gsl_linalg_QR_unpack(b59274c26d5d73d6). (J, tau, q, r);
535 return GSL_SUCCESScxx . . $ GSL_SUCCESS.;
536 }
537
538 /* Compute qtdf = Q^T df, w = (Q^T df - R dx)/|dx|, v = D^2 dx/|dx| */
539
540 compute_qtfcxx . . $ compute_qtf(2dce5d0446e62af0). (q, df, qtdf);
541
542 compute_wvcxx . . $ compute_wv(2c840f80fc6277aa). (qtdf, rdx, dx, diag, pnorm, w, v);
543
544 /* Rank-1 update of the jacobian Q'R' = Q(R + w v^T) */
545
546 gsl_linalg_QR_updatecxx . . $ gsl_linalg_QR_update(9319f07bb2feed5b). (q, r, w, v);
547
548 /* No progress as measured by jacobian evaluations */
549
550 if (state->nslow2cxx . . $ $anonymous_type_2ea9c544160e9de4_0#nslow2. == 5)
551 {
552 return GSL_ENOPROGJcxx . . $ GSL_ENOPROGJ.;
553 }
554
555 /* No progress as measured by function evaluations */
556
557 if (state->nslow1cxx . . $ $anonymous_type_2ea9c544160e9de4_0#nslow1. == 10)
558 {
559 return GSL_ENOPROGcxx . . $ GSL_ENOPROG.;
560 }
561
562 return GSL_SUCCESScxx . . $ GSL_SUCCESS.;
563 }
564
565
566 static void
567 hybridj_freecxx . . $ hybridj_free(5d22bdacc48458e8). (void *vstate)
568 {
569 hybridj_state_tcxx . . $ hybridj_state_t# *state = (hybridj_state_tcxx . . $ hybridj_state_t# *) vstate;
570
571 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (state->vcxx . . $ $anonymous_type_2ea9c544160e9de4_0#v.);
572 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (state->wcxx . . $ $anonymous_type_2ea9c544160e9de4_0#w.);
573 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (state->rdxcxx . . $ $anonymous_type_2ea9c544160e9de4_0#rdx.);
574 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (state->qtdfcxx . . $ $anonymous_type_2ea9c544160e9de4_0#qtdf.);
575 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (state->dfcxx . . $ $anonymous_type_2ea9c544160e9de4_0#df.);
576 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (state->f_trialcxx . . $ $anonymous_type_2ea9c544160e9de4_0#f_trial.);
577 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (state->x_trialcxx . . $ $anonymous_type_2ea9c544160e9de4_0#x_trial.);
578 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (state->gradientcxx . . $ $anonymous_type_2ea9c544160e9de4_0#gradient.);
579 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (state->newtoncxx . . $ $anonymous_type_2ea9c544160e9de4_0#newton.);
580 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (state->qtfcxx . . $ $anonymous_type_2ea9c544160e9de4_0#qtf.);
581 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (state->diagcxx . . $ $anonymous_type_2ea9c544160e9de4_0#diag.);
582 gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (state->taucxx . . $ $anonymous_type_2ea9c544160e9de4_0#tau.);
583 gsl_matrix_freecxx . . $ gsl_matrix_free(ab29a617cccd3636). (state->rcxx . . $ $anonymous_type_2ea9c544160e9de4_0#r.);
584 gsl_matrix_freecxx . . $ gsl_matrix_free(ab29a617cccd3636). (state->qcxx . . $ $anonymous_type_2ea9c544160e9de4_0#q.);
585 }
586
587 static const gsl_multiroot_fdfsolver_typecxx . . $ gsl_multiroot_fdfsolver_type# hybridj_typecxx . . $ hybridj_type. =
588 {
589 "hybridj", /* name */
590 sizeof (hybridj_state_tcxx . . $ hybridj_state_t#),
591 &hybridj_alloccxx . . $ hybridj_alloc(c0a5f96701d3f89).,
592 &hybridj_setcxx . . $ hybridj_set(36a4c1ecdfe5d338).,
593 &hybridj_iteratecxx . . $ hybridj_iterate(36a4c1ecdfe5d338).,
594 &hybridj_freecxx . . $ hybridj_free(5d22bdacc48458e8).
595 };
596
597 static const gsl_multiroot_fdfsolver_typecxx . . $ gsl_multiroot_fdfsolver_type# hybridsj_typecxx . . $ hybridsj_type. =
598 {
599 "hybridsj", /* name */
600 sizeof (hybridj_state_tcxx . . $ hybridj_state_t#),
601 &hybridj_alloccxx . . $ hybridj_alloc(c0a5f96701d3f89).,
602 &hybridsj_setcxx . . $ hybridsj_set(36a4c1ecdfe5d338).,
603 &hybridsj_iteratecxx . . $ hybridsj_iterate(36a4c1ecdfe5d338).,
604 &hybridj_freecxx . . $ hybridj_free(5d22bdacc48458e8).
605 };
606
607 const gsl_multiroot_fdfsolver_typecxx . . $ gsl_multiroot_fdfsolver_type# *gsl_multiroot_fdfsolver_hybridjcxx . . $ gsl_multiroot_fdfsolver_hybridj. = &hybridj_typecxx . . $ hybridj_type.;
608 const gsl_multiroot_fdfsolver_typecxx . . $ gsl_multiroot_fdfsolver_type# *gsl_multiroot_fdfsolver_hybridsjcxx . . $ gsl_multiroot_fdfsolver_hybridsj. = &hybridsj_typecxx . . $ hybridsj_type.;