search for: c_test1

Displaying 3 results from an estimated 3 matches for "c_test1".

Did you mean: c7test1
2019 Jun 18
3
Fast way to call an R function from C++?
...n from C++ in a package. I know there are two functions (`R_forceAndCall` and `Rf_eval`) that can do the "call" part, but both are slow compared to calling the same function in R. I also try to use Rcpp and it is the worse one. Here is my test code: C++ code: ``` // [[Rcpp::export]] SEXP C_test1(SEXP f, SEXP x) { SEXP call =PROTECT(Rf_lang2(f, x)); SEXP val = R_forceAndCall(call, 1, R_GlobalEnv); UNPROTECT(1); return val; } // [[Rcpp::export]] SEXP C_test2(SEXP expr, SEXP env) { SEXP val = Rf_eval(expr, env); return val; } // [[Rcpp::export]] SEXP C_test3(SEXP f,SEXP x) { Function fun(f)...
2019 Jun 18
2
Fast way to call an R function from C++?
For reference, your benchmark using UNWIND_PROTECT: > system.time(test(testFunc, evn$x)) user system elapsed 0.331 0.000 0.331 > system.time(test(C_test1, testFunc, evn$x)) user system elapsed 2.029 0.000 2.036 > system.time(test(C_test2, expr, evn)) user system elapsed 2.307 0.000 2.313 > system.time(test(C_test3, testFunc, evn$x)) user system elapsed 2.131 0.000 2.138 I?aki On Tue, 18 Jun 2019 at 20:35, I?aki...
2019 Jun 19
0
Fast way to call an R function from C++?
...ence! Best, Jiefei On Tue, Jun 18, 2019 at 2:39 PM I?aki Ucar <iucar at fedoraproject.org> wrote: > For reference, your benchmark using UNWIND_PROTECT: > > > system.time(test(testFunc, evn$x)) > user system elapsed > 0.331 0.000 0.331 > > system.time(test(C_test1, testFunc, evn$x)) > user system elapsed > 2.029 0.000 2.036 > > system.time(test(C_test2, expr, evn)) > user system elapsed > 2.307 0.000 2.313 > > system.time(test(C_test3, testFunc, evn$x)) > user system elapsed > 2.131 0.000 2.138 >...