Debian Codegraph @

external/gsl/gsl_multiroots__newton.c

raw symbols SCIP
1 /* multiroots/newton.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
22 #include <stddef.h>
23 #include <stdlib.h>
24 #include <stdio.h>
25 #include <math.h>
26 #include <float.h>
27
28 #include "gsl_math.h"cxx . . $ `<file>/external/gsl/gsl_math.h`/
29 #include "gsl_errno.h"cxx . . $ `<file>/external/gsl/gsl_errno.h`/
30 #include "gsl_multiroots.h"cxx . . $ `<file>/external/gsl/gsl_multiroots.h`/
31 #include "gsl_linalg.h"cxx . . $ `<file>/external/gsl/gsl_linalg.h`/
32
33 typedef structcxx . . $ $anonymous_type_8d1668aafc88f3b6_0#
34 {
35 gsl_matrixcxx . . $ gsl_matrix# * lucxx . . $ $anonymous_type_8d1668aafc88f3b6_0#lu.;
36 gsl_permutationcxx . . $ gsl_permutation# * permutationcxx . . $ $anonymous_type_8d1668aafc88f3b6_0#permutation.;
37 }
38 newton_state_tcxx . . $ newton_state_t#;
39
40 static int newton_alloccxx . . $ newton_alloc(c0a5f96701d3f89). (void * vstate, size_t n);
41 static int newton_setcxx . . $ newton_set(36a4c1ecdfe5d338). (void * vstate, gsl_multiroot_function_fdfcxx . . $ gsl_multiroot_function_fdf# * fdf, gsl_vectorcxx . . $ gsl_vector# * x, gsl_vectorcxx . . $ gsl_vector# * f, gsl_matrixcxx . . $ gsl_matrix# * J, gsl_vectorcxx . . $ gsl_vector# * dx);
42 static int newton_iteratecxx . . $ newton_iterate(36a4c1ecdfe5d338). (void * vstate, gsl_multiroot_function_fdfcxx . . $ gsl_multiroot_function_fdf# * fdf, gsl_vectorcxx . . $ gsl_vector# * x, gsl_vectorcxx . . $ gsl_vector# * f, gsl_matrixcxx . . $ gsl_matrix# * J, gsl_vectorcxx . . $ gsl_vector# * dx);
43 static void newton_freecxx . . $ newton_free(5d22bdacc48458e8). (void * vstate);
44
45 static int
46 newton_alloccxx . . $ newton_alloc(c0a5f96701d3f89). (void * vstate, size_t n)
47 {
48 newton_state_tcxx . . $ newton_state_t# * state = (newton_state_tcxx . . $ newton_state_t# *) vstate;
49 gsl_permutationcxx . . $ gsl_permutation# * p;
50 gsl_matrixcxx . . $ gsl_matrix# * m;
51
52 m = gsl_matrix_calloccxx . . $ gsl_matrix_calloc(5a4d020b4836594). (n,n);
53
54 if (m == 0)
55 {
56 GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("failed to allocate space for lu", GSL_ENOMEM);
57 }
58
59 state->lucxx . . $ $anonymous_type_8d1668aafc88f3b6_0#lu. = m ;
60
61 p = gsl_permutation_calloccxx . . $ gsl_permutation_calloc(311f4cfee96dd0e3). (n);
62
63 if (p == 0)
64 {
65 gsl_matrix_freecxx . . $ gsl_matrix_free(ab29a617cccd3636).(m);
66
67 GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("failed to allocate space for permutation", GSL_ENOMEM);
68 }
69
70 state->permutationcxx . . $ $anonymous_type_8d1668aafc88f3b6_0#permutation. = p ;
71
72 return GSL_SUCCESScxx . . $ GSL_SUCCESS.;
73 }
74
75 static int
76 newton_setcxx . . $ newton_set(36a4c1ecdfe5d338). (void * vstate, gsl_multiroot_function_fdfcxx . . $ gsl_multiroot_function_fdf# * FDF, gsl_vectorcxx . . $ gsl_vector# * x, gsl_vectorcxx . . $ gsl_vector# * f, gsl_matrixcxx . . $ gsl_matrix# * J, gsl_vectorcxx . . $ gsl_vector# * dx)
77 {
78 size_t i, n = FDF->ncxx . . $ gsl_multiroot_function_fdf_struct#n. ;
79
80 GSL_MULTIROOT_FN_EVAL_F_DFcxx . . $ `external/gsl/gsl_multiroots.h:114:9`! (FDF, x, f, J);
81
82 for (i = 0; i < n; i++)
83 {
84 gsl_vector_setcxx . . $ gsl_vector_set(c35f863a529e8fae). (dx, i, 0.0);
85 }
86
87 return GSL_SUCCESScxx . . $ GSL_SUCCESS.;
88 }
89
90 static int
91 newton_iteratecxx . . $ newton_iterate(36a4c1ecdfe5d338). (void * vstate, gsl_multiroot_function_fdfcxx . . $ gsl_multiroot_function_fdf# * fdf, gsl_vectorcxx . . $ gsl_vector# * x, gsl_vectorcxx . . $ gsl_vector# * f, gsl_matrixcxx . . $ gsl_matrix# * J, gsl_vectorcxx . . $ gsl_vector# * dx)
92 {
93 newton_state_tcxx . . $ newton_state_t# * state = (newton_state_tcxx . . $ newton_state_t# *) vstate;
94
95 int signum;
96
97 size_t i;
98
99 size_t n = fdf->ncxx . . $ gsl_multiroot_function_fdf_struct#n. ;
100
101 gsl_matrix_memcpycxx . . $ gsl_matrix_memcpy(2d55a18be0e0c72f). (state->lucxx . . $ $anonymous_type_8d1668aafc88f3b6_0#lu., J);
102
103 gsl_linalg_LU_decompcxx . . $ gsl_linalg_LU_decomp(e9d4741e9a7c7a22). (state->lucxx . . $ $anonymous_type_8d1668aafc88f3b6_0#lu., state->permutationcxx . . $ $anonymous_type_8d1668aafc88f3b6_0#permutation., &signum);
104
105 gsl_linalg_LU_solvecxx . . $ gsl_linalg_LU_solve(58522a8301ae2475). (state->lucxx . . $ $anonymous_type_8d1668aafc88f3b6_0#lu., state->permutationcxx . . $ $anonymous_type_8d1668aafc88f3b6_0#permutation., f, dx);
106
107 for (i = 0; i < n; i++)
108 {
109 double e = gsl_vector_getcxx . . $ gsl_vector_get(bd1f20df78adc7a). (dx, i);
110 double y = gsl_vector_getcxx . . $ gsl_vector_get(bd1f20df78adc7a). (x, i);
111 gsl_vector_setcxx . . $ gsl_vector_set(c35f863a529e8fae). (dx, i, -e);
112 gsl_vector_setcxx . . $ gsl_vector_set(c35f863a529e8fae). (x, i, y - e);
113 }
114
115 {
116 int status = GSL_MULTIROOT_FN_EVAL_F_DFcxx . . $ `external/gsl/gsl_multiroots.h:114:9`! (fdf, x, f, J);
117
118 if (status != GSL_SUCCESScxx . . $ GSL_SUCCESS.)
119 {
120 return GSL_EBADFUNCcxx . . $ GSL_EBADFUNC.;
121 }
122 }
123
124 return GSL_SUCCESScxx . . $ GSL_SUCCESS.;
125 }
126
127
128 static void
129 newton_freecxx . . $ newton_free(5d22bdacc48458e8). (void * vstate)
130 {
131 newton_state_tcxx . . $ newton_state_t# * state = (newton_state_tcxx . . $ newton_state_t# *) vstate;
132
133 gsl_matrix_freecxx . . $ gsl_matrix_free(ab29a617cccd3636).(state->lucxx . . $ $anonymous_type_8d1668aafc88f3b6_0#lu.);
134
135 gsl_permutation_freecxx . . $ gsl_permutation_free(bfe6c130f63679fa).(state->permutationcxx . . $ $anonymous_type_8d1668aafc88f3b6_0#permutation.);
136 }
137
138
139 static const gsl_multiroot_fdfsolver_typecxx . . $ gsl_multiroot_fdfsolver_type# newton_typecxx . . $ newton_type. =
140 {"newton", /* name */
141 sizeof (newton_state_tcxx . . $ newton_state_t#),
142 &newton_alloccxx . . $ newton_alloc(c0a5f96701d3f89).,
143 &newton_setcxx . . $ newton_set(36a4c1ecdfe5d338).,
144 &newton_iteratecxx . . $ newton_iterate(36a4c1ecdfe5d338).,
145 &newton_freecxx . . $ newton_free(5d22bdacc48458e8).};
146
147 const gsl_multiroot_fdfsolver_typecxx . . $ gsl_multiroot_fdfsolver_type# * gsl_multiroot_fdfsolver_newtoncxx . . $ gsl_multiroot_fdfsolver_newton. = &newton_typecxx . . $ newton_type.;