chiark / gitweb /
C++ compilation fixes
authorstevenj <stevenj@alum.mit.edu>
Fri, 28 May 2010 16:44:40 +0000 (12:44 -0400)
committerstevenj <stevenj@alum.mit.edu>
Fri, 28 May 2010 16:44:40 +0000 (12:44 -0400)
darcs-hash:20100528164440-c8de0-870eb4a31ef2c3a9f0633b8be912b0f2c3156b70.gz

auglag/auglag.c
cdirect/cdirect.c
cdirect/cdirect.h
cobyla/cobyla.c
neldermead/sbplx.c

index 8c85f3955fb055557b2f975bafd24fcdc46c350b..4e5881e87d7ec31da4b5e5cf399f75cc9108b176 100644 (file)
@@ -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);
 
index 8ab211c6d7352fa9bd68191e8825655905f35d7a..ed315eeb9bd448716519b2cbe096b9244b5a0c06 100644 (file)
@@ -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);
index 0222577eba632a23724df0bdf0c144ad6999bb5f..09284ff739961af50dec487f289519fa0c987015 100644 (file)
@@ -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" */
index a285793bc49eb57f701d96811dda3b132dcfcf14..9be178b812242c3a1578ff9ba7e8ba9af25f46f3 100644 (file)
@@ -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;
 
 /*
index efe68a43f1f653a428ee599f8a373574ce22de9c..d5b7fe4e97493bdc79561c0fb251c4993097b8a5 100644 (file)
@@ -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);
 }