Debian Codegraph @

external/gsl/gsl_ode-initval__bsimp.c

raw symbols SCIP
1 /* ode-initval/bsimp.c
2 *
3 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004 Gerard Jungman
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 /* Bulirsch-Stoer Implicit */
21
22 /* Author: G. Jungman
23 */
24 /* Bader-Deuflhard implicit extrapolative stepper.
25 * [Numer. Math., 41, 373 (1983)]
26 */
27 #include "gsl__config.h"cxx . . $ `<file>/external/gsl/gsl__config.h`/
28 #include <stdlib.h>
29 #include <string.h>
30 #include "gsl_math.h"cxx . . $ `<file>/external/gsl/gsl_math.h`/
31 #include "gsl_errno.h"cxx . . $ `<file>/external/gsl/gsl_errno.h`/
32 #include "gsl_linalg.h"cxx . . $ `<file>/external/gsl/gsl_linalg.h`/
33 #include "gsl_odeiv.h"cxx . . $ `<file>/external/gsl/gsl_odeiv.h`/
34
35 #include "gsl_ode-initval__odeiv_util.h"cxx . . $ `<file>/external/gsl/gsl_ode-initval__odeiv_util.h`/
36
37 #define SEQUENCE_COUNTcxx . . $ `external/gsl/gsl_ode-initval__bsimp.c:37:9`! 8
38 #define SEQUENCE_MAXcxx . . $ `external/gsl/gsl_ode-initval__bsimp.c:38:9`! 7
39
40 /* Bader-Deuflhard extrapolation sequence */
41 static const int bd_sequencecxx . . $ bd_sequence.[SEQUENCE_COUNTcxx . . $ `external/gsl/gsl_ode-initval__bsimp.c:37:9`!] =
42 { 2, 6, 10, 14, 22, 34, 50, 70 };
43
44 typedef structcxx . . $ $anonymous_type_271c8f60d40fdba7_0#
45 {
46 gsl_matrixcxx . . $ gsl_matrix# *dcxx . . $ $anonymous_type_271c8f60d40fdba7_0#d.; /* workspace for extrapolation */
47 gsl_matrixcxx . . $ gsl_matrix# *a_matcxx . . $ $anonymous_type_271c8f60d40fdba7_0#a_mat.; /* workspace for linear system matrix */
48 gsl_permutationcxx . . $ gsl_permutation# *p_veccxx . . $ $anonymous_type_271c8f60d40fdba7_0#p_vec.; /* workspace for LU permutation */
49
50 double xcxx . . $ $anonymous_type_271c8f60d40fdba7_0#x.[SEQUENCE_MAXcxx . . $ `external/gsl/gsl_ode-initval__bsimp.c:38:9`!]; /* workspace for extrapolation */
51
52 /* state info */
53 size_tcxx . . $ size_t# k_currentcxx . . $ $anonymous_type_271c8f60d40fdba7_0#k_current.;
54 size_tcxx . . $ size_t# k_choicecxx . . $ $anonymous_type_271c8f60d40fdba7_0#k_choice.;
55 double h_nextcxx . . $ $anonymous_type_271c8f60d40fdba7_0#h_next.;
56 double epscxx . . $ $anonymous_type_271c8f60d40fdba7_0#eps.;
57
58 /* workspace for extrapolation step */
59 double *ypcxx . . $ $anonymous_type_271c8f60d40fdba7_0#yp.;
60 double *y_savecxx . . $ $anonymous_type_271c8f60d40fdba7_0#y_save.;
61 double *yerr_savecxx . . $ $anonymous_type_271c8f60d40fdba7_0#yerr_save.;
62 double *y_extrap_savecxx . . $ $anonymous_type_271c8f60d40fdba7_0#y_extrap_save.;
63 double *y_extrap_sequencecxx . . $ $anonymous_type_271c8f60d40fdba7_0#y_extrap_sequence.;
64 double *extrap_workcxx . . $ $anonymous_type_271c8f60d40fdba7_0#extrap_work.;
65 double *dfdtcxx . . $ $anonymous_type_271c8f60d40fdba7_0#dfdt.;
66 double *y_tempcxx . . $ $anonymous_type_271c8f60d40fdba7_0#y_temp.;
67 double *delta_tempcxx . . $ $anonymous_type_271c8f60d40fdba7_0#delta_temp.;
68 double *weightcxx . . $ $anonymous_type_271c8f60d40fdba7_0#weight.;
69 gsl_matrixcxx . . $ gsl_matrix# *dfdycxx . . $ $anonymous_type_271c8f60d40fdba7_0#dfdy.;
70
71 /* workspace for the basic stepper */
72 double *rhs_tempcxx . . $ $anonymous_type_271c8f60d40fdba7_0#rhs_temp.;
73 double *deltacxx . . $ $anonymous_type_271c8f60d40fdba7_0#delta.;
74
75 /* order of last step */
76 size_tcxx . . $ size_t# ordercxx . . $ $anonymous_type_271c8f60d40fdba7_0#order.;
77 }
78 bsimp_state_tcxx . . $ bsimp_state_t#;
79
80 /* Compute weighting factor */
81
82 static void
83 compute_weightscxx . . $ compute_weights(609a03399dd18ac2). (const double y[], double w[], size_tcxx . . $ size_t# dim)
84 {
85 size_tcxx . . $ size_t# i;
86 for (i = 0; i < dim; i++)
87 {
88 double u = fabs(y[i]);
89 w[i] = (u > 0.0) ? u : 1.0;
90 }
91 }
92
93 /* Calculate a choice for the "order" of the method, using the
94 * Deuflhard criteria.
95 */
96
97 static size_tcxx . . $ size_t#
98 bsimp_deuf_kchoicecxx . . $ bsimp_deuf_kchoice(fae394b1ee072f3d). (double eps, size_tcxx . . $ size_t# dimension)
99 {
100 const double safety_f = 0.25;
101 const double small_eps = safety_f * eps;
102
103 double a_work[SEQUENCE_COUNTcxx . . $ `external/gsl/gsl_ode-initval__bsimp.c:37:9`!];
104 double alpha[SEQUENCE_MAXcxx . . $ `external/gsl/gsl_ode-initval__bsimp.c:38:9`!][SEQUENCE_MAXcxx . . $ `external/gsl/gsl_ode-initval__bsimp.c:38:9`!];
105
106 int i, k;
107
108 a_work[0] = bd_sequencecxx . . $ bd_sequence.[0] + 1.0;
109
110 for (k = 0; k < SEQUENCE_MAXcxx . . $ `external/gsl/gsl_ode-initval__bsimp.c:38:9`!; k++)
111 {
112 a_work[k + 1] = a_work[k] + bd_sequencecxx . . $ bd_sequence.[k + 1];
113 }
114
115 for (i = 0; i < SEQUENCE_MAXcxx . . $ `external/gsl/gsl_ode-initval__bsimp.c:38:9`!; i++)
116 {
117 alpha[i][i] = 1.0;
118 for (k = 0; k < i; k++)
119 {
120 const double tmp1 = a_work[k + 1] - a_work[i + 1];
121 const double tmp2 = (a_work[i + 1] - a_work[0] + 1.0) * (2 * k + 1);
122 alpha[k][i] = pow (small_eps, tmp1 / tmp2);
123 }
124 }
125
126 a_work[0] += dimension;
127
128 for (k = 0; k < SEQUENCE_MAXcxx . . $ `external/gsl/gsl_ode-initval__bsimp.c:38:9`!; k++)
129 {
130 a_work[k + 1] = a_work[k] + bd_sequencecxx . . $ bd_sequence.[k + 1];
131 }
132
133 for (k = 0; k < SEQUENCE_MAXcxx . . $ `external/gsl/gsl_ode-initval__bsimp.c:38:9`! - 1; k++)
134 {
135 if (a_work[k + 2] > a_work[k + 1] * alpha[k][k + 1])
136 break;
137 }
138
139 return k;
140 }
141
142 static void
143 poly_extrapcxx . . $ poly_extrap(bfcc40cac40a29a4). (gsl_matrixcxx . . $ gsl_matrix# * d,
144 const double x[],
145 const unsigned int i_step,
146 const double x_i,
147 const double y_i[],
148 double y_0[], double y_0_err[], double work[], const size_tcxx . . $ size_t# dim)
149 {
150 size_tcxx . . $ size_t# j, k;
151
152 DBL_MEMCPYcxx . . $ `external/gsl/gsl_ode-initval__odeiv_util.h:1:9`! (y_0_err, y_i, dim);
153 DBL_MEMCPYcxx . . $ `external/gsl/gsl_ode-initval__odeiv_util.h:1:9`! (y_0, y_i, dim);
154
155 if (i_step == 0)
156 {
157 for (j = 0; j < dim; j++)
158 {
159 gsl_matrix_setcxx . . $ gsl_matrix_set(b56d954874bd7b13). (d, 0, j, y_i[j]);
160 }
161 }
162 else
163 {
164 DBL_MEMCPYcxx . . $ `external/gsl/gsl_ode-initval__odeiv_util.h:1:9`! (work, y_i, dim);
165
166 for (k = 0; k < i_step; k++)
167 {
168 double delta = 1.0 / (x[i_step - k - 1] - x_i);
169 const double f1 = delta * x_i;
170 const double f2 = delta * x[i_step - k - 1];
171
172 for (j = 0; j < dim; j++)
173 {
174 const double q_kj = gsl_matrix_getcxx . . $ gsl_matrix_get(dfa4c0641bd665a5). (d, k, j);
175 gsl_matrix_setcxx . . $ gsl_matrix_set(b56d954874bd7b13). (d, k, j, y_0_err[j]);
176 delta = work[j] - q_kj;
177 y_0_err[j] = f1 * delta;
178 work[j] = f2 * delta;
179 y_0[j] += y_0_err[j];
180 }
181 }
182
183 for (j = 0; j < dim; j++)
184 {
185 gsl_matrix_setcxx . . $ gsl_matrix_set(b56d954874bd7b13). (d, i_step, j, y_0_err[j]);
186 }
187 }
188 }
189
190 /* Basic implicit Bulirsch-Stoer step. Divide the step h_total into
191 * n_step smaller steps and do the Bader-Deuflhard semi-implicit
192 * iteration. */
193
194 static int
195 bsimp_step_localcxx . . $ bsimp_step_local(a03f7f8feda6750). (void *vstate,
196 size_tcxx . . $ size_t# dim,
197 const double t0,
198 const double h_total,
199 const unsigned int n_step,
200 const double y[],
201 const double yp[],
202 const double dfdt[],
203 const gsl_matrixcxx . . $ gsl_matrix# * dfdy,
204 double y_out[],
205 const gsl_odeiv_systemcxx . . $ gsl_odeiv_system# * sys)
206 {
207 bsimp_state_tcxx . . $ bsimp_state_t# *state = (bsimp_state_tcxx . . $ bsimp_state_t# *) vstate;
208
209 gsl_matrixcxx . . $ gsl_matrix# *const a_mat = state->a_matcxx . . $ $anonymous_type_271c8f60d40fdba7_0#a_mat.;
210 gsl_permutationcxx . . $ gsl_permutation# *const p_vec = state->p_veccxx . . $ $anonymous_type_271c8f60d40fdba7_0#p_vec.;
211
212 double *const delta = state->deltacxx . . $ $anonymous_type_271c8f60d40fdba7_0#delta.;
213 double *const y_temp = state->y_tempcxx . . $ $anonymous_type_271c8f60d40fdba7_0#y_temp.;
214 double *const delta_temp = state->delta_tempcxx . . $ $anonymous_type_271c8f60d40fdba7_0#delta_temp.;
215 double *const rhs_temp = state->rhs_tempcxx . . $ $anonymous_type_271c8f60d40fdba7_0#rhs_temp.;
216 double *const w = state->weightcxx . . $ $anonymous_type_271c8f60d40fdba7_0#weight.;
217
218 gsl_vector_viewcxx . . $ gsl_vector_view# y_temp_vec = gsl_vector_view_arraycxx . . $ gsl_vector_view_array(8bd5fb11e568e882). (y_temp, dim);
219 gsl_vector_viewcxx . . $ gsl_vector_view# delta_temp_vec = gsl_vector_view_arraycxx . . $ gsl_vector_view_array(8bd5fb11e568e882). (delta_temp, dim);
220 gsl_vector_viewcxx . . $ gsl_vector_view# rhs_temp_vec = gsl_vector_view_arraycxx . . $ gsl_vector_view_array(8bd5fb11e568e882). (rhs_temp, dim);
221
222 const double h = h_total / n_step;
223 double t = t0 + h;
224
225 double sum;
226
227 /* This is the factor sigma referred to in equation 3.4 of the
228 paper. A relative change in y exceeding sigma indicates a
229 runaway behavior. According to the authors suitable values for
230 sigma are >>1. I have chosen a value of 100*dim. BJG */
231
232 const double max_sum = 100.0 * dim;
233
234 int signum, status;
235 size_tcxx . . $ size_t# i, j;
236 size_tcxx . . $ size_t# n_inter;
237
238 /* Calculate the matrix for the linear system. */
239 for (i = 0; i < dim; i++)
240 {
241 for (j = 0; j < dim; j++)
242 {
243 gsl_matrix_setcxx . . $ gsl_matrix_set(b56d954874bd7b13). (a_mat, i, j, -h * gsl_matrix_getcxx . . $ gsl_matrix_get(dfa4c0641bd665a5). (dfdy, i, j));
244 }
245 gsl_matrix_setcxx . . $ gsl_matrix_set(b56d954874bd7b13). (a_mat, i, i, gsl_matrix_getcxx . . $ gsl_matrix_get(dfa4c0641bd665a5). (a_mat, i, i) + 1.0);
246 }
247
248 /* LU decomposition for the linear system. */
249
250 gsl_linalg_LU_decompcxx . . $ gsl_linalg_LU_decomp(e9d4741e9a7c7a22). (a_mat, p_vec, &signum);
251
252 /* Compute weighting factors */
253
254 compute_weightscxx . . $ compute_weights(609a03399dd18ac2). (y, w, dim);
255
256 /* Initial step. */
257
258 for (i = 0; i < dim; i++)
259 {
260 y_temp[i] = h * (yp[i] + h * dfdt[i]);
261 }
262
263 gsl_linalg_LU_solvecxx . . $ gsl_linalg_LU_solve(58522a8301ae2475). (a_mat, p_vec, &y_temp_vec.vectorcxx . . $ $anonymous_type_a8c2e3e00d6867c2_1#vector., &delta_temp_vec.vectorcxx . . $ $anonymous_type_a8c2e3e00d6867c2_1#vector.);
264
265 sum = 0.0;
266
267 for (i = 0; i < dim; i++)
268 {
269 const double di = delta_temp[i];
270 delta[i] = di;
271 y_temp[i] = y[i] + di;
272 sum += fabs(di) / w[i];
273 }
274
275 if (sum > max_sum)
276 {
277 return GSL_EFAILEDcxx . . $ GSL_EFAILED. ;
278 }
279
280 /* Intermediate steps. */
281
282 status = GSL_ODEIV_FN_EVALcxx . . $ `external/gsl/gsl_odeiv.h:67:9`! (sys, t, y_temp, y_out);
283
284 if (status)
285 {
286 return status;
287 }
288
289 for (n_inter = 1; n_inter < n_step; n_inter++)
290 {
291 for (i = 0; i < dim; i++)
292 {
293 rhs_temp[i] = h * y_out[i] - delta[i];
294 }
295
296 gsl_linalg_LU_solvecxx . . $ gsl_linalg_LU_solve(58522a8301ae2475). (a_mat, p_vec, &rhs_temp_vec.vectorcxx . . $ $anonymous_type_a8c2e3e00d6867c2_1#vector., &delta_temp_vec.vectorcxx . . $ $anonymous_type_a8c2e3e00d6867c2_1#vector.);
297
298 sum = 0.0;
299
300 for (i = 0; i < dim; i++)
301 {
302 delta[i] += 2.0 * delta_temp[i];
303 y_temp[i] += delta[i];
304 sum += fabs(delta[i]) / w[i];
305 }
306
307 if (sum > max_sum)
308 {
309 return GSL_EFAILEDcxx . . $ GSL_EFAILED. ;
310 }
311
312 t += h;
313
314 status = GSL_ODEIV_FN_EVALcxx . . $ `external/gsl/gsl_odeiv.h:67:9`! (sys, t, y_temp, y_out);
315
316 if (status)
317 {
318 return status;
319 }
320 }
321
322
323 /* Final step. */
324
325 for (i = 0; i < dim; i++)
326 {
327 rhs_temp[i] = h * y_out[i] - delta[i];
328 }
329
330 gsl_linalg_LU_solvecxx . . $ gsl_linalg_LU_solve(58522a8301ae2475). (a_mat, p_vec, &rhs_temp_vec.vectorcxx . . $ $anonymous_type_a8c2e3e00d6867c2_1#vector., &delta_temp_vec.vectorcxx . . $ $anonymous_type_a8c2e3e00d6867c2_1#vector.);
331
332 sum = 0.0;
333
334 for (i = 0; i < dim; i++)
335 {
336 y_out[i] = y_temp[i] + delta_temp[i];
337 sum += fabs(delta_temp[i]) / w[i];
338 }
339
340 if (sum > max_sum)
341 {
342 return GSL_EFAILEDcxx . . $ GSL_EFAILED. ;
343 }
344
345 return GSL_SUCCESScxx . . $ GSL_SUCCESS.;
346 }
347
348
349 static void *
350 bsimp_alloccxx . . $ bsimp_alloc(bfcfa4d6b7f7ef64). (size_tcxx . . $ size_t# dim)
351 {
352 bsimp_state_tcxx . . $ bsimp_state_t# *state = (bsimp_state_tcxx . . $ bsimp_state_t# *) malloccxx . . $ malloc(bfcfa4d6b7f7ef64). (sizeof (bsimp_state_tcxx . . $ bsimp_state_t#));
353
354 state->dcxx . . $ $anonymous_type_271c8f60d40fdba7_0#d. = gsl_matrix_alloccxx . . $ gsl_matrix_alloc(5a4d020b4836594). (SEQUENCE_MAXcxx . . $ `external/gsl/gsl_ode-initval__bsimp.c:38:9`!, dim);
355 state->a_matcxx . . $ $anonymous_type_271c8f60d40fdba7_0#a_mat. = gsl_matrix_alloccxx . . $ gsl_matrix_alloc(5a4d020b4836594). (dim, dim);
356 state->p_veccxx . . $ $anonymous_type_271c8f60d40fdba7_0#p_vec. = gsl_permutation_alloccxx . . $ gsl_permutation_alloc(311f4cfee96dd0e3). (dim);
357
358 state->ypcxx . . $ $anonymous_type_271c8f60d40fdba7_0#yp. = (double *) malloccxx . . $ malloc(bfcfa4d6b7f7ef64). (dim * sizeof (double));
359 state->y_savecxx . . $ $anonymous_type_271c8f60d40fdba7_0#y_save. = (double *) malloccxx . . $ malloc(bfcfa4d6b7f7ef64). (dim * sizeof (double));
360 state->yerr_savecxx . . $ $anonymous_type_271c8f60d40fdba7_0#yerr_save. = (double *) malloccxx . . $ malloc(bfcfa4d6b7f7ef64). (dim * sizeof (double));
361 state->y_extrap_savecxx . . $ $anonymous_type_271c8f60d40fdba7_0#y_extrap_save. = (double *) malloccxx . . $ malloc(bfcfa4d6b7f7ef64). (dim * sizeof (double));
362 state->y_extrap_sequencecxx . . $ $anonymous_type_271c8f60d40fdba7_0#y_extrap_sequence. = (double *) malloccxx . . $ malloc(bfcfa4d6b7f7ef64). (dim * sizeof (double));
363 state->extrap_workcxx . . $ $anonymous_type_271c8f60d40fdba7_0#extrap_work. = (double *) malloccxx . . $ malloc(bfcfa4d6b7f7ef64). (dim * sizeof (double));
364 state->dfdtcxx . . $ $anonymous_type_271c8f60d40fdba7_0#dfdt. = (double *) malloccxx . . $ malloc(bfcfa4d6b7f7ef64). (dim * sizeof (double));
365 state->y_tempcxx . . $ $anonymous_type_271c8f60d40fdba7_0#y_temp. = (double *) malloccxx . . $ malloc(bfcfa4d6b7f7ef64). (dim * sizeof (double));
366 state->delta_tempcxx . . $ $anonymous_type_271c8f60d40fdba7_0#delta_temp. = (double *) malloccxx . . $ malloc(bfcfa4d6b7f7ef64). (dim * sizeof(double));
367 state->weightcxx . . $ $anonymous_type_271c8f60d40fdba7_0#weight. = (double *) malloccxx . . $ malloc(bfcfa4d6b7f7ef64). (dim * sizeof(double));
368
369 state->dfdycxx . . $ $anonymous_type_271c8f60d40fdba7_0#dfdy. = gsl_matrix_alloccxx . . $ gsl_matrix_alloc(5a4d020b4836594). (dim, dim);
370
371 state->rhs_tempcxx . . $ $anonymous_type_271c8f60d40fdba7_0#rhs_temp. = (double *) malloccxx . . $ malloc(bfcfa4d6b7f7ef64). (dim * sizeof(double));
372 state->deltacxx . . $ $anonymous_type_271c8f60d40fdba7_0#delta. = (double *) malloccxx . . $ malloc(bfcfa4d6b7f7ef64). (dim * sizeof (double));
373
374 {
375 size_tcxx . . $ size_t# k_choice = bsimp_deuf_kchoicecxx . . $ bsimp_deuf_kchoice(fae394b1ee072f3d). (GSL_SQRT_DBL_EPSILONcxx . . $ `external/gsl/gsl_machine.h:18:9`!, dim); /*FIXME: choice of epsilon? */
376 state->k_choicecxx . . $ $anonymous_type_271c8f60d40fdba7_0#k_choice. = k_choice;
377 state->k_currentcxx . . $ $anonymous_type_271c8f60d40fdba7_0#k_current. = k_choice;
378 state->ordercxx . . $ $anonymous_type_271c8f60d40fdba7_0#order. = 2 * k_choice;
379 }
380
381 state->h_nextcxx . . $ $anonymous_type_271c8f60d40fdba7_0#h_next. = -GSL_SQRT_DBL_MAXcxx . . $ `external/gsl/gsl_machine.h:34:9`!;
382
383 return state;
384 }
385
386 /* Perform the basic semi-implicit extrapolation
387 * step, of size h, at a Deuflhard determined order.
388 */
389 static int
390 bsimp_applycxx . . $ bsimp_apply(46f97775c18f9353). (void *vstate,
391 size_tcxx . . $ size_t# dim,
392 double t,
393 double h,
394 double y[],
395 double yerr[],
396 const double dydt_in[],
397 double dydt_out[],
398 const gsl_odeiv_systemcxx . . $ gsl_odeiv_system# * sys)
399 {
400 bsimp_state_tcxx . . $ bsimp_state_t# *state = (bsimp_state_tcxx . . $ bsimp_state_t# *) vstate;
401
402 double *const x = state->xcxx . . $ $anonymous_type_271c8f60d40fdba7_0#x.;
403 double *const yp = state->ypcxx . . $ $anonymous_type_271c8f60d40fdba7_0#yp.;
404 double *const y_save = state->y_savecxx . . $ $anonymous_type_271c8f60d40fdba7_0#y_save.;
405 double *const yerr_save = state->yerr_savecxx . . $ $anonymous_type_271c8f60d40fdba7_0#yerr_save.;
406 double *const y_extrap_sequence = state->y_extrap_sequencecxx . . $ $anonymous_type_271c8f60d40fdba7_0#y_extrap_sequence.;
407 double *const y_extrap_save = state->y_extrap_savecxx . . $ $anonymous_type_271c8f60d40fdba7_0#y_extrap_save.;
408 double *const extrap_work = state->extrap_workcxx . . $ $anonymous_type_271c8f60d40fdba7_0#extrap_work.;
409 double *const dfdt = state->dfdtcxx . . $ $anonymous_type_271c8f60d40fdba7_0#dfdt.;
410 gsl_matrixcxx . . $ gsl_matrix# *d = state->dcxx . . $ $anonymous_type_271c8f60d40fdba7_0#d.;
411 gsl_matrixcxx . . $ gsl_matrix# *dfdy = state->dfdycxx . . $ $anonymous_type_271c8f60d40fdba7_0#dfdy.;
412
413 const double t_local = t;
414 size_tcxx . . $ size_t# i, k;
415
416 if (h + t_local == t_local)
417 {
418 return GSL_EUNDRFLWcxx . . $ GSL_EUNDRFLW.; /* FIXME: error condition */
419 }
420
421 DBL_MEMCPYcxx . . $ `external/gsl/gsl_ode-initval__odeiv_util.h:1:9`! (y_extrap_save, y, dim);
422
423 /* Save inputs */
424 DBL_MEMCPYcxx . . $ `external/gsl/gsl_ode-initval__odeiv_util.h:1:9`! (y_save, y, dim);
425 DBL_MEMCPYcxx . . $ `external/gsl/gsl_ode-initval__odeiv_util.h:1:9`! (yerr_save, yerr, dim);
426
427 /* Evaluate the derivative. */
428 if (dydt_in != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
429 {
430 DBL_MEMCPYcxx . . $ `external/gsl/gsl_ode-initval__odeiv_util.h:1:9`! (yp, dydt_in, dim);
431 }
432 else
433 {
434 int s = GSL_ODEIV_FN_EVALcxx . . $ `external/gsl/gsl_odeiv.h:67:9`! (sys, t_local, y, yp);
435
436 if (s != GSL_SUCCESScxx . . $ GSL_SUCCESS.)
437 {
438 return s;
439 }
440 }
441
442 /* Evaluate the Jacobian for the system. */
443 {
444 int s = GSL_ODEIV_JA_EVALcxx . . $ `external/gsl/gsl_odeiv.h:68:9`! (sys, t_local, y, dfdy->data, dfdt);
445
446 if (s != GSL_SUCCESScxx . . $ GSL_SUCCESS.)
447 {
448 return s;
449 }
450 }
451
452 /* Make a series of refined extrapolations,
453 * up to the specified maximum order, which
454 * was calculated based on the Deuflhard
455 * criterion upon state initialization. */
456 for (k = 0; k <= state->k_currentcxx . . $ $anonymous_type_271c8f60d40fdba7_0#k_current.; k++)
457 {
458 const unsigned int N = bd_sequencecxx . . $ bd_sequence.[k];
459 const double r = (h / N);
460 const double x_k = r * r;
461
462 int status = bsimp_step_localcxx . . $ bsimp_step_local(a03f7f8feda6750). (state,
463 dim, t_local, h, N,
464 y_extrap_save, yp,
465 dfdt, dfdy,
466 y_extrap_sequence,
467 sys);
468
469 if (status == GSL_EFAILEDcxx . . $ GSL_EFAILED.)
470 {
471 /* If the local step fails, set the error to infinity in
472 order to force a reduction in the step size */
473
474 for (i = 0; i < dim; i++)
475 {
476 yerr[i] = GSL_POSINFcxx . . $ `external/gsl/gsl_nan.h:24:10`!;
477 }
478
479 break;
480 }
481
482 else if (status != GSL_SUCCESScxx . . $ GSL_SUCCESS.)
483 {
484 return status;
485 }
486
487 x[k] = x_k;
488
489 poly_extrapcxx . . $ poly_extrap(bfcc40cac40a29a4). (d, x, k, x_k, y_extrap_sequence, y, yerr, extrap_work, dim);
490 }
491
492 /* Evaluate dydt_out[]. */
493
494 if (dydt_out != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
495 {
496 int s = GSL_ODEIV_FN_EVALcxx . . $ `external/gsl/gsl_odeiv.h:67:9`! (sys, t + h, y, dydt_out);
497
498 if (s != GSL_SUCCESScxx . . $ GSL_SUCCESS.)
499 {
500 DBL_MEMCPYcxx . . $ `external/gsl/gsl_ode-initval__odeiv_util.h:1:9`! (y, y_save, dim);
501 DBL_MEMCPYcxx . . $ `external/gsl/gsl_ode-initval__odeiv_util.h:1:9`! (yerr, yerr_save, dim);
502 return s;
503 }
504 }
505
506 return GSL_SUCCESScxx . . $ GSL_SUCCESS.;
507 }
508
509 static unsigned int
510 bsimp_ordercxx . . $ bsimp_order(6769d0e399bf81e3). (void *vstate)
511 {
512 bsimp_state_tcxx . . $ bsimp_state_t# *state = (bsimp_state_tcxx . . $ bsimp_state_t# *) vstate;
513 return state->ordercxx . . $ $anonymous_type_271c8f60d40fdba7_0#order.;
514 }
515
516 static int
517 bsimp_resetcxx . . $ bsimp_reset(c0a5f96701d3f89). (void *vstate, size_tcxx . . $ size_t# dim)
518 {
519 bsimp_state_tcxx . . $ bsimp_state_t# *state = (bsimp_state_tcxx . . $ bsimp_state_t# *) vstate;
520
521 state->h_nextcxx . . $ $anonymous_type_271c8f60d40fdba7_0#h_next. = 0;
522
523 DBL_ZERO_MEMSETcxx . . $ `external/gsl/gsl_ode-initval__odeiv_util.h:2:9`! (state->yp, dim);
524
525 return GSL_SUCCESScxx . . $ GSL_SUCCESS.;
526 }
527
528
529 static void
530 bsimp_freecxx . . $ bsimp_free(5d22bdacc48458e8). (void * vstate)
531 {
532 bsimp_state_tcxx . . $ bsimp_state_t# *state = (bsimp_state_tcxx . . $ bsimp_state_t# *) vstate;
533
534 freecxx . . $ free(5d22bdacc48458e8). (state->deltacxx . . $ $anonymous_type_271c8f60d40fdba7_0#delta.);
535 freecxx . . $ free(5d22bdacc48458e8). (state->rhs_tempcxx . . $ $anonymous_type_271c8f60d40fdba7_0#rhs_temp.);
536
537 gsl_matrix_freecxx . . $ gsl_matrix_free(ab29a617cccd3636). (state->dfdycxx . . $ $anonymous_type_271c8f60d40fdba7_0#dfdy.);
538
539 freecxx . . $ free(5d22bdacc48458e8). (state->weightcxx . . $ $anonymous_type_271c8f60d40fdba7_0#weight.);
540 freecxx . . $ free(5d22bdacc48458e8). (state->delta_tempcxx . . $ $anonymous_type_271c8f60d40fdba7_0#delta_temp.);
541 freecxx . . $ free(5d22bdacc48458e8). (state->y_tempcxx . . $ $anonymous_type_271c8f60d40fdba7_0#y_temp.);
542 freecxx . . $ free(5d22bdacc48458e8). (state->dfdtcxx . . $ $anonymous_type_271c8f60d40fdba7_0#dfdt.);
543 freecxx . . $ free(5d22bdacc48458e8). (state->extrap_workcxx . . $ $anonymous_type_271c8f60d40fdba7_0#extrap_work.);
544 freecxx . . $ free(5d22bdacc48458e8). (state->y_extrap_sequencecxx . . $ $anonymous_type_271c8f60d40fdba7_0#y_extrap_sequence.);
545 freecxx . . $ free(5d22bdacc48458e8). (state->y_extrap_savecxx . . $ $anonymous_type_271c8f60d40fdba7_0#y_extrap_save.);
546 freecxx . . $ free(5d22bdacc48458e8). (state->y_savecxx . . $ $anonymous_type_271c8f60d40fdba7_0#y_save.);
547 freecxx . . $ free(5d22bdacc48458e8). (state->yerr_savecxx . . $ $anonymous_type_271c8f60d40fdba7_0#yerr_save.);
548 freecxx . . $ free(5d22bdacc48458e8). (state->ypcxx . . $ $anonymous_type_271c8f60d40fdba7_0#yp.);
549
550 gsl_permutation_freecxx . . $ gsl_permutation_free(bfe6c130f63679fa). (state->p_veccxx . . $ $anonymous_type_271c8f60d40fdba7_0#p_vec.);
551 gsl_matrix_freecxx . . $ gsl_matrix_free(ab29a617cccd3636). (state->a_matcxx . . $ $anonymous_type_271c8f60d40fdba7_0#a_mat.);
552 gsl_matrix_freecxx . . $ gsl_matrix_free(ab29a617cccd3636). (state->dcxx . . $ $anonymous_type_271c8f60d40fdba7_0#d.);
553 freecxx . . $ free(5d22bdacc48458e8). (state);
554 }
555
556 static const gsl_odeiv_step_typecxx . . $ gsl_odeiv_step_type# bsimp_typecxx . . $ bsimp_type. = {
557 "bsimp", /* name */
558 1, /* can use dydt_in */
559 1, /* gives exact dydt_out */
560 &bsimp_alloccxx . . $ bsimp_alloc(bfcfa4d6b7f7ef64).,
561 &bsimp_applycxx . . $ bsimp_apply(46f97775c18f9353).,
562 &bsimp_resetcxx . . $ bsimp_reset(c0a5f96701d3f89).,
563 &bsimp_ordercxx . . $ bsimp_order(6769d0e399bf81e3).,
564 &bsimp_freecxx . . $ bsimp_free(5d22bdacc48458e8).
565 };
566
567 const gsl_odeiv_step_typecxx . . $ gsl_odeiv_step_type# *gsl_odeiv_step_bsimpcxx . . $ gsl_odeiv_step_bsimp. = &bsimp_typecxx . . $ bsimp_type.;