chiark / gitweb /
a few int -> unsigned fixes
authorstevenj <stevenj@alum.mit.edu>
Fri, 28 May 2010 16:37:37 +0000 (12:37 -0400)
committerstevenj <stevenj@alum.mit.edu>
Fri, 28 May 2010 16:37:37 +0000 (12:37 -0400)
darcs-hash:20100528163737-c8de0-c889ae8574dbe08c7bd3e5af247574f8a3fc0c3e.gz

mlsl/mlsl.c
mma/mma.c
mma/mma.h

index fa4830175205c052ef1c275f6a85daf7b60155c6..70356a4bfec5cdd6618e23538d464e4d92a9f1c8 100644 (file)
@@ -247,7 +247,7 @@ static pt *alloc_pt(int n)
 }
 
 /* wrapper around objective function that increments evaluation count */
-static double fcount(int n, const double *x, double *grad, void *p_)
+static double fcount(unsigned n, const double *x, double *grad, void *p_)
 {
      mlsl_data *p = (mlsl_data *) p_;
      p->stop->nevals++;
index d882ef850fe4a851e26ff90942f4a14d780958f2..638e07d2c48a1debfb3f4e8fd13845bb4726110d 100644 (file)
--- a/mma/mma.c
+++ b/mma/mma.c
@@ -28,7 +28,7 @@
 #include "mma.h"
 #include "nlopt-util.h"
 
-int mma_verbose = 0; /* > 0 for verbose output */
+unsigned mma_verbose = 0; /* > 0 for verbose output */
 
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
@@ -50,7 +50,7 @@ static int my_isnan(double x) { return x != x; }
 
 typedef struct {
      int count; /* evaluation count, incremented each call */
-     int n; /* must be set on input to dimension of x */
+     unsigned n; /* must be set on input to dimension of x */
      const double *x, *lb, *ub, *sigma, *dfdx; /* arrays of length n */
      const double *dfcdx; /* m-by-n array of fc gradients */
      double fval, rho; /* must be set on input */
@@ -61,10 +61,10 @@ typedef struct {
 
 static double sqr(double x) { return x * x; }
 
-static double dual_func(int m, const double *y, double *grad, void *d_)
+static double dual_func(unsigned m, const double *y, double *grad, void *d_)
 {
      dual_data *d = (dual_data *) d_;
-     int n = d->n;
+     unsigned n = d->n;
      const double *x = d->x, *lb = d->lb, *ub = d->ub, *sigma = d->sigma, 
          *dfdx = d->dfdx;
      const double *dfcdx = d->dfcdx;
@@ -72,7 +72,7 @@ static double dual_func(int m, const double *y, double *grad, void *d_)
      const double *rhoc = d->rhoc, *fcval = d->fcval;
      double *xcur = d->xcur;
      double *gcval = d->gcval;
-     int i, j;
+     unsigned i, j;
      double val;
 
      d->count++;
@@ -145,8 +145,8 @@ static double dual_func(int m, const double *y, double *grad, void *d_)
    nlopt_minimize_constrained interface: whenever the constraint
    function returns NaN, that constraint becomes inactive. */
 
-nlopt_result mma_minimize(int n, nlopt_func f, void *f_data,
-                         int m, nlopt_constraint *fc,
+nlopt_result mma_minimize(unsigned n, nlopt_func f, void *f_data,
+                         unsigned m, nlopt_constraint *fc,
                          const double *lb, const double *ub, /* bounds */
                          double *x, /* in: initial guess, out: minimizer */
                          double *minf,
@@ -157,7 +157,7 @@ nlopt_result mma_minimize(int n, nlopt_func f, void *f_data,
      double *xcur, rho, *sigma, *dfdx, *dfdx_cur, *xprev, *xprevprev, fcur;
      double *dfcdx, *dfcdx_cur;
      double *fcval, *fcval_cur, *rhoc, *gcval, *y, *dual_lb, *dual_ub;
-     int i, j, k = 0;
+     unsigned i, j, k = 0;
      dual_data dd;
      int feasible;
      double infeasibility;
@@ -246,7 +246,8 @@ nlopt_result mma_minimize(int n, nlopt_func f, void *f_data,
 
          while (1) { /* inner iterations */
               double min_dual, infeasibility_cur;
-              int feasible_cur, inner_done, save_verbose;
+              int feasible_cur, inner_done;
+              unsigned save_verbose;
               int new_infeasible_constraint;
               nlopt_result reti;
 
index 3b2c04021681b2e466230981e8a7dd1d902e8be2..9a4aacde003567c646714fb32c4b3d37bc442f19 100644 (file)
--- a/mma/mma.h
+++ b/mma/mma.h
@@ -31,10 +31,10 @@ extern "C"
 {
 #endif /* __cplusplus */
 
-extern int mma_verbose;
+extern unsigned mma_verbose;
 
-nlopt_result mma_minimize(int n, nlopt_func f, void *f_data,
-                         int m, nlopt_constraint *fc,
+nlopt_result mma_minimize(unsigned n, nlopt_func f, void *f_data,
+                         unsigned m, nlopt_constraint *fc,
                          const double *lb, const double *ub, /* bounds */
                          double *x, /* in: initial guess, out: minimizer */
                          double *minf,