search for: c_test3

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

Did you mean: c_test
2019 Jun 18
3
Fast way to call an R function from C++?
...de: ``` // [[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); return fun(x); } ``` R code: ``` testFunc<-function(x){ x=x^2 return(x) } evn=new.env() evn$x=x expr=quote(testFunc(evn$x)) testFunc(evn$x) C_test1(testFunc, evn$x) C_test2(expr,evn) C_test3(testFunc,evn$x) ``` For the results, I run each function 1,000,0...
2019 Jun 18
2
Fast way to call an R function from C++?
...> 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 Ucar <iucar at fedoraproject.org> wrote: > > On Tue, 18 Jun 2019 at 19:41, King Jiefei <szwjf08 at gmail.com> wrote: > > > > [...] > > > > It is c...
2019 Jun 19
0
Fast way to call an R function from C++?
...; 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 Ucar <iucar at fedoraproject.org> wrote: > > > > On Tue, 18 Jun 2019 at 19:41, King Jiefei <szwjf08 at gmail.com> wrote: > > >...