| 1 | /* multiroots/fdfsolver.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 | #include <stdlib.h> |
| 22 | #include <string.h> |
| 23 | #include "gsl_errno.h"cxx . . $ `<file>/external/gsl/gsl_errno.h`/ |
| 24 | #include "gsl_multiroots.h"cxx . . $ `<file>/external/gsl/gsl_multiroots.h`/ |
| 25 | |
| 26 | gsl_multiroot_fdfsolvercxx . . $ gsl_multiroot_fdfsolver# * |
| 27 | gsl_multiroot_fdfsolver_alloccxx . . $ gsl_multiroot_fdfsolver_alloc(16402f2f316f1654). (const gsl_multiroot_fdfsolver_typecxx . . $ gsl_multiroot_fdfsolver_type# * T, |
| 28 | size_t n) |
| 29 | { |
| 30 | int status; |
| 31 | |
| 32 | gsl_multiroot_fdfsolvercxx . . $ gsl_multiroot_fdfsolver# * s; |
| 33 | |
| 34 | s = (gsl_multiroot_fdfsolvercxx . . $ gsl_multiroot_fdfsolver# *) malloccxx . . $ malloc(bfcfa4d6b7f7ef64). (sizeof (gsl_multiroot_fdfsolvercxx . . $ gsl_multiroot_fdfsolver#)); |
| 35 | |
| 36 | if (s == 0) |
| 37 | { |
| 38 | GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("failed to allocate space for multiroot solver struct", |
| 39 | GSL_ENOMEM, 0); |
| 40 | } |
| 41 | |
| 42 | s->xcxx . . $ $anonymous_type_a4b565e210e7961f_3#x. = gsl_vector_calloccxx . . $ gsl_vector_calloc(71d9e095f27e8ea9). (n); |
| 43 | |
| 44 | if (s->xcxx . . $ $anonymous_type_a4b565e210e7961f_3#x. == 0) |
| 45 | { |
| 46 | freecxx . . $ free(5d22bdacc48458e8). (s); |
| 47 | GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("failed to allocate space for x", GSL_ENOMEM, 0); |
| 48 | } |
| 49 | |
| 50 | s->fcxx . . $ $anonymous_type_a4b565e210e7961f_3#f. = gsl_vector_calloccxx . . $ gsl_vector_calloc(71d9e095f27e8ea9). (n); |
| 51 | |
| 52 | if (s->fcxx . . $ $anonymous_type_a4b565e210e7961f_3#f. == 0) |
| 53 | { |
| 54 | gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (s->xcxx . . $ $anonymous_type_a4b565e210e7961f_3#x.); |
| 55 | freecxx . . $ free(5d22bdacc48458e8). (s); |
| 56 | GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("failed to allocate space for f", GSL_ENOMEM, 0); |
| 57 | } |
| 58 | |
| 59 | s->Jcxx . . $ $anonymous_type_a4b565e210e7961f_3#J. = gsl_matrix_calloccxx . . $ gsl_matrix_calloc(5a4d020b4836594). (n,n); |
| 60 | |
| 61 | if (s->Jcxx . . $ $anonymous_type_a4b565e210e7961f_3#J. == 0) |
| 62 | { |
| 63 | gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (s->xcxx . . $ $anonymous_type_a4b565e210e7961f_3#x.); |
| 64 | gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (s->fcxx . . $ $anonymous_type_a4b565e210e7961f_3#f.); |
| 65 | freecxx . . $ free(5d22bdacc48458e8). (s); |
| 66 | GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("failed to allocate space for g", GSL_ENOMEM, 0); |
| 67 | } |
| 68 | |
| 69 | s->dxcxx . . $ $anonymous_type_a4b565e210e7961f_3#dx. = gsl_vector_calloccxx . . $ gsl_vector_calloc(71d9e095f27e8ea9). (n); |
| 70 | |
| 71 | if (s->dxcxx . . $ $anonymous_type_a4b565e210e7961f_3#dx. == 0) |
| 72 | { |
| 73 | gsl_matrix_freecxx . . $ gsl_matrix_free(ab29a617cccd3636). (s->Jcxx . . $ $anonymous_type_a4b565e210e7961f_3#J.); |
| 74 | gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (s->xcxx . . $ $anonymous_type_a4b565e210e7961f_3#x.); |
| 75 | gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (s->fcxx . . $ $anonymous_type_a4b565e210e7961f_3#f.); |
| 76 | freecxx . . $ free(5d22bdacc48458e8). (s); |
| 77 | GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("failed to allocate space for dx", GSL_ENOMEM, 0); |
| 78 | } |
| 79 | |
| 80 | s->statecxx . . $ $anonymous_type_a4b565e210e7961f_3#state. = malloccxx . . $ malloc(bfcfa4d6b7f7ef64). (T->sizecxx . . $ $anonymous_type_a4b565e210e7961f_2#size.); |
| 81 | |
| 82 | if (s->statecxx . . $ $anonymous_type_a4b565e210e7961f_3#state. == 0) |
| 83 | { |
| 84 | gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (s->dxcxx . . $ $anonymous_type_a4b565e210e7961f_3#dx.); |
| 85 | gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (s->xcxx . . $ $anonymous_type_a4b565e210e7961f_3#x.); |
| 86 | gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (s->fcxx . . $ $anonymous_type_a4b565e210e7961f_3#f.); |
| 87 | gsl_matrix_freecxx . . $ gsl_matrix_free(ab29a617cccd3636). (s->Jcxx . . $ $anonymous_type_a4b565e210e7961f_3#J.); |
| 88 | freecxx . . $ free(5d22bdacc48458e8). (s); /* exception in constructor, avoid memory leak */ |
| 89 | |
| 90 | GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("failed to allocate space for multiroot solver state", |
| 91 | GSL_ENOMEM, 0); |
| 92 | } |
| 93 | |
| 94 | s->typecxx . . $ $anonymous_type_a4b565e210e7961f_3#type. = T ; |
| 95 | |
| 96 | status = (s->typecxx . . $ $anonymous_type_a4b565e210e7961f_3#type.->alloccxx . . $ $anonymous_type_a4b565e210e7961f_2#alloc.)(s->statecxx . . $ $anonymous_type_a4b565e210e7961f_3#state., n); |
| 97 | |
| 98 | if (status != GSL_SUCCESScxx . . $ GSL_SUCCESS.) |
| 99 | { |
| 100 | freecxx . . $ free(5d22bdacc48458e8). (s->statecxx . . $ $anonymous_type_a4b565e210e7961f_3#state.); |
| 101 | gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (s->dxcxx . . $ $anonymous_type_a4b565e210e7961f_3#dx.); |
| 102 | gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (s->xcxx . . $ $anonymous_type_a4b565e210e7961f_3#x.); |
| 103 | gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (s->fcxx . . $ $anonymous_type_a4b565e210e7961f_3#f.); |
| 104 | gsl_matrix_freecxx . . $ gsl_matrix_free(ab29a617cccd3636). (s->Jcxx . . $ $anonymous_type_a4b565e210e7961f_3#J.); |
| 105 | freecxx . . $ free(5d22bdacc48458e8). (s); /* exception in constructor, avoid memory leak */ |
| 106 | |
| 107 | GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("failed to set solver", status, 0); |
| 108 | } |
| 109 | |
| 110 | s->fdfcxx . . $ $anonymous_type_a4b565e210e7961f_3#fdf. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 111 | |
| 112 | return s; |
| 113 | } |
| 114 | |
| 115 | int |
| 116 | gsl_multiroot_fdfsolver_setcxx . . $ gsl_multiroot_fdfsolver_set(49036c28fbcad88a). (gsl_multiroot_fdfsolvercxx . . $ gsl_multiroot_fdfsolver# * s, |
| 117 | gsl_multiroot_function_fdfcxx . . $ gsl_multiroot_function_fdf# * f, |
| 118 | const gsl_vectorcxx . . $ gsl_vector# * x) |
| 119 | { |
| 120 | if (s->xcxx . . $ $anonymous_type_a4b565e210e7961f_3#x.->sizecxx . . $ $anonymous_type_a8c2e3e00d6867c2_0#size. != f->ncxx . . $ gsl_multiroot_function_fdf_struct#n.) |
| 121 | { |
| 122 | GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("function incompatible with solver size", GSL_EBADLEN); |
| 123 | } |
| 124 | |
| 125 | if (x->sizecxx . . $ $anonymous_type_a8c2e3e00d6867c2_0#size. != f->ncxx . . $ gsl_multiroot_function_fdf_struct#n.) |
| 126 | { |
| 127 | GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("vector length not compatible with function", GSL_EBADLEN); |
| 128 | } |
| 129 | |
| 130 | s->fdfcxx . . $ $anonymous_type_a4b565e210e7961f_3#fdf. = f; |
| 131 | gsl_vector_memcpycxx . . $ gsl_vector_memcpy(950c164c4e50c555).(s->xcxx . . $ $anonymous_type_a4b565e210e7961f_3#x.,x); |
| 132 | |
| 133 | return (s->typecxx . . $ $anonymous_type_a4b565e210e7961f_3#type.->setcxx . . $ $anonymous_type_a4b565e210e7961f_2#set.) (s->statecxx . . $ $anonymous_type_a4b565e210e7961f_3#state., s->fdfcxx . . $ $anonymous_type_a4b565e210e7961f_3#fdf., s->xcxx . . $ $anonymous_type_a4b565e210e7961f_3#x., s->fcxx . . $ $anonymous_type_a4b565e210e7961f_3#f., s->Jcxx . . $ $anonymous_type_a4b565e210e7961f_3#J., s->dxcxx . . $ $anonymous_type_a4b565e210e7961f_3#dx.); |
| 134 | } |
| 135 | |
| 136 | int |
| 137 | gsl_multiroot_fdfsolver_iteratecxx . . $ gsl_multiroot_fdfsolver_iterate(62ee3652521f8407). (gsl_multiroot_fdfsolvercxx . . $ gsl_multiroot_fdfsolver# * s) |
| 138 | { |
| 139 | return (s->typecxx . . $ $anonymous_type_a4b565e210e7961f_3#type.->iteratecxx . . $ $anonymous_type_a4b565e210e7961f_2#iterate.) (s->statecxx . . $ $anonymous_type_a4b565e210e7961f_3#state., s->fdfcxx . . $ $anonymous_type_a4b565e210e7961f_3#fdf., s->xcxx . . $ $anonymous_type_a4b565e210e7961f_3#x., s->fcxx . . $ $anonymous_type_a4b565e210e7961f_3#f., s->Jcxx . . $ $anonymous_type_a4b565e210e7961f_3#J., s->dxcxx . . $ $anonymous_type_a4b565e210e7961f_3#dx.); |
| 140 | } |
| 141 | |
| 142 | void |
| 143 | gsl_multiroot_fdfsolver_freecxx . . $ gsl_multiroot_fdfsolver_free(27d1ba267bc9dbce). (gsl_multiroot_fdfsolvercxx . . $ gsl_multiroot_fdfsolver# * s) |
| 144 | { |
| 145 | (s->typecxx . . $ $anonymous_type_a4b565e210e7961f_3#type.->freecxx . . $ $anonymous_type_a4b565e210e7961f_2#free.) (s->statecxx . . $ $anonymous_type_a4b565e210e7961f_3#state.); |
| 146 | freecxx . . $ free(5d22bdacc48458e8). (s->statecxx . . $ $anonymous_type_a4b565e210e7961f_3#state.); |
| 147 | gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (s->dxcxx . . $ $anonymous_type_a4b565e210e7961f_3#dx.); |
| 148 | gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (s->xcxx . . $ $anonymous_type_a4b565e210e7961f_3#x.); |
| 149 | gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (s->fcxx . . $ $anonymous_type_a4b565e210e7961f_3#f.); |
| 150 | gsl_matrix_freecxx . . $ gsl_matrix_free(ab29a617cccd3636). (s->Jcxx . . $ $anonymous_type_a4b565e210e7961f_3#J.); |
| 151 | freecxx . . $ free(5d22bdacc48458e8). (s); |
| 152 | } |
| 153 | |
| 154 | const char * |
| 155 | gsl_multiroot_fdfsolver_namecxx . . $ gsl_multiroot_fdfsolver_name(c56846354ae899a6). (const gsl_multiroot_fdfsolvercxx . . $ gsl_multiroot_fdfsolver# * s) |
| 156 | { |
| 157 | return s->typecxx . . $ $anonymous_type_a4b565e210e7961f_3#type.->namecxx . . $ $anonymous_type_a4b565e210e7961f_2#name.; |
| 158 | } |
| 159 | |
| 160 | gsl_vectorcxx . . $ gsl_vector# * |
| 161 | gsl_multiroot_fdfsolver_rootcxx . . $ gsl_multiroot_fdfsolver_root(2a1114588428b4e2). (const gsl_multiroot_fdfsolvercxx . . $ gsl_multiroot_fdfsolver# * s) |
| 162 | { |
| 163 | return s->xcxx . . $ $anonymous_type_a4b565e210e7961f_3#x.; |
| 164 | } |
| 165 | |
| 166 | gsl_vectorcxx . . $ gsl_vector# * |
| 167 | gsl_multiroot_fdfsolver_dxcxx . . $ gsl_multiroot_fdfsolver_dx(2a1114588428b4e2). (const gsl_multiroot_fdfsolvercxx . . $ gsl_multiroot_fdfsolver# * s) |
| 168 | { |
| 169 | return s->dxcxx . . $ $anonymous_type_a4b565e210e7961f_3#dx.; |
| 170 | } |
| 171 | |
| 172 | gsl_vectorcxx . . $ gsl_vector# * |
| 173 | gsl_multiroot_fdfsolver_fcxx . . $ gsl_multiroot_fdfsolver_f(2a1114588428b4e2). (const gsl_multiroot_fdfsolvercxx . . $ gsl_multiroot_fdfsolver# * s) |
| 174 | { |
| 175 | return s->fcxx . . $ $anonymous_type_a4b565e210e7961f_3#f.; |
| 176 | } |