| 1 | /* multifit/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_multifit_nlin.h"cxx . . $ `<file>/external/gsl/gsl_multifit_nlin.h`/ |
| 25 | |
| 26 | gsl_multifit_fdfsolvercxx . . $ gsl_multifit_fdfsolver# * |
| 27 | gsl_multifit_fdfsolver_alloccxx . . $ gsl_multifit_fdfsolver_alloc(820795a84717c6bd). (const gsl_multifit_fdfsolver_typecxx . . $ gsl_multifit_fdfsolver_type# * T, |
| 28 | size_t n, size_t p) |
| 29 | { |
| 30 | int status; |
| 31 | |
| 32 | gsl_multifit_fdfsolvercxx . . $ gsl_multifit_fdfsolver# * s; |
| 33 | |
| 34 | if (n < p) |
| 35 | { |
| 36 | GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("insufficient data points, n < p", GSL_EINVAL, 0); |
| 37 | } |
| 38 | |
| 39 | s = (gsl_multifit_fdfsolvercxx . . $ gsl_multifit_fdfsolver# *) malloccxx . . $ malloc(bfcfa4d6b7f7ef64). (sizeof (gsl_multifit_fdfsolvercxx . . $ gsl_multifit_fdfsolver#)); |
| 40 | |
| 41 | if (s == 0) |
| 42 | { |
| 43 | GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("failed to allocate space for multifit solver struct", |
| 44 | GSL_ENOMEM, 0); |
| 45 | } |
| 46 | |
| 47 | s->xcxx . . $ $anonymous_type_52a18a1d9253cc93_3#x. = gsl_vector_calloccxx . . $ gsl_vector_calloc(71d9e095f27e8ea9). (p); |
| 48 | |
| 49 | if (s->xcxx . . $ $anonymous_type_52a18a1d9253cc93_3#x. == 0) |
| 50 | { |
| 51 | freecxx . . $ free(5d22bdacc48458e8). (s); |
| 52 | GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("failed to allocate space for x", GSL_ENOMEM, 0); |
| 53 | } |
| 54 | |
| 55 | s->fcxx . . $ $anonymous_type_52a18a1d9253cc93_3#f. = gsl_vector_calloccxx . . $ gsl_vector_calloc(71d9e095f27e8ea9). (n); |
| 56 | |
| 57 | if (s->fcxx . . $ $anonymous_type_52a18a1d9253cc93_3#f. == 0) |
| 58 | { |
| 59 | gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (s->xcxx . . $ $anonymous_type_52a18a1d9253cc93_3#x.); |
| 60 | freecxx . . $ free(5d22bdacc48458e8). (s); |
| 61 | GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("failed to allocate space for f", GSL_ENOMEM, 0); |
| 62 | } |
| 63 | |
| 64 | s->Jcxx . . $ $anonymous_type_52a18a1d9253cc93_3#J. = gsl_matrix_calloccxx . . $ gsl_matrix_calloc(5a4d020b4836594). (n,p); |
| 65 | |
| 66 | if (s->Jcxx . . $ $anonymous_type_52a18a1d9253cc93_3#J. == 0) |
| 67 | { |
| 68 | gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (s->xcxx . . $ $anonymous_type_52a18a1d9253cc93_3#x.); |
| 69 | gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (s->fcxx . . $ $anonymous_type_52a18a1d9253cc93_3#f.); |
| 70 | freecxx . . $ free(5d22bdacc48458e8). (s); |
| 71 | GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("failed to allocate space for g", GSL_ENOMEM, 0); |
| 72 | } |
| 73 | |
| 74 | s->dxcxx . . $ $anonymous_type_52a18a1d9253cc93_3#dx. = gsl_vector_calloccxx . . $ gsl_vector_calloc(71d9e095f27e8ea9). (p); |
| 75 | |
| 76 | if (s->dxcxx . . $ $anonymous_type_52a18a1d9253cc93_3#dx. == 0) |
| 77 | { |
| 78 | gsl_matrix_freecxx . . $ gsl_matrix_free(ab29a617cccd3636). (s->Jcxx . . $ $anonymous_type_52a18a1d9253cc93_3#J.); |
| 79 | gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (s->xcxx . . $ $anonymous_type_52a18a1d9253cc93_3#x.); |
| 80 | gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (s->fcxx . . $ $anonymous_type_52a18a1d9253cc93_3#f.); |
| 81 | freecxx . . $ free(5d22bdacc48458e8). (s); |
| 82 | GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("failed to allocate space for dx", GSL_ENOMEM, 0); |
| 83 | } |
| 84 | |
| 85 | s->statecxx . . $ $anonymous_type_52a18a1d9253cc93_3#state. = malloccxx . . $ malloc(bfcfa4d6b7f7ef64). (T->sizecxx . . $ $anonymous_type_52a18a1d9253cc93_2#size.); |
| 86 | |
| 87 | if (s->statecxx . . $ $anonymous_type_52a18a1d9253cc93_3#state. == 0) |
| 88 | { |
| 89 | gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (s->dxcxx . . $ $anonymous_type_52a18a1d9253cc93_3#dx.); |
| 90 | gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (s->xcxx . . $ $anonymous_type_52a18a1d9253cc93_3#x.); |
| 91 | gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (s->fcxx . . $ $anonymous_type_52a18a1d9253cc93_3#f.); |
| 92 | gsl_matrix_freecxx . . $ gsl_matrix_free(ab29a617cccd3636). (s->Jcxx . . $ $anonymous_type_52a18a1d9253cc93_3#J.); |
| 93 | freecxx . . $ free(5d22bdacc48458e8). (s); /* exception in constructor, avoid memory leak */ |
| 94 | |
| 95 | GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("failed to allocate space for multifit solver state", |
| 96 | GSL_ENOMEM, 0); |
| 97 | } |
| 98 | |
| 99 | s->typecxx . . $ $anonymous_type_52a18a1d9253cc93_3#type. = T ; |
| 100 | |
| 101 | status = (s->typecxx . . $ $anonymous_type_52a18a1d9253cc93_3#type.->alloccxx . . $ $anonymous_type_52a18a1d9253cc93_2#alloc.)(s->statecxx . . $ $anonymous_type_52a18a1d9253cc93_3#state., n, p); |
| 102 | |
| 103 | if (status != GSL_SUCCESScxx . . $ GSL_SUCCESS.) |
| 104 | { |
| 105 | freecxx . . $ free(5d22bdacc48458e8). (s->statecxx . . $ $anonymous_type_52a18a1d9253cc93_3#state.); |
| 106 | gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (s->dxcxx . . $ $anonymous_type_52a18a1d9253cc93_3#dx.); |
| 107 | gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (s->xcxx . . $ $anonymous_type_52a18a1d9253cc93_3#x.); |
| 108 | gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (s->fcxx . . $ $anonymous_type_52a18a1d9253cc93_3#f.); |
| 109 | gsl_matrix_freecxx . . $ gsl_matrix_free(ab29a617cccd3636). (s->Jcxx . . $ $anonymous_type_52a18a1d9253cc93_3#J.); |
| 110 | freecxx . . $ free(5d22bdacc48458e8). (s); /* exception in constructor, avoid memory leak */ |
| 111 | |
| 112 | GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("failed to set solver", status, 0); |
| 113 | } |
| 114 | |
| 115 | s->fdfcxx . . $ $anonymous_type_52a18a1d9253cc93_3#fdf. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 116 | |
| 117 | return s; |
| 118 | } |
| 119 | |
| 120 | int |
| 121 | gsl_multifit_fdfsolver_setcxx . . $ gsl_multifit_fdfsolver_set(acadafc21178bf26). (gsl_multifit_fdfsolvercxx . . $ gsl_multifit_fdfsolver# * s, |
| 122 | gsl_multifit_function_fdfcxx . . $ gsl_multifit_function_fdf# * f, |
| 123 | const gsl_vectorcxx . . $ gsl_vector# * x) |
| 124 | { |
| 125 | if (s->fcxx . . $ $anonymous_type_52a18a1d9253cc93_3#f.->sizecxx . . $ $anonymous_type_a8c2e3e00d6867c2_0#size. != f->ncxx . . $ gsl_multifit_function_fdf_struct#n.) |
| 126 | { |
| 127 | GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("function size does not match solver", GSL_EBADLEN); |
| 128 | } |
| 129 | |
| 130 | if (s->xcxx . . $ $anonymous_type_52a18a1d9253cc93_3#x.->sizecxx . . $ $anonymous_type_a8c2e3e00d6867c2_0#size. != x->sizecxx . . $ $anonymous_type_a8c2e3e00d6867c2_0#size.) |
| 131 | { |
| 132 | GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("vector length does not match solver", GSL_EBADLEN); |
| 133 | } |
| 134 | |
| 135 | s->fdfcxx . . $ $anonymous_type_52a18a1d9253cc93_3#fdf. = f; |
| 136 | gsl_vector_memcpycxx . . $ gsl_vector_memcpy(950c164c4e50c555).(s->xcxx . . $ $anonymous_type_52a18a1d9253cc93_3#x.,x); |
| 137 | |
| 138 | return (s->typecxx . . $ $anonymous_type_52a18a1d9253cc93_3#type.->setcxx . . $ $anonymous_type_52a18a1d9253cc93_2#set.) (s->statecxx . . $ $anonymous_type_52a18a1d9253cc93_3#state., s->fdfcxx . . $ $anonymous_type_52a18a1d9253cc93_3#fdf., s->xcxx . . $ $anonymous_type_52a18a1d9253cc93_3#x., s->fcxx . . $ $anonymous_type_52a18a1d9253cc93_3#f., s->Jcxx . . $ $anonymous_type_52a18a1d9253cc93_3#J., s->dxcxx . . $ $anonymous_type_52a18a1d9253cc93_3#dx.); |
| 139 | } |
| 140 | |
| 141 | int |
| 142 | gsl_multifit_fdfsolver_iteratecxx . . $ gsl_multifit_fdfsolver_iterate(98f8151cfbe716d9). (gsl_multifit_fdfsolvercxx . . $ gsl_multifit_fdfsolver# * s) |
| 143 | { |
| 144 | return (s->typecxx . . $ $anonymous_type_52a18a1d9253cc93_3#type.->iteratecxx . . $ $anonymous_type_52a18a1d9253cc93_2#iterate.) (s->statecxx . . $ $anonymous_type_52a18a1d9253cc93_3#state., s->fdfcxx . . $ $anonymous_type_52a18a1d9253cc93_3#fdf., s->xcxx . . $ $anonymous_type_52a18a1d9253cc93_3#x., s->fcxx . . $ $anonymous_type_52a18a1d9253cc93_3#f., s->Jcxx . . $ $anonymous_type_52a18a1d9253cc93_3#J., s->dxcxx . . $ $anonymous_type_52a18a1d9253cc93_3#dx.); |
| 145 | } |
| 146 | |
| 147 | void |
| 148 | gsl_multifit_fdfsolver_freecxx . . $ gsl_multifit_fdfsolver_free(259eba66c1a4a515). (gsl_multifit_fdfsolvercxx . . $ gsl_multifit_fdfsolver# * s) |
| 149 | { |
| 150 | (s->typecxx . . $ $anonymous_type_52a18a1d9253cc93_3#type.->freecxx . . $ $anonymous_type_52a18a1d9253cc93_2#free.) (s->statecxx . . $ $anonymous_type_52a18a1d9253cc93_3#state.); |
| 151 | freecxx . . $ free(5d22bdacc48458e8). (s->statecxx . . $ $anonymous_type_52a18a1d9253cc93_3#state.); |
| 152 | gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (s->dxcxx . . $ $anonymous_type_52a18a1d9253cc93_3#dx.); |
| 153 | gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (s->xcxx . . $ $anonymous_type_52a18a1d9253cc93_3#x.); |
| 154 | gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (s->fcxx . . $ $anonymous_type_52a18a1d9253cc93_3#f.); |
| 155 | gsl_matrix_freecxx . . $ gsl_matrix_free(ab29a617cccd3636). (s->Jcxx . . $ $anonymous_type_52a18a1d9253cc93_3#J.); |
| 156 | freecxx . . $ free(5d22bdacc48458e8). (s); |
| 157 | } |
| 158 | |
| 159 | const char * |
| 160 | gsl_multifit_fdfsolver_namecxx . . $ gsl_multifit_fdfsolver_name(26c60aa56e511a7a). (const gsl_multifit_fdfsolvercxx . . $ gsl_multifit_fdfsolver# * s) |
| 161 | { |
| 162 | return s->typecxx . . $ $anonymous_type_52a18a1d9253cc93_3#type.->namecxx . . $ $anonymous_type_52a18a1d9253cc93_2#name.; |
| 163 | } |
| 164 | |
| 165 | gsl_vectorcxx . . $ gsl_vector# * |
| 166 | gsl_multifit_fdfsolver_positioncxx . . $ gsl_multifit_fdfsolver_position(e91240201488c426). (const gsl_multifit_fdfsolvercxx . . $ gsl_multifit_fdfsolver# * s) |
| 167 | { |
| 168 | return s->xcxx . . $ $anonymous_type_52a18a1d9253cc93_3#x.; |
| 169 | } |
| 170 |