[Deoptim-commits] r107 - in pkg/DEoptim: R src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Jul 1 18:21:33 CEST 2012


Author: bodanker
Date: 2012-07-01 18:21:33 +0200 (Sun, 01 Jul 2012)
New Revision: 107

Modified:
   pkg/DEoptim/R/DEoptim.R
   pkg/DEoptim/src/evaluate.c
Log:
- Remove conversion to double in fnMapC
- Remove code duplication in popEvaluate


Modified: pkg/DEoptim/R/DEoptim.R
===================================================================
--- pkg/DEoptim/R/DEoptim.R	2012-07-01 13:40:30 UTC (rev 106)
+++ pkg/DEoptim/R/DEoptim.R	2012-07-01 16:21:33 UTC (rev 107)
@@ -235,8 +235,6 @@
         warning("Could not remove ",sum(dups)," duplicates from the mapped ",
                 "population in 5 tries. Evaluating population with duplicates.",
                 call.=FALSE, immediate.=TRUE)
-      ## memcpy fails if mappedPop isn't double (need TYPEOF switch in C?)
-      storage.mode(mappedPop) <- "double"
       mappedPop
     }
   }

Modified: pkg/DEoptim/src/evaluate.c
===================================================================
--- pkg/DEoptim/src/evaluate.c	2012-07-01 13:40:30 UTC (rev 106)
+++ pkg/DEoptim/src/evaluate.c	2012-07-01 16:21:33 UTC (rev 107)
@@ -37,23 +37,18 @@
    switch(TYPEOF(sexp_fvec)) {
      case INTSXP:
        PROTECT(sexp_fvec = coerceVector(sexp_fvec, REALSXP)); P++;
-       d_result = REAL(sexp_fvec);
-       for(int i=0; i < nr; i++) {
-         if(ISNAN(d_result[i]))
-           error("NaN value of objective function! \nPerhaps adjust the bounds.");
-       }
        break;
      case REALSXP:
-       d_result = REAL(sexp_fvec);
-       for(int i=0; i < nr; i++) {
-         if(ISNAN(d_result[i]))
-           error("NaN value of objective function! \nPerhaps adjust the bounds.");
-       }
        break;
      default:
        error("unsupported objective function return value");
        break;
    }
+   d_result = REAL(sexp_fvec);
+   for(int i=0; i < nr; i++) {
+     if(ISNAN(d_result[i]))
+       error("NaN value of objective function! \nPerhaps adjust the bounds.");
+   }
    UNPROTECT(P);
    return(sexp_fvec);
 }



More information about the Deoptim-commits mailing list