chiark / gitweb /
minor edits
authorAmro <amroamroamro@gmail.com>
Tue, 13 Sep 2016 17:42:16 +0000 (20:42 +0300)
committerAmro <amroamroamro@gmail.com>
Tue, 13 Sep 2016 18:13:26 +0000 (21:13 +0300)
- use C-style comments /* .. */ in .c files
- trim trailing spaces and other minor style edits

api/options.c
esch/esch.c
slsqp/slsqp.c
stogo/stogo_config.h
test/box.c
test/testfuncs.c
util/mt19937ar.c

index 626a38b8c04323f69ed2be1020a236a7587b3a68..ba2a1b8f064795bd23c0c3f4ace981d1b809ff4b 100644 (file)
@@ -211,7 +211,7 @@ nlopt_opt NLOPT_STDCALL nlopt_copy(const nlopt_opt opt)
      return nopt;
 
 oom:
-     nopt->munge_on_destroy = NULL; // better to leak mem than crash
+     nopt->munge_on_destroy = NULL; /* better to leak mem than crash */
      nlopt_destroy(nopt);
      return NULL;
 }
index 8a21cb9ccce23a4baa184ce0bfdb0cfcc9ed5398..6fd5ecb65e4f642af6c60c6608bb663a62c26b3a 100644 (file)
@@ -7,25 +7,25 @@
  * distribute, sublicense, and/or sell copies of the Software, and to
  * permit persons to whom the Software is furnished to do so, subject to
  * the following conditions:
- * 
+ *
  * The above copyright notice and this permission notice shall be
  * included in all copies or substantial portions of the Software.
- * 
+ *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
 #include <stdlib.h>
 #include <string.h>
 #include "esch.h"
 
-// ---------------------------------------------------------------------------
-// Cauchy random number distribution
+/****************************************************************************/
+/* Cauchy random number distribution */
 static double randcauchy(const double params[7]) {
      /* double min, double max, double mi, double t, double band */
      double na_unif, cauchy_mit, limit_inf, limit_sup;
@@ -35,35 +35,35 @@ static double randcauchy(const double params[7]) {
      limit_inf = mi - (band*0.5);
      limit_sup = mi + (band*0.5);
      do {
-         na_unif = nlopt_urand(0,1); // ran2(0,1);
+         na_unif = nlopt_urand(0,1); /* ran2(0,1); */
          cauchy_mit = t*tan((na_unif-0.5)*3.14159265358979323846) + mi;
-     } while ( (cauchy_mit<limit_inf) || (cauchy_mit>limit_sup) );   
-     
+     } while ( (cauchy_mit<limit_inf) || (cauchy_mit>limit_sup) );
+
      if (cauchy_mit < 0)
          cauchy_mit = -cauchy_mit;
      else
          cauchy_mit = cauchy_mit + (band*0.5);
      valor  = cauchy_mit/band;
-     valor = min+(max-min)*valor;   
-     return valor;  
+     valor = min+(max-min)*valor;
+     return valor;
 }
 
-// ---------------------------------------------------------------------------
+/****************************************************************************/
 
-// main Individual representation type
+/* main Individual representation type */
 typedef struct IndividualStructure {
      double * parameters;
      double fitness;
-} Individual; 
+} Individual;
 
 static int CompareIndividuals(void *unused, const void *a_, const void *b_) {
-     // (void) unused;
+     /* (void) unused; */
      const Individual *a = (const Individual *) a_;
      const Individual *b = (const Individual *) b_;
      return a->fitness < b->fitness ? -1 : (a->fitness > b->fitness ? +1 : 0);
 }
 
-nlopt_result chevolutionarystrategy( 
+nlopt_result chevolutionarystrategy(
      unsigned nparameters, /* Number of input parameters */
      nlopt_func f,     /* Recursive Objective Funtion Call */
      void * data_f,    /* Data to Objective Function */
@@ -72,29 +72,29 @@ nlopt_result chevolutionarystrategy(
      double* x,                                /*in: initial guess, out: minimizer */
      double* minf,
      nlopt_stopping* stop,             /* nlopt stop condition */
-     unsigned np,                      /* Number of Parents */ 
+     unsigned np,                      /* Number of Parents */
      unsigned no) {                    /* Number of Offsprings */
 
-     // variables from nlopt
+     /* variables from nlopt */
      nlopt_result ret = NLOPT_SUCCESS;
      double vetor[8];
      unsigned  i, id, item;
      int  parent1, parent2;
-     unsigned crosspoint;  // crossover parameteres
-     int  contmutation, totalmutation; // mutation parameters
-     int  idoffmutation, paramoffmutation;     // mutation parameters
-     Individual * esparents;                   // Parents population
-     Individual * esoffsprings;                // Offsprings population
-     Individual * estotal;// copy containing Parents and Offsprings pops
+     unsigned crosspoint;  /* crossover parameteres */
+     int  contmutation, totalmutation; /* mutation parameters */
+     int  idoffmutation, paramoffmutation;     /* mutation parameters */
+     Individual * esparents;                   /* Parents population */
+     Individual * esoffsprings;                /* Offsprings population */
+     Individual * estotal;/* copy containing Parents and Offsprings pops */
      /* It is interesting to maintain the parents and offsprings
       * populations stablished and sorted; when the final iterations
       * is achieved, they are ranked and updated. */
 
-     // -------------------------------
-     // controling the population size
-     // -------------------------------
+     /*********************************
+      * controling the population size
+      *********************************/
      if (!np) np = 40;
-     if (!no) no = 60;     
+     if (!no) no = 60;
      if ((np < 1)||(no<1)) {
          nlopt_stop_msg(stop, "populations %d, %d are too small", np, no);
          return NLOPT_INVALID_ARGS;
@@ -102,38 +102,38 @@ nlopt_result chevolutionarystrategy(
      esparents    = (Individual*) malloc(sizeof(Individual) * np);
      esoffsprings = (Individual*) malloc(sizeof(Individual) * no);
      estotal    = (Individual*) malloc(sizeof(Individual) * (np+no));
-     if ((!esparents)||(!esoffsprings)||(!estotal)) { 
-         free(esparents); free(esoffsprings); free(estotal); 
+     if ((!esparents)||(!esoffsprings)||(!estotal)) {
+         free(esparents); free(esoffsprings); free(estotal);
          return NLOPT_OUT_OF_MEMORY;
      }
      for (id=0; id < np; id++) esparents[id].parameters = NULL;
      for (id=0; id < no; id++) esoffsprings[id].parameters = NULL;
-     // From here the population is initialized 
+     /* From here the population is initialized */
      /* we don't handle unbounded search regions;
-       this check is unnecessary since it is performed in nlopt_optimize.
-       for (j = 0; j < nparameters; ++j) 
+           this check is unnecessary since it is performed in nlopt_optimize.
+        for (j = 0; j < nparameters; ++j)
          if (nlopt_isinf(low[j]) || nlopt_isinf(up[j]))
            return NLOPT_INVALID_ARGS;
      */
-     // main vector of parameters to randcauchy
-     vetor[0] = 4; // ignored
+     /* main vector of parameters to randcauchy */
+     vetor[0] = 4; /* ignored */
      vetor[3] = 0;
      vetor[4] = 1;
      vetor[5] = 10;
-     vetor[6] = 1;     
-     vetor[7] = 0; // ignored
-     // ------------------------------------
-     // Initializing parents population
-     // ------------------------------------
+     vetor[6] = 1;
+     vetor[7] = 0; /* ignored */
+     /**************************************
+      * Initializing parents population
+      **************************************/
      for (id=0; id < np; id++) {
-         esparents[id].parameters = 
+         esparents[id].parameters =
               (double*) malloc(sizeof(double) * nparameters);
          if (!esparents[id].parameters) {
               ret = NLOPT_OUT_OF_MEMORY;
               goto done;
          }
          for (item=0; item<nparameters; item++) {
-              vetor[1] = lb[item];     
+              vetor[1] = lb[item];
               vetor[2] = ub[item];
               vetor[7]=vetor[7]+1;
               esparents[id].parameters[item] = randcauchy(vetor);
@@ -141,34 +141,34 @@ nlopt_result chevolutionarystrategy(
      }
      memcpy(esparents[0].parameters, x, nparameters * sizeof(double));
 
-     // ------------------------------------
-     // Initializing offsprings population
-     // ------------------------------------
+     /**************************************
+      * Initializing offsprings population
+      **************************************/
      for (id=0; id < no; id++) {
-         esoffsprings[id].parameters = 
+         esoffsprings[id].parameters =
               (double*) malloc(sizeof(double) * nparameters);
          if (!esoffsprings[id].parameters) {
               ret = NLOPT_OUT_OF_MEMORY;
               goto done;
          }
          for (item=0; item<nparameters; item++) {
-              vetor[1] = lb[item];     
+              vetor[1] = lb[item];
               vetor[2] = ub[item];
               vetor[7]=vetor[7]+1;
               esoffsprings[id].parameters[item] = randcauchy(vetor);
          }
      }
-     // ------------------------------------
-     // Parents fitness evaluation  
-     // ------------------------------------
-     for (id=0; id < np; id++) { 
-         esparents[id].fitness = 
+     /**************************************
+      * Parents fitness evaluation
+      **************************************/
+     for (id=0; id < np; id++) {
+         esparents[id].fitness =
               f(nparameters, esparents[id].parameters, NULL, data_f);
          estotal[id].fitness = esparents[id].fitness;
          stop->nevals++;
          if (*minf > esparents[id].fitness) {
               *minf = esparents[id].fitness;
-              memcpy(x, esparents[id].parameters, 
+              memcpy(x, esparents[id].parameters,
                      nparameters * sizeof(double));
          }
          if (nlopt_stop_forced(stop)) ret = NLOPT_FORCED_STOP;
@@ -177,84 +177,84 @@ nlopt_result chevolutionarystrategy(
          else if (nlopt_stop_time(stop)) ret = NLOPT_MAXTIME_REACHED;
          if (ret != NLOPT_SUCCESS) goto done;
      }
-     // ------------------------------------
-     // Main Loop - Generations
-     // ------------------------------------
+     /**************************************
+      * Main Loop - Generations
+      **************************************/
      while (1) {
-         // ------------------------------------
-         // Crossover 
-         // ------------------------------------
+         /**************************************
+          * Crossover
+          **************************************/
          for (id=0; id < no; id++)
          {
               parent1  = nlopt_iurand((int) np);
               parent2  = nlopt_iurand((int) np);
               crosspoint = (unsigned) nlopt_iurand((int) nparameters);
               for (item=0; item < crosspoint; item++)
-                   esoffsprings[id].parameters[item] 
-                        = esparents[parent1].parameters[item]; 
+                   esoffsprings[id].parameters[item]
+                        = esparents[parent1].parameters[item];
               for (item=crosspoint; item < nparameters; item++)
-                   esoffsprings[id].parameters[item] 
-                        = esparents[parent2].parameters[item]; 
+                   esoffsprings[id].parameters[item]
+                        = esparents[parent2].parameters[item];
          }
-         // ------------------------------------
-         // Gaussian Mutation 
-         // ------------------------------------
+         /**************************************
+          * Gaussian Mutation
+          **************************************/
          totalmutation = (int) ((no * nparameters) / 10);
          if (totalmutation < 1) totalmutation = 1;
          for (contmutation=0; contmutation < totalmutation;
               contmutation++) {
               idoffmutation = nlopt_iurand((int) no);
               paramoffmutation = nlopt_iurand((int) nparameters);
-              vetor[1] = lb[paramoffmutation]; 
+              vetor[1] = lb[paramoffmutation];
               vetor[2] = ub[paramoffmutation];
               vetor[7] = vetor[7]+contmutation;
-              esoffsprings[idoffmutation].parameters[paramoffmutation] 
+              esoffsprings[idoffmutation].parameters[paramoffmutation]
                    = randcauchy(vetor);
          }
-         // ------------------------------------
-         // Offsprings fitness evaluation 
-         // ------------------------------------
-         for (id=0; id < no; id++){ 
-              //esoffsprings[id].fitness = (double)fitness(esoffsprings[id].parameters, nparameters,fittype);
+         /**************************************
+          * Offsprings fitness evaluation
+          **************************************/
+         for (id=0; id < no; id++){
+              /*esoffsprings[id].fitness = (double)fitness(esoffsprings[id].parameters, nparameters,fittype);*/
               esoffsprings[id].fitness = f(nparameters, esoffsprings[id].parameters, NULL, data_f);
               estotal[id+np].fitness = esoffsprings[id].fitness;
               stop->nevals++;
               if (*minf > esoffsprings[id].fitness) {
                    *minf = esoffsprings[id].fitness;
-                   memcpy(x, esoffsprings[id].parameters, 
+                   memcpy(x, esoffsprings[id].parameters,
                           nparameters * sizeof(double));
               }
               if (nlopt_stop_forced(stop)) ret = NLOPT_FORCED_STOP;
-              else if (*minf < stop->minf_max) 
+              else if (*minf < stop->minf_max)
                    ret = NLOPT_MINF_MAX_REACHED;
               else if (nlopt_stop_evals(stop)) ret = NLOPT_MAXEVAL_REACHED;
               else if (nlopt_stop_time(stop)) ret = NLOPT_MAXTIME_REACHED;
               if (ret != NLOPT_SUCCESS) goto done;
          }
-         // ------------------------------------
-         // Individual selection
-         // ------------------------------------
-         // all the individuals are copied to one vector to easily identify best solutions             
+         /**************************************
+          * Individual selection
+          **************************************/
+         /* all the individuals are copied to one vector to easily identify best solutions */
          for (i=0; i < np; i++)
               estotal[i] = esparents[i];
          for (i=0; i < no; i++)
               estotal[np+i] = esoffsprings[i];
-         // Sorting
+         /* Sorting */
          nlopt_qsort_r(estotal, no+np, sizeof(Individual), NULL,
                        CompareIndividuals);
-         // copy after sorting:
+         /* copy after sorting: */
          for (i=0; i < no+np; i++) {
               if (i<np)
                    esparents[i] = estotal[i];
               else
                    esoffsprings[i-np] = estotal[i];
          }
-     } // generations loop
-     
+     } /* generations loop */
+
 done:
      for (id=0; id < np; id++) free(esparents[id].parameters);
      for (id=0; id < no; id++) free(esoffsprings[id].parameters);
-     
+
      if (esparents)    free(esparents);
      if (esoffsprings)         free(esoffsprings);
      if (estotal)              free(estotal);
index 2548e91d1e10d65c94da08a6be8b176a347acc93..6cb284d095666a5dd2f8da5a7c550ed0ca98e77a 100644 (file)
@@ -1145,7 +1145,7 @@ static void lsei_(double *c__, double *d__, double *e,
     }
     *mode = 1;
     w[mc1] = 0.0;
-    i__2 = *mg; // BUGFIX for *mc == *n: changed from *mg - *mc, SGJ 2010
+    i__2 = *mg; /* BUGFIX for *mc == *n: changed from *mg - *mc, SGJ 2010 */
     dcopy___(&i__2, &w[mc1], 0, &w[mc1], 1);
     if (*mc == *n) {
        goto L50;
index 1e94f370a35d2ddc843d604cfe801c58ea57eedb..08fa721b32f7d0f3f3fac27db9330a20f8a99562 100644 (file)
@@ -1,19 +1,18 @@
 #ifndef STOGO_CONFIG_H
 #define STOGO_CONFIG_H
 
-// Compiler flags to enable/disable various options in the code
+/* Compiler flags to enable/disable various options in the code */
 
-// To obtain extra information on the global search process:
-//#define GS_DEBUG
+/* To obtain extra information on the global search process: */
+/* #define GS_DEBUG */
 
-// To obtain info on the local search process:
-//#define LS_DEBUG     
+/* To obtain info on the local search process: */
+/* #define LS_DEBUG */
 
-// Initialization strategy in the local search (INI1,INI2 or INI3)
+/* Initialization strategy in the local search (INI1,INI2 or INI3) */
 #define INI2
 
-// Use the more pessimistic strategy for lower bound estimation
-//#define LB2
-
+/* Use the more pessimistic strategy for lower bound estimation */
+/* #define LB2 */
 
 #endif
index 2253f58b62085b4149ce4cb38818124cc0bbe6ae..61596d40faa8e0886dacf09f9a138e85895bee0c 100644 (file)
@@ -1,7 +1,6 @@
 #include <stdio.h>
 #include <math.h>
-
-#include <nlopt.h>
+#include "nlopt.h"
 
 /****************************************************************************/
 /* test function from M. J. Box, "A new method of constrained optimization
@@ -130,11 +129,12 @@ static const double box_lb[5] = {0,1.2,20,9,6.5};
 static const double box_ub[5] = {HUGE_VAL, 2.4, 60, 9.3, 7.0};
 static const double box_xmin[5] = {4.53743, 2.4, 60, 9.3, 7.0};
 
-int main(void) {
+int main(void)
+{
      int cdata[6] = {-1,1,-2,2,-3,3};
      double x[5] = {2.52, 2, 37.5, 9.25, 6.8};
      double minf;
+
      nlopt_minimize_constrained(NLOPT_LN_COBYLA, 5, box, NULL,
                                6, box_constraint, cdata, sizeof(int),
                                box_lb, box_ub, x, &minf,
index 6c89ee1e2f5402fcf3fee23c9bfd830927de371c..74237a2b2b66b14796db9d76619e121cc384c091 100644 (file)
@@ -147,7 +147,7 @@ static double goldsteinprice_f(unsigned n, const double *x, double *grad, void *
      b1 = 2*x0-3*x1; b12 = sqr(b1);
      b2 = 18 - 32*x0 + 12*x0*x0 + 48*x1 - 36*x0*x1 + 27*x1*x1;
      if (grad) {
-         grad[0] = (1 + a12 * a2) * (2 * b1 * 2 * b2 
+         grad[0] = (1 + a12 * a2) * (2 * b1 * 2 * b2
                                      + b12 * (-32 + 24*x0 - 36*x1))
               + (2 * a1 * a2 + a12 * (-14 + 6*x0 + 6*x1)) * (30 + b12 * b2);
          grad[1] = (1 + a12 * a2) * (2 * b1 * (-3) * b2
@@ -180,7 +180,7 @@ static double shekel_f(unsigned n, const double *x, double *grad, void *data)
      if (grad) for (i = 0; i < n; ++i) grad[i] = 0;
      unsigned m = *((unsigned *) data);
      for (i = 0; i < m; ++i) {
-         double fi = 1.0 / (c[i] 
+         double fi = 1.0 / (c[i]
                             + sqr(x[0]-A[i][0])
                             + sqr(x[1]-A[i][1])
                             + sqr(x[2]-A[i][2])
@@ -264,7 +264,7 @@ static double sixhumpcamel_f(unsigned n, const double *x, double *grad, void *da
          grad[0] = 8*x[0] - 2.1*4*pow(x[0],3.) + 2*pow(x[0],5.) + x[1];
          grad[1] = x[0] - 8*x[1] + 16*pow(x[1],3.);
      }
-     RETURN(4*sqr(x[0]) - 2.1 * pow(x[0],4.) + pow(x[0],6.)/3. 
+     RETURN(4*sqr(x[0]) - 2.1 * pow(x[0],4.) + pow(x[0],6.)/3.
            + x[0]*x[1] - 4*sqr(x[1]) + 4*pow(x[1],4.));
 }
 
index f6d7f60fcb02dc05b7b3d4730186d8451cfe32aa..d0b90ac777c146d598879d76d8c2c6a8b78628d9 100644 (file)
@@ -1,12 +1,12 @@
-/* 
+/*
    A C-program for MT19937, with initialization improved 2002/1/26.
    Coded by Takuji Nishimura and Makoto Matsumoto.
 
-   Before using, initialize the state by using init_genrand(seed)  
-   or init_by_array(init_key, key_length).
+   Before using, initialize the state by using nlopt_init_genrand(seed)
+   or nlopt_init_by_array(init_key, key_length).
 
    Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
-   All rights reserved.                          
+   All rights reserved.
 
    Modified 2007 by Steven G. Johnson for use with NLopt (to avoid
    namespace pollution, use uint32_t instead of unsigned long,
@@ -24,8 +24,8 @@
         notice, this list of conditions and the following disclaimer in the
         documentation and/or other materials provided with the distribution.
 
-     3. The names of its contributors may not be used to endorse or promote 
-        products derived from this software without specific prior written 
+     3. The names of its contributors may not be used to endorse or promote
+        products derived from this software without specific prior written
         permission.
 
    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
@@ -63,7 +63,7 @@
 #  endif
 #endif
 
-/* Period parameters */  
+/* Period parameters */
 #define N 624
 #define M 397
 #define MATRIX_A 0x9908b0dfUL   /* constant vector a */
@@ -81,8 +81,8 @@ void nlopt_init_genrand(unsigned long s)
 {
     mt[0]= s & 0xffffffffUL;
     for (mti=1; mti<N; mti++) {
-        mt[mti] = 
-           (1812433253UL * (mt[mti-1] ^ (mt[mti-1] >> 30)) + mti); 
+        mt[mti] =
+           (1812433253UL * (mt[mti-1] ^ (mt[mti-1] >> 30)) + mti);
         /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
         /* In the previous versions, MSBs of the seed affect   */
         /* only MSBs of the array mt[].                        */
@@ -118,7 +118,7 @@ static uint32_t nlopt_genrand_int32(void)
 
         mti = 0;
     }
-  
+
     y = mt[mti++];
 
     /* Tempering */
@@ -158,7 +158,7 @@ static void nlopt_init_by_array(uint32_t init_key[], int key_length)
         if (i>=N) { mt[0] = mt[N-1]; i=1; }
     }
 
-    mt[0] = 0x80000000UL; /* MSB is 1; assuring non-zero initial array */ 
+    mt[0] = 0x80000000UL; /* MSB is 1; assuring non-zero initial array */
 }
 
 /* generates a random number on [0,0x7fffffff]-interval */
@@ -170,32 +170,32 @@ static long nlopt_genrand_int31(void)
 /* generates a random number on [0,1]-real-interval */
 static double nlopt_genrand_real1(void)
 {
-    return nlopt_genrand_int32()*(1.0/4294967295.0); 
-    /* divided by 2^32-1 */ 
+    return nlopt_genrand_int32()*(1.0/4294967295.0);
+    /* divided by 2^32-1 */
 }
 
 /* generates a random number on [0,1)-real-interval */
 static double nlopt_genrand_real2(void)
 {
-    return nlopt_genrand_int32()*(1.0/4294967296.0); 
+    return nlopt_genrand_int32()*(1.0/4294967296.0);
     /* divided by 2^32 */
 }
 
 /* generates a random number on (0,1)-real-interval */
 static double nlopt_genrand_real3(void)
 {
-    return (((double)nlopt_genrand_int32()) + 0.5)*(1.0/4294967296.0); 
+    return (((double)nlopt_genrand_int32()) + 0.5)*(1.0/4294967296.0);
     /* divided by 2^32 */
 }
 
 #endif
 
 /* generates a random number on [0,1) with 53-bit resolution*/
-static double nlopt_genrand_res53(void) 
-{ 
-    uint32_t a=nlopt_genrand_int32()>>5, b=nlopt_genrand_int32()>>6; 
-    return(a*67108864.0+b)*(1.0/9007199254740992.0); 
-} 
+static double nlopt_genrand_res53(void)
+{
+    uint32_t a=nlopt_genrand_int32()>>5, b=nlopt_genrand_int32()>>6;
+    return(a*67108864.0+b)*(1.0/9007199254740992.0);
+}
 /* These real versions are due to Isaku Wada, 2002/01/09 added */
 
 /* generate uniform random number in [a,b) with 53-bit resolution,
@@ -215,8 +215,8 @@ int nlopt_iurand(int n)
    added by SGJ */
 double nlopt_nrand(double mean, double stddev)
 {
-  // Box-Muller algorithm to generate Gaussian from uniform
-  // see Knuth vol II algorithm P, sec. 3.4.1
+  /* Box-Muller algorithm to generate Gaussian from uniform
+     see Knuth vol II algorithm P, sec. 3.4.1 */
   double v1, v2, s;
   do {
     v1 = nlopt_urand(-1, 1);