Debian Codegraph @

external/gsl/gsl_multifit__lmiterate.c

raw symbols SCIP
1 staticcxx . . $ `<file>/external/gsl/gsl_multifit__lmiterate.c`/ int
2 iteratecxx . . $ iterate(75a59fa53ef762b1). (void *vstate, gsl_multifit_function_fdfcxx . . $ gsl_multifit_function_fdf# * fdf, gsl_vectorcxx . . $ gsl_vector# * x, gsl_vectorcxx . . $ gsl_vector# * f, gsl_matrixcxx . . $ gsl_matrix# * J, gsl_vectorcxx . . $ gsl_vector# * dx, int scale)
3 {
4 lmder_state_tcxx . . $ lmder_state_t# *state = (lmder_state_tcxx . . $ lmder_state_t# *) vstate;
5
6 gsl_matrixcxx . . $ gsl_matrix# *r = state->rcxx . . $ $anonymous_type_9e3e468d83e34f36_0#r.;
7 gsl_vectorcxx . . $ gsl_vector# *tau = state->taucxx . . $ $anonymous_type_9e3e468d83e34f36_0#tau.;
8 gsl_vectorcxx . . $ gsl_vector# *diag = state->diagcxx . . $ $anonymous_type_9e3e468d83e34f36_0#diag.;
9 gsl_vectorcxx . . $ gsl_vector# *qtf = state->qtfcxx . . $ $anonymous_type_9e3e468d83e34f36_0#qtf.;
10 gsl_vectorcxx . . $ gsl_vector# *x_trial = state->x_trialcxx . . $ $anonymous_type_9e3e468d83e34f36_0#x_trial.;
11 gsl_vectorcxx . . $ gsl_vector# *f_trial = state->f_trialcxx . . $ $anonymous_type_9e3e468d83e34f36_0#f_trial.;
12 gsl_vectorcxx . . $ gsl_vector# *rptdx = state->rptdxcxx . . $ $anonymous_type_9e3e468d83e34f36_0#rptdx.;
13 gsl_vectorcxx . . $ gsl_vector# *newton = state->newtoncxx . . $ $anonymous_type_9e3e468d83e34f36_0#newton.;
14 gsl_vectorcxx . . $ gsl_vector# *gradient = state->gradientcxx . . $ $anonymous_type_9e3e468d83e34f36_0#gradient.;
15 gsl_vectorcxx . . $ gsl_vector# *sdiag = state->sdiagcxx . . $ $anonymous_type_9e3e468d83e34f36_0#sdiag.;
16 gsl_vectorcxx . . $ gsl_vector# *w = state->wcxx . . $ $anonymous_type_9e3e468d83e34f36_0#w.;
17 gsl_vectorcxx . . $ gsl_vector# *work1 = state->work1cxx . . $ $anonymous_type_9e3e468d83e34f36_0#work1.;
18 gsl_permutationcxx . . $ gsl_permutation# *perm = state->permcxx . . $ $anonymous_type_9e3e468d83e34f36_0#perm.;
19
20 double prered, actred;
21 double pnorm, fnorm1, fnorm1p, gnorm;
22 double ratio;
23 double dirder;
24
25 int iter = 0;
26
27 double p1 = 0.1, p25 = 0.25, p5 = 0.5, p75 = 0.75, p0001 = 0.0001;
28
29 if (state->fnormcxx . . $ $anonymous_type_9e3e468d83e34f36_0#fnorm. == 0.0)
30 {
31 return GSL_SUCCESScxx . . $ GSL_SUCCESS.;
32 }
33
34 /* Compute qtf = Q^T f */
35
36 gsl_vector_memcpycxx . . $ gsl_vector_memcpy(950c164c4e50c555). (qtf, f);
37 gsl_linalg_QR_QTveccxx . . $ gsl_linalg_QR_QTvec(c419fed7545aef1d). (r, tau, qtf);
38
39 /* Compute norm of scaled gradient */
40
41 compute_gradient_directioncxx . . $ compute_gradient_direction(c5955c8cf6d9de3f). (r, perm, qtf, diag, gradient);
42
43 {
44 size_t iamax = gsl_blas_idamaxcxx . . $ gsl_blas_idamax(5954d1cf5d86524e). (gradient);
45
46 gnorm = fabs(gsl_vector_getcxx . . $ gsl_vector_get(bd1f20df78adc7a). (gradient, iamax) / state->fnormcxx . . $ $anonymous_type_9e3e468d83e34f36_0#fnorm.);
47 }
48
49 /* Determine the Levenberg-Marquardt parameter */
50
51 lm_iteration:
52
53 iter++ ;
54
55 {
56 int status = lmparcxx . . $ lmpar(9017207d366e1657). (r, perm, qtf, diag, state->deltacxx . . $ $anonymous_type_9e3e468d83e34f36_0#delta., &(state->parcxx . . $ $anonymous_type_9e3e468d83e34f36_0#par.), newton, gradient, sdiag, dx, w);
57 if (status)
58 return status;
59 }
60
61 /* Take a trial step */
62
63 gsl_vector_scalecxx . . $ gsl_vector_scale(ddf696d31a4a9aeb). (dx, -1.0); /* reverse the step to go downhill */
64
65 compute_trial_stepcxx . . $ compute_trial_step(8bd3db731690f6c2). (x, dx, state->x_trialcxx . . $ $anonymous_type_9e3e468d83e34f36_0#x_trial.);
66
67 pnorm = scaled_enormcxx . . $ scaled_enorm(d7a1c0a0f7c25398). (diag, dx);
68
69 if (state->itercxx . . $ $anonymous_type_9e3e468d83e34f36_0#iter. == 1)
70 {
71 if (pnorm < state->deltacxx . . $ $anonymous_type_9e3e468d83e34f36_0#delta.)
72 {
73 #ifdef DEBUG
74 printf("set delta = pnorm = %g\n" , pnorm);
75 #endif
76 state->deltacxx . . $ $anonymous_type_9e3e468d83e34f36_0#delta. = pnorm;
77 }
78 }
79
80 /* Evaluate function at x + p */
81 /* return immediately if evaluation raised error */
82 {
83 int status = GSL_MULTIFIT_FN_EVAL_Fcxx . . $ `external/gsl/gsl_multifit_nlin.h:113:9`! (fdf, x_trial, f_trial);
84 if (status)
85 return status;
86 }
87
88 fnorm1 = enormcxx . . $ enorm(1b712e435b5359e9). (f_trial);
89
90 /* Compute the scaled actual reduction */
91
92 actred = compute_actual_reductioncxx . . $ compute_actual_reduction(d8e7e0733fa41c87). (state->fnormcxx . . $ $anonymous_type_9e3e468d83e34f36_0#fnorm., fnorm1);
93
94 #ifdef DEBUG
95 printf("lmiterate: fnorm = %g fnorm1 = %g actred = %g\n", state->fnorm, fnorm1, actred);
96 printf("r = "); gsl_matrix_fprintf(stdout, r, "%g");
97 printf("perm = "); gsl_permutation_fprintf(stdout, perm, "%d");
98 printf("dx = "); gsl_vector_fprintf(stdout, dx, "%g");
99 #endif
100
101 /* Compute rptdx = R P^T dx, noting that |J dx| = |R P^T dx| */
102
103 compute_rptdxcxx . . $ compute_rptdx(9fc0152a492dd699). (r, perm, dx, rptdx);
104
105 #ifdef DEBUG
106 printf("rptdx = "); gsl_vector_fprintf(stdout, rptdx, "%g");
107 #endif
108
109 fnorm1p = enormcxx . . $ enorm(1b712e435b5359e9). (rptdx);
110
111 /* Compute the scaled predicted reduction = |J dx|^2 + 2 par |D dx|^2 */
112
113 {
114 double t1 = fnorm1p / state->fnormcxx . . $ $anonymous_type_9e3e468d83e34f36_0#fnorm.;
115 double t2 = (sqrt(state->parcxx . . $ $anonymous_type_9e3e468d83e34f36_0#par.) * pnorm) / state->fnormcxx . . $ $anonymous_type_9e3e468d83e34f36_0#fnorm.;
116
117 prered = t1 * t1 + t2 * t2 / p5;
118 dirder = -(t1 * t1 + t2 * t2);
119 }
120
121 /* compute the ratio of the actual to predicted reduction */
122
123 if (prered > 0)
124 {
125 ratio = actred / prered;
126 }
127 else
128 {
129 ratio = 0;
130 }
131
132 #ifdef DEBUG
133 printf("lmiterate: prered = %g dirder = %g ratio = %g\n", prered, dirder,ratio);
134 #endif
135
136
137 /* update the step bound */
138
139 if (ratio > p25)
140 {
141 #ifdef DEBUG
142 printf("ratio > p25\n");
143 #endif
144 if (state->parcxx . . $ $anonymous_type_9e3e468d83e34f36_0#par. == 0 || ratio >= p75)
145 {
146 state->deltacxx . . $ $anonymous_type_9e3e468d83e34f36_0#delta. = pnorm / p5;
147 state->parcxx . . $ $anonymous_type_9e3e468d83e34f36_0#par. *= p5;
148 #ifdef DEBUG
149 printf("updated step bounds: delta = %g, par = %g\n", state->delta, state->par);
150 #endif
151 }
152 }
153 else
154 {
155 double temp = (actred >= 0) ? p5 : p5*dirder / (dirder + p5 * actred);
156
157 #ifdef DEBUG
158 printf("ratio < p25\n");
159 #endif
160
161 if (p1 * fnorm1 >= state->fnormcxx . . $ $anonymous_type_9e3e468d83e34f36_0#fnorm. || temp < p1 )
162 {
163 temp = p1;
164 }
165
166 state->deltacxx . . $ $anonymous_type_9e3e468d83e34f36_0#delta. = temp * GSL_MIN_DBLcxx . . $ `external/gsl/gsl_math.h:178:9`! (state->delta, pnorm/p1);
167
168 state->parcxx . . $ $anonymous_type_9e3e468d83e34f36_0#par. /= temp;
169 #ifdef DEBUG
170 printf("updated step bounds: delta = %g, par = %g\n", state->delta, state->par);
171 #endif
172 }
173
174
175 /* test for successful iteration, termination and stringent tolerances */
176
177 if (ratio >= p0001)
178 {
179 gsl_vector_memcpycxx . . $ gsl_vector_memcpy(950c164c4e50c555). (x, x_trial);
180 gsl_vector_memcpycxx . . $ gsl_vector_memcpy(950c164c4e50c555). (f, f_trial);
181
182 /* return immediately if evaluation raised error */
183 {
184 int status = GSL_MULTIFIT_FN_EVAL_DFcxx . . $ `external/gsl/gsl_multifit_nlin.h:114:9`! (fdf, x_trial, J);
185 if (status)
186 return status;
187 }
188
189 /* wa2_j = diag_j * x_j */
190 state->xnormcxx . . $ $anonymous_type_9e3e468d83e34f36_0#xnorm. = scaled_enormcxx . . $ scaled_enorm(d7a1c0a0f7c25398).(diag, x);
191 state->fnormcxx . . $ $anonymous_type_9e3e468d83e34f36_0#fnorm. = fnorm1;
192 state->itercxx . . $ $anonymous_type_9e3e468d83e34f36_0#iter.++;
193
194 /* Rescale if necessary */
195
196 if (scale)
197 {
198 update_diagcxx . . $ update_diag(3663f5842c4582d6). (J, diag);
199 }
200
201 {
202 int signum;
203 gsl_matrix_memcpycxx . . $ gsl_matrix_memcpy(2d55a18be0e0c72f). (r, J);
204 gsl_linalg_QRPT_decompcxx . . $ gsl_linalg_QRPT_decomp(d6e1b21eccd765e2). (r, tau, perm, &signum, work1);
205 }
206
207 return GSL_SUCCESScxx . . $ GSL_SUCCESS.;
208 }
209 else if (fabs(actred) <= GSL_DBL_EPSILONcxx . . $ `external/gsl/gsl_machine.h:17:9`! && prered <= GSL_DBL_EPSILONcxx . . $ `external/gsl/gsl_machine.h:17:9`!
210 && p5 * ratio <= 1.0)
211 {
212 return GSL_ETOLFcxx . . $ GSL_ETOLF. ;
213 }
214 else if (state->deltacxx . . $ $anonymous_type_9e3e468d83e34f36_0#delta. <= GSL_DBL_EPSILONcxx . . $ `external/gsl/gsl_machine.h:17:9`! * state->xnormcxx . . $ $anonymous_type_9e3e468d83e34f36_0#xnorm.)
215 {
216 return GSL_ETOLXcxx . . $ GSL_ETOLX.;
217 }
218 else if (gnorm <= GSL_DBL_EPSILONcxx . . $ `external/gsl/gsl_machine.h:17:9`!)
219 {
220 return GSL_ETOLGcxx . . $ GSL_ETOLG.;
221 }
222 else if (iter < 10)
223 {
224 /* Repeat inner loop if unsuccessful */
225 goto lm_iteration;
226 }
227
228 return GSL_CONTINUEcxx . . $ GSL_CONTINUE.;
229 }