| 1 | /* multimin/fminimizer.c |
| 2 | * |
| 3 | * Copyright (C) 2002 Tuomo Keskitalo, Ivo Alxneit |
| 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 "gsl_errno.h"cxx . . $ `<file>/external/gsl/gsl_errno.h`/ |
| 22 | #include "gsl_multimin.h"cxx . . $ `<file>/external/gsl/gsl_multimin.h`/ |
| 23 | |
| 24 | gsl_multimin_fminimizercxx . . $ gsl_multimin_fminimizer# * |
| 25 | gsl_multimin_fminimizer_alloccxx . . $ gsl_multimin_fminimizer_alloc(d03d4388a5571eda). (const gsl_multimin_fminimizer_typecxx . . $ gsl_multimin_fminimizer_type# * T, |
| 26 | size_t n) |
| 27 | { |
| 28 | int status; |
| 29 | |
| 30 | gsl_multimin_fminimizercxx . . $ gsl_multimin_fminimizer# *s = |
| 31 | (gsl_multimin_fminimizercxx . . $ gsl_multimin_fminimizer# *) malloccxx . . $ malloc(bfcfa4d6b7f7ef64). (sizeof (gsl_multimin_fminimizercxx . . $ gsl_multimin_fminimizer#)); |
| 32 | |
| 33 | if (s == 0) |
| 34 | { |
| 35 | GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("failed to allocate space for minimizer struct", |
| 36 | GSL_ENOMEM, 0); |
| 37 | } |
| 38 | |
| 39 | s->typecxx . . $ $anonymous_type_e343b93576372a1f_1#type. = T; |
| 40 | |
| 41 | s->xcxx . . $ $anonymous_type_e343b93576372a1f_1#x. = gsl_vector_calloccxx . . $ gsl_vector_calloc(71d9e095f27e8ea9). (n); |
| 42 | |
| 43 | if (s->xcxx . . $ $anonymous_type_e343b93576372a1f_1#x. == 0) |
| 44 | { |
| 45 | freecxx . . $ free(5d22bdacc48458e8). (s); |
| 46 | GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("failed to allocate space for x", GSL_ENOMEM, 0); |
| 47 | } |
| 48 | |
| 49 | s->statecxx . . $ $anonymous_type_e343b93576372a1f_1#state. = malloccxx . . $ malloc(bfcfa4d6b7f7ef64). (T->sizecxx . . $ $anonymous_type_e343b93576372a1f_0#size.); |
| 50 | |
| 51 | if (s->statecxx . . $ $anonymous_type_e343b93576372a1f_1#state. == 0) |
| 52 | { |
| 53 | gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (s->xcxx . . $ $anonymous_type_e343b93576372a1f_1#x.); |
| 54 | freecxx . . $ free(5d22bdacc48458e8). (s); |
| 55 | GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("failed to allocate space for minimizer state", |
| 56 | GSL_ENOMEM, 0); |
| 57 | } |
| 58 | |
| 59 | status = (T->alloccxx . . $ $anonymous_type_e343b93576372a1f_0#alloc.) (s->statecxx . . $ $anonymous_type_e343b93576372a1f_1#state., n); |
| 60 | |
| 61 | if (status != GSL_SUCCESScxx . . $ GSL_SUCCESS.) |
| 62 | { |
| 63 | freecxx . . $ free(5d22bdacc48458e8). (s->statecxx . . $ $anonymous_type_e343b93576372a1f_1#state.); |
| 64 | gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (s->xcxx . . $ $anonymous_type_e343b93576372a1f_1#x.); |
| 65 | freecxx . . $ free(5d22bdacc48458e8). (s); |
| 66 | |
| 67 | GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("failed to initialize minimizer state", GSL_ENOMEM, 0); |
| 68 | } |
| 69 | |
| 70 | return s; |
| 71 | } |
| 72 | |
| 73 | int |
| 74 | gsl_multimin_fminimizer_setcxx . . $ gsl_multimin_fminimizer_set(8e77c96991dc76af). (gsl_multimin_fminimizercxx . . $ gsl_multimin_fminimizer# * s, |
| 75 | gsl_multimin_functioncxx . . $ gsl_multimin_function# * f, |
| 76 | const gsl_vectorcxx . . $ gsl_vector# * x, |
| 77 | const gsl_vectorcxx . . $ gsl_vector# * step_size) |
| 78 | { |
| 79 | if (s->xcxx . . $ $anonymous_type_e343b93576372a1f_1#x.->sizecxx . . $ $anonymous_type_a8c2e3e00d6867c2_0#size. != f->ncxx . . $ gsl_multimin_function_struct#n.) |
| 80 | { |
| 81 | GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("function incompatible with solver size", GSL_EBADLEN); |
| 82 | } |
| 83 | |
| 84 | if (x->sizecxx . . $ $anonymous_type_a8c2e3e00d6867c2_0#size. != f->ncxx . . $ gsl_multimin_function_struct#n. || step_size->sizecxx . . $ $anonymous_type_a8c2e3e00d6867c2_0#size. != f->ncxx . . $ gsl_multimin_function_struct#n.) |
| 85 | { |
| 86 | GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("vector length not compatible with function", GSL_EBADLEN); |
| 87 | } |
| 88 | |
| 89 | s->fcxx . . $ $anonymous_type_e343b93576372a1f_1#f. = f; |
| 90 | |
| 91 | gsl_vector_memcpycxx . . $ gsl_vector_memcpy(950c164c4e50c555). (s->xcxx . . $ $anonymous_type_e343b93576372a1f_1#x.,x); |
| 92 | |
| 93 | return (s->typecxx . . $ $anonymous_type_e343b93576372a1f_1#type.->setcxx . . $ $anonymous_type_e343b93576372a1f_0#set.) (s->statecxx . . $ $anonymous_type_e343b93576372a1f_1#state., s->fcxx . . $ $anonymous_type_e343b93576372a1f_1#f., s->xcxx . . $ $anonymous_type_e343b93576372a1f_1#x., &(s->sizecxx . . $ $anonymous_type_e343b93576372a1f_1#size.), step_size); |
| 94 | } |
| 95 | |
| 96 | void |
| 97 | gsl_multimin_fminimizer_freecxx . . $ gsl_multimin_fminimizer_free(f53db73159010606). (gsl_multimin_fminimizercxx . . $ gsl_multimin_fminimizer# * s) |
| 98 | { |
| 99 | (s->typecxx . . $ $anonymous_type_e343b93576372a1f_1#type.->freecxx . . $ $anonymous_type_e343b93576372a1f_0#free.) (s->statecxx . . $ $anonymous_type_e343b93576372a1f_1#state.); |
| 100 | freecxx . . $ free(5d22bdacc48458e8). (s->statecxx . . $ $anonymous_type_e343b93576372a1f_1#state.); |
| 101 | gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (s->xcxx . . $ $anonymous_type_e343b93576372a1f_1#x.); |
| 102 | freecxx . . $ free(5d22bdacc48458e8). (s); |
| 103 | } |
| 104 | |
| 105 | int |
| 106 | gsl_multimin_fminimizer_iteratecxx . . $ gsl_multimin_fminimizer_iterate(83f7cbbc2b0e0d25). (gsl_multimin_fminimizercxx . . $ gsl_multimin_fminimizer# * s) |
| 107 | { |
| 108 | return (s->typecxx . . $ $anonymous_type_e343b93576372a1f_1#type.->iteratecxx . . $ $anonymous_type_e343b93576372a1f_0#iterate.) (s->statecxx . . $ $anonymous_type_e343b93576372a1f_1#state., s->fcxx . . $ $anonymous_type_e343b93576372a1f_1#f., s->xcxx . . $ $anonymous_type_e343b93576372a1f_1#x., &(s->sizecxx . . $ $anonymous_type_e343b93576372a1f_1#size.), &(s->fvalcxx . . $ $anonymous_type_e343b93576372a1f_1#fval.)); |
| 109 | } |
| 110 | |
| 111 | const char * |
| 112 | gsl_multimin_fminimizer_namecxx . . $ gsl_multimin_fminimizer_name(c778b8addfc01163). (const gsl_multimin_fminimizercxx . . $ gsl_multimin_fminimizer# * s) |
| 113 | { |
| 114 | return s->typecxx . . $ $anonymous_type_e343b93576372a1f_1#type.->namecxx . . $ $anonymous_type_e343b93576372a1f_0#name.; |
| 115 | } |
| 116 | |
| 117 | |
| 118 | gsl_vectorcxx . . $ gsl_vector# * |
| 119 | gsl_multimin_fminimizer_xcxx . . $ gsl_multimin_fminimizer_x(c6e2b5c593d882cd). (const gsl_multimin_fminimizercxx . . $ gsl_multimin_fminimizer# * s) |
| 120 | { |
| 121 | return s->xcxx . . $ $anonymous_type_e343b93576372a1f_1#x.; |
| 122 | } |
| 123 | |
| 124 | double |
| 125 | gsl_multimin_fminimizer_minimumcxx . . $ gsl_multimin_fminimizer_minimum(8b6fcc202053b7cc). (const gsl_multimin_fminimizercxx . . $ gsl_multimin_fminimizer# * s) |
| 126 | { |
| 127 | return s->fvalcxx . . $ $anonymous_type_e343b93576372a1f_1#fval.; |
| 128 | } |
| 129 | |
| 130 | double |
| 131 | gsl_multimin_fminimizer_sizecxx . . $ gsl_multimin_fminimizer_size(8b6fcc202053b7cc). (const gsl_multimin_fminimizercxx . . $ gsl_multimin_fminimizer# * s) |
| 132 | { |
| 133 | return s->sizecxx . . $ $anonymous_type_e343b93576372a1f_1#size.; |
| 134 | } |