| 1 | /* ode-initval/rk2simp.c |
| 2 | * |
| 3 | * Copyright (C) 2004 Tuomo Keskitalo |
| 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 | /* Runge-Kutta 2, Gaussian implicit. Also known as implicit midpoint rule. |
| 21 | |
| 22 | Non-linear equations solved by linearization, LU-decomposition |
| 23 | and matrix inversion. For reference, see eg. |
| 24 | |
| 25 | Ascher, U.M., Petzold, L.R., Computer methods for ordinary |
| 26 | differential and differential-algebraic equations, SIAM, |
| 27 | Philadelphia, 1998. |
| 28 | */ |
| 29 | |
| 30 | #include "gsl__config.h"cxx . . $ `<file>/external/gsl/gsl__config.h`/ |
| 31 | #include <stdlib.h> |
| 32 | #include <string.h> |
| 33 | #include "gsl_math.h"cxx . . $ `<file>/external/gsl/gsl_math.h`/ |
| 34 | #include "gsl_errno.h"cxx . . $ `<file>/external/gsl/gsl_errno.h`/ |
| 35 | #include "gsl_odeiv.h"cxx . . $ `<file>/external/gsl/gsl_odeiv.h`/ |
| 36 | #include "gsl_linalg.h"cxx . . $ `<file>/external/gsl/gsl_linalg.h`/ |
| 37 | |
| 38 | #include "gsl_ode-initval__odeiv_util.h"cxx . . $ `<file>/external/gsl/gsl_ode-initval__odeiv_util.h`/ |
| 39 | |
| 40 | typedef structcxx . . $ $anonymous_type_86d77917ada7425c_0# |
| 41 | { |
| 42 | double *Y1cxx . . $ $anonymous_type_86d77917ada7425c_0#Y1.; |
| 43 | double *y0cxx . . $ $anonymous_type_86d77917ada7425c_0#y0.; |
| 44 | double *y0_origcxx . . $ $anonymous_type_86d77917ada7425c_0#y0_orig.; |
| 45 | double *ytmpcxx . . $ $anonymous_type_86d77917ada7425c_0#ytmp.; |
| 46 | double *dfdycxx . . $ $anonymous_type_86d77917ada7425c_0#dfdy.; /* Jacobian */ |
| 47 | double *dfdtcxx . . $ $anonymous_type_86d77917ada7425c_0#dfdt.; /* time derivatives, not used */ |
| 48 | double *y_onestepcxx . . $ $anonymous_type_86d77917ada7425c_0#y_onestep.; |
| 49 | gsl_permutationcxx . . $ gsl_permutation# *pcxx . . $ $anonymous_type_86d77917ada7425c_0#p.; |
| 50 | } |
| 51 | rk2simp_state_tcxx . . $ rk2simp_state_t#; |
| 52 | |
| 53 | static void * |
| 54 | rk2simp_alloccxx . . $ rk2simp_alloc(bfcfa4d6b7f7ef64). (size_t dim) |
| 55 | { |
| 56 | rk2simp_state_tcxx . . $ rk2simp_state_t# *state = |
| 57 | (rk2simp_state_tcxx . . $ rk2simp_state_t# *) malloccxx . . $ malloc(bfcfa4d6b7f7ef64). (sizeof (rk2simp_state_tcxx . . $ rk2simp_state_t#)); |
| 58 | |
| 59 | if (state == 0) |
| 60 | { |
| 61 | GSL_ERROR_NULLcxx . . $ `external/gsl/gsl_errno.h:129:9`! ("failed to allocate space for rk2simp_state", |
| 62 | GSL_ENOMEM); |
| 63 | } |
| 64 | |
| 65 | state->Y1cxx . . $ $anonymous_type_86d77917ada7425c_0#Y1. = (double *) malloccxx . . $ malloc(bfcfa4d6b7f7ef64). (dim * sizeof (double)); |
| 66 | |
| 67 | if (state->Y1cxx . . $ $anonymous_type_86d77917ada7425c_0#Y1. == 0) |
| 68 | { |
| 69 | freecxx . . $ free(5d22bdacc48458e8). (state); |
| 70 | GSL_ERROR_NULLcxx . . $ `external/gsl/gsl_errno.h:129:9`! ("failed to allocate space for Y1", GSL_ENOMEM); |
| 71 | } |
| 72 | |
| 73 | state->y0cxx . . $ $anonymous_type_86d77917ada7425c_0#y0. = (double *) malloccxx . . $ malloc(bfcfa4d6b7f7ef64). (dim * sizeof (double)); |
| 74 | |
| 75 | if (state->y0cxx . . $ $anonymous_type_86d77917ada7425c_0#y0. == 0) |
| 76 | { |
| 77 | freecxx . . $ free(5d22bdacc48458e8). (state->Y1cxx . . $ $anonymous_type_86d77917ada7425c_0#Y1.); |
| 78 | freecxx . . $ free(5d22bdacc48458e8). (state); |
| 79 | GSL_ERROR_NULLcxx . . $ `external/gsl/gsl_errno.h:129:9`! ("failed to allocate space for y0", GSL_ENOMEM); |
| 80 | } |
| 81 | |
| 82 | state->y0_origcxx . . $ $anonymous_type_86d77917ada7425c_0#y0_orig. = (double *) malloccxx . . $ malloc(bfcfa4d6b7f7ef64). (dim * sizeof (double)); |
| 83 | |
| 84 | if (state->y0_origcxx . . $ $anonymous_type_86d77917ada7425c_0#y0_orig. == 0) |
| 85 | { |
| 86 | freecxx . . $ free(5d22bdacc48458e8). (state->Y1cxx . . $ $anonymous_type_86d77917ada7425c_0#Y1.); |
| 87 | freecxx . . $ free(5d22bdacc48458e8). (state->y0cxx . . $ $anonymous_type_86d77917ada7425c_0#y0.); |
| 88 | freecxx . . $ free(5d22bdacc48458e8). (state); |
| 89 | GSL_ERROR_NULLcxx . . $ `external/gsl/gsl_errno.h:129:9`! ("failed to allocate space for y0_orig", GSL_ENOMEM); |
| 90 | } |
| 91 | |
| 92 | state->ytmpcxx . . $ $anonymous_type_86d77917ada7425c_0#ytmp. = (double *) malloccxx . . $ malloc(bfcfa4d6b7f7ef64). (dim * sizeof (double)); |
| 93 | |
| 94 | if (state->ytmpcxx . . $ $anonymous_type_86d77917ada7425c_0#ytmp. == 0) |
| 95 | { |
| 96 | freecxx . . $ free(5d22bdacc48458e8). (state->Y1cxx . . $ $anonymous_type_86d77917ada7425c_0#Y1.); |
| 97 | freecxx . . $ free(5d22bdacc48458e8). (state->y0cxx . . $ $anonymous_type_86d77917ada7425c_0#y0.); |
| 98 | freecxx . . $ free(5d22bdacc48458e8). (state->y0_origcxx . . $ $anonymous_type_86d77917ada7425c_0#y0_orig.); |
| 99 | freecxx . . $ free(5d22bdacc48458e8). (state); |
| 100 | GSL_ERROR_NULLcxx . . $ `external/gsl/gsl_errno.h:129:9`! ("failed to allocate space for ytmp", GSL_ENOMEM); |
| 101 | } |
| 102 | |
| 103 | state->dfdycxx . . $ $anonymous_type_86d77917ada7425c_0#dfdy. = (double *) malloccxx . . $ malloc(bfcfa4d6b7f7ef64). (dim * dim * sizeof (double)); |
| 104 | |
| 105 | if (state->dfdycxx . . $ $anonymous_type_86d77917ada7425c_0#dfdy. == 0) |
| 106 | { |
| 107 | freecxx . . $ free(5d22bdacc48458e8). (state->Y1cxx . . $ $anonymous_type_86d77917ada7425c_0#Y1.); |
| 108 | freecxx . . $ free(5d22bdacc48458e8). (state->y0cxx . . $ $anonymous_type_86d77917ada7425c_0#y0.); |
| 109 | freecxx . . $ free(5d22bdacc48458e8). (state->y0_origcxx . . $ $anonymous_type_86d77917ada7425c_0#y0_orig.); |
| 110 | freecxx . . $ free(5d22bdacc48458e8). (state->ytmpcxx . . $ $anonymous_type_86d77917ada7425c_0#ytmp.); |
| 111 | freecxx . . $ free(5d22bdacc48458e8). (state); |
| 112 | GSL_ERROR_NULLcxx . . $ `external/gsl/gsl_errno.h:129:9`! ("failed to allocate space for dfdy", GSL_ENOMEM); |
| 113 | } |
| 114 | |
| 115 | state->dfdtcxx . . $ $anonymous_type_86d77917ada7425c_0#dfdt. = (double *) malloccxx . . $ malloc(bfcfa4d6b7f7ef64). (dim * sizeof (double)); |
| 116 | |
| 117 | if (state->dfdtcxx . . $ $anonymous_type_86d77917ada7425c_0#dfdt. == 0) |
| 118 | { |
| 119 | freecxx . . $ free(5d22bdacc48458e8). (state->Y1cxx . . $ $anonymous_type_86d77917ada7425c_0#Y1.); |
| 120 | freecxx . . $ free(5d22bdacc48458e8). (state->y0cxx . . $ $anonymous_type_86d77917ada7425c_0#y0.); |
| 121 | freecxx . . $ free(5d22bdacc48458e8). (state->y0_origcxx . . $ $anonymous_type_86d77917ada7425c_0#y0_orig.); |
| 122 | freecxx . . $ free(5d22bdacc48458e8). (state->ytmpcxx . . $ $anonymous_type_86d77917ada7425c_0#ytmp.); |
| 123 | freecxx . . $ free(5d22bdacc48458e8). (state->dfdycxx . . $ $anonymous_type_86d77917ada7425c_0#dfdy.); |
| 124 | freecxx . . $ free(5d22bdacc48458e8). (state); |
| 125 | GSL_ERROR_NULLcxx . . $ `external/gsl/gsl_errno.h:129:9`! ("failed to allocate space for dfdt", GSL_ENOMEM); |
| 126 | } |
| 127 | |
| 128 | state->y_onestepcxx . . $ $anonymous_type_86d77917ada7425c_0#y_onestep. = (double *) malloccxx . . $ malloc(bfcfa4d6b7f7ef64). (dim * sizeof (double)); |
| 129 | |
| 130 | if (state->y_onestepcxx . . $ $anonymous_type_86d77917ada7425c_0#y_onestep. == 0) |
| 131 | { |
| 132 | freecxx . . $ free(5d22bdacc48458e8). (state->Y1cxx . . $ $anonymous_type_86d77917ada7425c_0#Y1.); |
| 133 | freecxx . . $ free(5d22bdacc48458e8). (state->y0cxx . . $ $anonymous_type_86d77917ada7425c_0#y0.); |
| 134 | freecxx . . $ free(5d22bdacc48458e8). (state->y0_origcxx . . $ $anonymous_type_86d77917ada7425c_0#y0_orig.); |
| 135 | freecxx . . $ free(5d22bdacc48458e8). (state->ytmpcxx . . $ $anonymous_type_86d77917ada7425c_0#ytmp.); |
| 136 | freecxx . . $ free(5d22bdacc48458e8). (state->dfdycxx . . $ $anonymous_type_86d77917ada7425c_0#dfdy.); |
| 137 | freecxx . . $ free(5d22bdacc48458e8). (state->dfdtcxx . . $ $anonymous_type_86d77917ada7425c_0#dfdt.); |
| 138 | freecxx . . $ free(5d22bdacc48458e8). (state); |
| 139 | GSL_ERROR_NULLcxx . . $ `external/gsl/gsl_errno.h:129:9`! ("failed to allocate space for y_onestep", GSL_ENOMEM); |
| 140 | } |
| 141 | |
| 142 | state->pcxx . . $ $anonymous_type_86d77917ada7425c_0#p. = gsl_permutation_alloccxx . . $ gsl_permutation_alloc(311f4cfee96dd0e3). (dim); |
| 143 | |
| 144 | if (state->pcxx . . $ $anonymous_type_86d77917ada7425c_0#p. == 0) |
| 145 | { |
| 146 | freecxx . . $ free(5d22bdacc48458e8). (state->Y1cxx . . $ $anonymous_type_86d77917ada7425c_0#Y1.); |
| 147 | freecxx . . $ free(5d22bdacc48458e8). (state->y0cxx . . $ $anonymous_type_86d77917ada7425c_0#y0.); |
| 148 | freecxx . . $ free(5d22bdacc48458e8). (state->y0_origcxx . . $ $anonymous_type_86d77917ada7425c_0#y0_orig.); |
| 149 | freecxx . . $ free(5d22bdacc48458e8). (state->ytmpcxx . . $ $anonymous_type_86d77917ada7425c_0#ytmp.); |
| 150 | freecxx . . $ free(5d22bdacc48458e8). (state->dfdycxx . . $ $anonymous_type_86d77917ada7425c_0#dfdy.); |
| 151 | freecxx . . $ free(5d22bdacc48458e8). (state->dfdtcxx . . $ $anonymous_type_86d77917ada7425c_0#dfdt.); |
| 152 | freecxx . . $ free(5d22bdacc48458e8). (state); |
| 153 | GSL_ERROR_NULLcxx . . $ `external/gsl/gsl_errno.h:129:9`! ("failed to allocate space for p", GSL_ENOMEM); |
| 154 | } |
| 155 | |
| 156 | return state; |
| 157 | } |
| 158 | |
| 159 | |
| 160 | static int |
| 161 | rk2simp_stepcxx . . $ rk2simp_step(27dc0daafa378821). (double *y, rk2simp_state_tcxx . . $ rk2simp_state_t# * state, |
| 162 | const double h, const double t, |
| 163 | const size_t dim, const gsl_odeiv_systemcxx . . $ gsl_odeiv_system# * sys) |
| 164 | { |
| 165 | /* Makes a Runge-Kutta 2nd order semi-implicit advance with step size h. |
| 166 | y0 is initial values of variables y. |
| 167 | |
| 168 | The linearized semi-implicit equations to calculate are: |
| 169 | |
| 170 | Y1 = y0 + h/2 * (1 - h/2 * df/dy)^(-1) * f(t + h/2, y0) |
| 171 | |
| 172 | y = y0 + h * f(t + h/2, Y1) |
| 173 | */ |
| 174 | |
| 175 | const double *y0 = state->y0cxx . . $ $anonymous_type_86d77917ada7425c_0#y0.; |
| 176 | double *Y1 = state->Y1cxx . . $ $anonymous_type_86d77917ada7425c_0#Y1.; |
| 177 | double *ytmp = state->ytmpcxx . . $ $anonymous_type_86d77917ada7425c_0#ytmp.; |
| 178 | |
| 179 | size_t i; |
| 180 | int s, ps; |
| 181 | |
| 182 | gsl_matrix_viewcxx . . $ gsl_matrix_view# J = gsl_matrix_view_arraycxx . . $ gsl_matrix_view_array(1f69322eae7c3e05). (state->dfdycxx . . $ $anonymous_type_86d77917ada7425c_0#dfdy., dim, dim); |
| 183 | |
| 184 | /* First solve Y1. |
| 185 | Calculate the inverse matrix (1 - h/2 * df/dy)^-1 |
| 186 | */ |
| 187 | |
| 188 | /* Create matrix to J */ |
| 189 | |
| 190 | s = GSL_ODEIV_JA_EVALcxx . . $ `external/gsl/gsl_odeiv.h:68:9`! (sys, t, y0, state->dfdy, state->dfdt); |
| 191 | |
| 192 | if (s != GSL_SUCCESScxx . . $ GSL_SUCCESS.) |
| 193 | { |
| 194 | return s; |
| 195 | } |
| 196 | |
| 197 | gsl_matrix_scalecxx . . $ gsl_matrix_scale(c69b6356addad039). (&J.matrixcxx . . $ $anonymous_type_2f547ace9ee68af9_1#matrix., -h / 2.0); |
| 198 | gsl_matrix_add_diagonalcxx . . $ gsl_matrix_add_diagonal(c69b6356addad039).(&J.matrixcxx . . $ $anonymous_type_2f547ace9ee68af9_1#matrix., 1.0); |
| 199 | |
| 200 | /* Invert it by LU-decomposition to invmat */ |
| 201 | |
| 202 | s += gsl_linalg_LU_decompcxx . . $ gsl_linalg_LU_decomp(e9d4741e9a7c7a22). (&J.matrixcxx . . $ $anonymous_type_2f547ace9ee68af9_1#matrix., state->pcxx . . $ $anonymous_type_86d77917ada7425c_0#p., &ps); |
| 203 | |
| 204 | if (s != GSL_SUCCESScxx . . $ GSL_SUCCESS.) |
| 205 | { |
| 206 | return GSL_EFAILEDcxx . . $ GSL_EFAILED.; |
| 207 | } |
| 208 | |
| 209 | /* Evaluate f(t + h/2, y0) */ |
| 210 | |
| 211 | s = GSL_ODEIV_FN_EVALcxx . . $ `external/gsl/gsl_odeiv.h:67:9`! (sys, t + 0.5 * h, y0, ytmp); |
| 212 | |
| 213 | if (s != GSL_SUCCESScxx . . $ GSL_SUCCESS.) |
| 214 | { |
| 215 | return s; |
| 216 | } |
| 217 | |
| 218 | /* Calculate Y1 = y0 + h/2 * ((1-h/2 * df/dy)^-1) ytmp */ |
| 219 | |
| 220 | { |
| 221 | gsl_vector_const_viewcxx . . $ gsl_vector_const_view# y0_view = gsl_vector_const_view_arraycxx . . $ gsl_vector_const_view_array(cb672aec181e7afc).(y0, dim); |
| 222 | gsl_vector_viewcxx . . $ gsl_vector_view# ytmp_view = gsl_vector_view_arraycxx . . $ gsl_vector_view_array(8bd5fb11e568e882).(ytmp, dim); |
| 223 | gsl_vector_viewcxx . . $ gsl_vector_view# Y1_view = gsl_vector_view_arraycxx . . $ gsl_vector_view_array(8bd5fb11e568e882).(Y1, dim); |
| 224 | |
| 225 | s = gsl_linalg_LU_solvecxx . . $ gsl_linalg_LU_solve(58522a8301ae2475). (&J.matrixcxx . . $ $anonymous_type_2f547ace9ee68af9_1#matrix., state->pcxx . . $ $anonymous_type_86d77917ada7425c_0#p., |
| 226 | &ytmp_view.vectorcxx . . $ $anonymous_type_a8c2e3e00d6867c2_1#vector., &Y1_view.vectorcxx . . $ $anonymous_type_a8c2e3e00d6867c2_1#vector.); |
| 227 | |
| 228 | gsl_vector_scalecxx . . $ gsl_vector_scale(ddf696d31a4a9aeb). (&Y1_view.vectorcxx . . $ $anonymous_type_a8c2e3e00d6867c2_1#vector., 0.5 * h); |
| 229 | gsl_vector_addcxx . . $ gsl_vector_add(950c164c4e50c555). (&Y1_view.vectorcxx . . $ $anonymous_type_a8c2e3e00d6867c2_1#vector., &y0_view.vectorcxx . . $ $anonymous_type_a8c2e3e00d6867c2_2#vector.); |
| 230 | } |
| 231 | |
| 232 | /* And finally evaluation of f(t + h/2, Y1) and calculation of y */ |
| 233 | |
| 234 | s = GSL_ODEIV_FN_EVALcxx . . $ `external/gsl/gsl_odeiv.h:67:9`! (sys, t + 0.5 * h, Y1, ytmp); |
| 235 | |
| 236 | if (s != GSL_SUCCESScxx . . $ GSL_SUCCESS.) |
| 237 | { |
| 238 | return s; |
| 239 | } |
| 240 | |
| 241 | for (i = 0; i < dim; i++) |
| 242 | { |
| 243 | y[i] = y0[i] + h * ytmp[i]; |
| 244 | } |
| 245 | |
| 246 | return s; |
| 247 | } |
| 248 | |
| 249 | static int |
| 250 | rk2simp_applycxx . . $ rk2simp_apply(46f97775c18f9353). (void *vstate, size_t dim, double t, double h, |
| 251 | double y[], double yerr[], const double dydt_in[], |
| 252 | double dydt_out[], const gsl_odeiv_systemcxx . . $ gsl_odeiv_system# * sys) |
| 253 | { |
| 254 | rk2simp_state_tcxx . . $ rk2simp_state_t# *state = (rk2simp_state_tcxx . . $ rk2simp_state_t# *) vstate; |
| 255 | |
| 256 | size_t i; |
| 257 | |
| 258 | double *y0 = state->y0cxx . . $ $anonymous_type_86d77917ada7425c_0#y0.; |
| 259 | double *y0_orig = state->y0_origcxx . . $ $anonymous_type_86d77917ada7425c_0#y0_orig.; |
| 260 | double *y_onestep = state->y_onestepcxx . . $ $anonymous_type_86d77917ada7425c_0#y_onestep.; |
| 261 | |
| 262 | /* Error estimation is done by step doubling procedure */ |
| 263 | |
| 264 | DBL_MEMCPYcxx . . $ `external/gsl/gsl_ode-initval__odeiv_util.h:1:9`! (y0, y, dim); |
| 265 | |
| 266 | /* Save initial values in case of failure */ |
| 267 | DBL_MEMCPYcxx . . $ `external/gsl/gsl_ode-initval__odeiv_util.h:1:9`! (y0_orig, y, dim); |
| 268 | |
| 269 | /* First traverse h with one step (save to y_onestep) */ |
| 270 | DBL_MEMCPYcxx . . $ `external/gsl/gsl_ode-initval__odeiv_util.h:1:9`! (y_onestep, y, dim); |
| 271 | |
| 272 | { |
| 273 | int s = rk2simp_stepcxx . . $ rk2simp_step(27dc0daafa378821). (y_onestep, state, h, t, dim, sys); |
| 274 | |
| 275 | if (s != GSL_SUCCESScxx . . $ GSL_SUCCESS.) |
| 276 | { |
| 277 | return s; |
| 278 | } |
| 279 | } |
| 280 | |
| 281 | /* Then with two steps with half step length (save to y) */ |
| 282 | |
| 283 | { |
| 284 | int s = rk2simp_stepcxx . . $ rk2simp_step(27dc0daafa378821). (y, state, h / 2.0, t, dim, sys); |
| 285 | |
| 286 | if (s != GSL_SUCCESScxx . . $ GSL_SUCCESS.) |
| 287 | { |
| 288 | /* Restore original y vector */ |
| 289 | DBL_MEMCPYcxx . . $ `external/gsl/gsl_ode-initval__odeiv_util.h:1:9`! (y, y0_orig, dim); |
| 290 | return s; |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | DBL_MEMCPYcxx . . $ `external/gsl/gsl_ode-initval__odeiv_util.h:1:9`! (y0, y, dim); |
| 295 | |
| 296 | { |
| 297 | int s = rk2simp_stepcxx . . $ rk2simp_step(27dc0daafa378821). (y, state, h / 2.0, t + h / 2.0, dim, sys); |
| 298 | |
| 299 | if (s != GSL_SUCCESScxx . . $ GSL_SUCCESS.) |
| 300 | { |
| 301 | /* Restore original y vector */ |
| 302 | DBL_MEMCPYcxx . . $ `external/gsl/gsl_ode-initval__odeiv_util.h:1:9`! (y, y0_orig, dim); |
| 303 | return s; |
| 304 | } |
| 305 | } |
| 306 | |
| 307 | /* Derivatives at output */ |
| 308 | |
| 309 | if (dydt_out != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 310 | { |
| 311 | int s = GSL_ODEIV_FN_EVALcxx . . $ `external/gsl/gsl_odeiv.h:67:9`! (sys, t + h, y, dydt_out); |
| 312 | |
| 313 | if (s != GSL_SUCCESScxx . . $ GSL_SUCCESS.) |
| 314 | { |
| 315 | /* Restore original y vector */ |
| 316 | DBL_MEMCPYcxx . . $ `external/gsl/gsl_ode-initval__odeiv_util.h:1:9`! (y, y0_orig, dim); |
| 317 | return s; |
| 318 | } |
| 319 | } |
| 320 | |
| 321 | /* Error estimation */ |
| 322 | |
| 323 | for (i = 0; i < dim; i++) |
| 324 | { |
| 325 | yerr[i] = 4.0 * (y[i] - y_onestep[i]) / 3.0; |
| 326 | } |
| 327 | |
| 328 | return GSL_SUCCESScxx . . $ GSL_SUCCESS.; |
| 329 | } |
| 330 | |
| 331 | |
| 332 | static int |
| 333 | rk2simp_resetcxx . . $ rk2simp_reset(c0a5f96701d3f89). (void *vstate, size_t dim) |
| 334 | { |
| 335 | rk2simp_state_tcxx . . $ rk2simp_state_t# *state = (rk2simp_state_tcxx . . $ rk2simp_state_t# *) vstate; |
| 336 | |
| 337 | DBL_ZERO_MEMSETcxx . . $ `external/gsl/gsl_ode-initval__odeiv_util.h:2:9`! (state->Y1, dim); |
| 338 | DBL_ZERO_MEMSETcxx . . $ `external/gsl/gsl_ode-initval__odeiv_util.h:2:9`! (state->y0, dim); |
| 339 | DBL_ZERO_MEMSETcxx . . $ `external/gsl/gsl_ode-initval__odeiv_util.h:2:9`! (state->y0_orig, dim); |
| 340 | DBL_ZERO_MEMSETcxx . . $ `external/gsl/gsl_ode-initval__odeiv_util.h:2:9`! (state->ytmp, dim); |
| 341 | DBL_ZERO_MEMSETcxx . . $ `external/gsl/gsl_ode-initval__odeiv_util.h:2:9`! (state->dfdt, dim * dim); |
| 342 | DBL_ZERO_MEMSETcxx . . $ `external/gsl/gsl_ode-initval__odeiv_util.h:2:9`! (state->dfdt, dim); |
| 343 | DBL_ZERO_MEMSETcxx . . $ `external/gsl/gsl_ode-initval__odeiv_util.h:2:9`! (state->y_onestep, dim); |
| 344 | |
| 345 | return GSL_SUCCESScxx . . $ GSL_SUCCESS.; |
| 346 | } |
| 347 | |
| 348 | static unsigned int |
| 349 | rk2simp_ordercxx . . $ rk2simp_order(6769d0e399bf81e3). (void *vstate) |
| 350 | { |
| 351 | return 2; |
| 352 | } |
| 353 | |
| 354 | static void |
| 355 | rk2simp_freecxx . . $ rk2simp_free(5d22bdacc48458e8). (void *vstate) |
| 356 | { |
| 357 | rk2simp_state_tcxx . . $ rk2simp_state_t# *state = (rk2simp_state_tcxx . . $ rk2simp_state_t# *) vstate; |
| 358 | freecxx . . $ free(5d22bdacc48458e8). (state->Y1cxx . . $ $anonymous_type_86d77917ada7425c_0#Y1.); |
| 359 | freecxx . . $ free(5d22bdacc48458e8). (state->y0cxx . . $ $anonymous_type_86d77917ada7425c_0#y0.); |
| 360 | freecxx . . $ free(5d22bdacc48458e8). (state->y0_origcxx . . $ $anonymous_type_86d77917ada7425c_0#y0_orig.); |
| 361 | freecxx . . $ free(5d22bdacc48458e8). (state->ytmpcxx . . $ $anonymous_type_86d77917ada7425c_0#ytmp.); |
| 362 | freecxx . . $ free(5d22bdacc48458e8). (state->dfdycxx . . $ $anonymous_type_86d77917ada7425c_0#dfdy.); |
| 363 | freecxx . . $ free(5d22bdacc48458e8). (state->dfdtcxx . . $ $anonymous_type_86d77917ada7425c_0#dfdt.); |
| 364 | freecxx . . $ free(5d22bdacc48458e8). (state->y_onestepcxx . . $ $anonymous_type_86d77917ada7425c_0#y_onestep.); |
| 365 | gsl_permutation_freecxx . . $ gsl_permutation_free(bfe6c130f63679fa). (state->pcxx . . $ $anonymous_type_86d77917ada7425c_0#p.); |
| 366 | freecxx . . $ free(5d22bdacc48458e8). (state); |
| 367 | } |
| 368 | |
| 369 | static const gsl_odeiv_step_typecxx . . $ gsl_odeiv_step_type# rk2simp_typecxx . . $ rk2simp_type. = { |
| 370 | "rk2simp", /* name */ |
| 371 | 0, /* can use dydt_in? */ |
| 372 | 1, /* gives exact dydt_out? */ |
| 373 | &rk2simp_alloccxx . . $ rk2simp_alloc(bfcfa4d6b7f7ef64)., |
| 374 | &rk2simp_applycxx . . $ rk2simp_apply(46f97775c18f9353)., |
| 375 | &rk2simp_resetcxx . . $ rk2simp_reset(c0a5f96701d3f89)., |
| 376 | &rk2simp_ordercxx . . $ rk2simp_order(6769d0e399bf81e3)., |
| 377 | &rk2simp_freecxx . . $ rk2simp_free(5d22bdacc48458e8). |
| 378 | }; |
| 379 | |
| 380 | const gsl_odeiv_step_typecxx . . $ gsl_odeiv_step_type# *gsl_odeiv_step_rk2simpcxx . . $ gsl_odeiv_step_rk2simp. = &rk2simp_typecxx . . $ rk2simp_type.; |