[Rcpp-commits] r2402 - pkg/RcppDE/src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Nov 6 21:14:22 CET 2010


Author: edd
Date: 2010-11-06 21:14:16 +0100 (Sat, 06 Nov 2010)
New Revision: 2402

Modified:
   pkg/RcppDE/src/evaluate.cpp
Log:
deactivated evaluate()

Modified: pkg/RcppDE/src/evaluate.cpp
===================================================================
--- pkg/RcppDE/src/evaluate.cpp	2010-11-06 15:22:27 UTC (rev 2401)
+++ pkg/RcppDE/src/evaluate.cpp	2010-11-06 20:14:16 UTC (rev 2402)
@@ -10,6 +10,7 @@
 
 // Slighly accelerated version of evaluate to evaluate function fcall with parameters param in environment env
 // Uses externally allocated par() vector into which param are copied
+#if 0
 double evaluate(long &l_nfeval, const double *param, SEXP par, SEXP fcall, SEXP env) {
     memcpy(REAL(par), param, Rf_nrows(par) * sizeof(double));      // -- faster: direct access _assuming_ numeric vector
     SEXP fn = ::Rf_lang2(fcall, par); 				   // this could be done with Rcpp 
@@ -20,4 +21,13 @@
     l_nfeval++;  						   // increment function evaluation count 
     return(f_result); 
 }
+#endif
+double evaluate(SEXP par, SEXP fcall, SEXP env) {
+    SEXP fn = ::Rf_lang2(fcall, par); 				   // this could be done with Rcpp 
+    SEXP sexp_fvec = ::Rf_eval(fn, env);		           // but is still a lot slower right now
+    double f_result = REAL(sexp_fvec)[0];
+    if (ISNAN(f_result)) 
+	::Rf_error("NaN value of objective function! \nPerhaps adjust the bounds.");
+    return(f_result); 
+}
 #endif 



More information about the Rcpp-commits mailing list