From: stevenj Date: Fri, 28 May 2010 16:44:40 +0000 (-0400) Subject: C++ compilation fixes X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=b7c9157807ea9c5e8846b0325890ca33353a27c8;p=nlopt.git C++ compilation fixes darcs-hash:20100528164440-c8de0-870eb4a31ef2c3a9f0633b8be912b0f2c3156b70.gz --- diff --git a/auglag/auglag.c b/auglag/auglag.c index 8c85f39..4e5881e 100644 --- a/auglag/auglag.c +++ b/auglag/auglag.c @@ -22,14 +22,15 @@ typedef struct { } auglag_data; /* the augmented lagrangian objective function */ -static double auglag(int n, const double *x, double *grad, void *data) +static double auglag(unsigned n, const double *x, double *grad, void *data) { auglag_data *d = (auglag_data *) data; double *gradtmp = grad ? d->gradtmp : NULL; double rho = d->rho; const double *lambda = d->lambda, *mu = d->mu; double L; - int i, j; + int i; + unsigned j; L = d->f(n, x, grad, d->f_data); diff --git a/cdirect/cdirect.c b/cdirect/cdirect.c index 8ab211c..ed315ee 100644 --- a/cdirect/cdirect.c +++ b/cdirect/cdirect.c @@ -408,8 +408,8 @@ static nlopt_result divide_good_rects(params *p) int im, ip; /* find unequal points before (im) and after (ip) to get slope */ - for (im = i-1; im >= 0 && hull[im][0] == hull[i][0]; --im); - for (ip = i+1; ip < nhull && hull[ip][0] == hull[i][0]; ++ip); + for (im = i-1; im >= 0 && hull[im][0] == hull[i][0]; --im) ; + for (ip = i+1; ip < nhull && hull[ip][0] == hull[i][0]; ++ip) ; if (im >= 0) K1 = (hull[i][1] - hull[im][1]) / (hull[i][0] - hull[im][0]); @@ -552,11 +552,11 @@ nlopt_result cdirect_unscaled(int n, nlopt_func f, void *f_data, coordinates to a unit hypercube ... we do this simply by wrapping cdirect() around cdirect_unscaled(). */ -double cdirect_uf(int n, const double *xu, double *grad, void *d_) +double cdirect_uf(unsigned n, const double *xu, double *grad, void *d_) { cdirect_uf_data *d = (cdirect_uf_data *) d_; double f; - int i; + unsigned i; for (i = 0; i < n; ++i) d->x[i] = d->lb[i] + xu[i] * (d->ub[i] - d->lb[i]); f = d->f(n, d->x, grad, d->f_data); diff --git a/cdirect/cdirect.h b/cdirect/cdirect.h index 0222577..09284ff 100644 --- a/cdirect/cdirect.h +++ b/cdirect/cdirect.h @@ -71,7 +71,7 @@ typedef struct { double *x; const double *lb, *ub; } cdirect_uf_data; -extern double cdirect_uf(int n, const double *xu, double *grad, void *d_); +extern double cdirect_uf(unsigned n, const double *xu, double *grad, void *d_); #ifdef __cplusplus } /* extern "C" */ diff --git a/cobyla/cobyla.c b/cobyla/cobyla.c index a285793..9be178b 100644 --- a/cobyla/cobyla.c +++ b/cobyla/cobyla.c @@ -108,7 +108,7 @@ typedef enum { COBYLA_MSG_NONE = 0, /* No messages */ COBYLA_MSG_EXIT = 1, /* Exit reasons */ COBYLA_MSG_ITER = 2, /* Rho and Sigma changes */ - COBYLA_MSG_INFO = 3, /* Informational messages */ + COBYLA_MSG_INFO = 3 /* Informational messages */ } cobyla_message; /* diff --git a/neldermead/sbplx.c b/neldermead/sbplx.c index efe68a4..d5b7fe4 100644 --- a/neldermead/sbplx.c +++ b/neldermead/sbplx.c @@ -51,7 +51,7 @@ typedef struct { } subspace_data; /* wrapper around objective function for subspace optimization */ -static double subspace_func(int ns, const double *xs, double *grad, void *data) +static double subspace_func(unsigned ns, const double *xs, double *grad, void *data) { subspace_data *d = (subspace_data *) data; int i, is = d->is; @@ -59,7 +59,7 @@ static double subspace_func(int ns, const double *xs, double *grad, void *data) double *x = d->x; (void) grad; /* should always be NULL here */ - for (i = is; i < is + ns; ++i) x[p[i]] = xs[i-is]; + for (i = is; i < is + ((int) ns); ++i) x[p[i]] = xs[i-is]; return d->f(d->n, x, NULL, d->f_data); }