|
Rcpp Version 0.9.10
|
00001 #!/usr/bin/r 00002 00003 suppressMessages(library(Rcpp)) 00004 suppressMessages(library(inline)) 00005 00006 foo <- ' 00007 IntegerVector vec(10000); // vec parameter viewed as vector of ints. 00008 int i = 0; 00009 for (int a = 0; a < 9; a++) 00010 for (int b = 0; b < 9; b++) 00011 for (int c = 0; c < 9; c++) 00012 for (int d = 0; d < 9; d++) 00013 vec(i++) = a*b - c*d; 00014 00015 return vec; 00016 ' 00017 00018 funx <- cxxfunction(signature(), foo, plugin = "Rcpp" ) 00019 00020 dd.inline.rcpp <- function() { 00021 res <- funx() 00022 tabulate(res) 00023 } 00024 00025 print(mean(replicate(100,system.time(dd.inline.rcpp())["elapsed"]),trim=0.05)) 00026 00027