[Rcpp-commits] r2410 - in pkg/RcppDE: . demo

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


Author: edd
Date: 2010-11-06 22:25:24 +0100 (Sat, 06 Nov 2010)
New Revision: 2410

Modified:
   pkg/RcppDE/ChangeLog
   pkg/RcppDE/demo/CompiledBenchmark.R
Log:
no longer need class Fun in CompiledBenchmark
updated ChangeLog


Modified: pkg/RcppDE/ChangeLog
===================================================================
--- pkg/RcppDE/ChangeLog	2010-11-06 20:46:44 UTC (rev 2409)
+++ pkg/RcppDE/ChangeLog	2010-11-06 21:25:24 UTC (rev 2410)
@@ -1,3 +1,15 @@
+2010-11-06  Dirk Eddelbuettel  <edd at debian.org>
+
+	* src/evaluate.h: Converted from evaluate.cpp, now contains abstract
+	base class for evaluation as well as two implementations for the old
+	standard (using a function and environment from R) as well as new one
+	using external pointers passing a function pointer to a function with
+	signature double (*fun)(SEXP); also counts nb of calls inside class
+	* src/devol.cpp: Adapted to use the new framework
+
+	* demo/CompiledBenchmark: New benchmark demo showcasing new approach
+	* compBenchmark: New frontend script
+
 2010-11-04  Dirk Eddelbuettel  <edd at debian.org>
 
 	* src/deoptim.cpp: Pass fn and rho through to devol()

Modified: pkg/RcppDE/demo/CompiledBenchmark.R
===================================================================
--- pkg/RcppDE/demo/CompiledBenchmark.R	2010-11-06 20:46:44 UTC (rev 2409)
+++ pkg/RcppDE/demo/CompiledBenchmark.R	2010-11-06 21:25:24 UTC (rev 2410)
@@ -47,24 +47,17 @@
                 return(sum);
              }
 
-             class Fun {
-             public:
-          	typedef double (*FunctionPointer)(SEXP);
-          	Fun( FunctionPointer ptr_ ) : ptr(ptr_) {};
-          	inline FunctionPointer get() { return ptr ; }
-             private:
-                FunctionPointer ptr ;
-             };
              '
 
     ## now via a class returning external pointer
     src.xptr <- 'std::string fstr = Rcpp::as<std::string>(funname);
+	         typedef double (*funcPtr)(SEXP);
                  if (fstr == "genrose")
-                     return(XPtr<Fun>(new Fun(&genrose)));
+                     return(XPtr<funcPtr>(new funcPtr(&genrose)));
                  else if (fstr == "wild")
-                     return(XPtr<Fun>(new Fun(&wild)));
+                     return(XPtr<funcPtr>(new funcPtr(&wild)));
                  else
-                     return(XPtr<Fun>(new Fun(&rastrigin)));
+                     return(XPtr<funcPtr>(new funcPtr(&rastrigin)));
                  '
     create_xptr <- cxxfunction(signature(funname="character"), body=src.xptr, inc=inc, plugin="Rcpp")
 



More information about the Rcpp-commits mailing list