ex-1: changed do-while with for
This commit is contained in:
parent
894854948d
commit
c560f3c57c
@ -93,7 +93,6 @@ double numeric_mode(double min, double max,
|
||||
|
||||
// initialize minimization
|
||||
double x = 0;
|
||||
int iter = 0;
|
||||
int max_iter = 100;
|
||||
double prec = 1e-7;
|
||||
int status;
|
||||
@ -102,15 +101,14 @@ double numeric_mode(double min, double max,
|
||||
gsl_min_fminimizer_set(s, &npdf, x, min, max);
|
||||
|
||||
// minimisation
|
||||
do {
|
||||
iter++;
|
||||
for (int iter = 0; status == GSL_CONTINUE && iter < max_iter; iter++)
|
||||
{
|
||||
status = gsl_min_fminimizer_iterate(s);
|
||||
x = gsl_min_fminimizer_x_minimum(s);
|
||||
min = gsl_min_fminimizer_x_lower(s);
|
||||
max = gsl_min_fminimizer_x_upper(s);
|
||||
status = gsl_min_test_interval(min, max, 0, prec);
|
||||
|
||||
} while (status == GSL_CONTINUE && iter < max_iter);
|
||||
}
|
||||
|
||||
/* The error is simply given by the width of
|
||||
* the final interval containing the solution
|
||||
|
Loading…
Reference in New Issue
Block a user