The 'distribution of determinant' example as a demonstration of how to use inline and Rcpp for a simple function.
#!/usr/bin/r
foo <- '
for (
int a = 0; a < 9; a++)
for (
int b = 0; b < 9; b++)
for (
int c = 0; c < 9; c++)
for (
int d = 0; d < 9; d++)
vec(i++) = a*b - c*d;
'
funx <- cxxfunction(signature(), foo, plugin = "Rcpp" )
dd.inline.rcpp <- function() {
res <- funx()
tabulate(res)
}
print(
mean(replicate(100,system.time(dd.inline.rcpp())[
"elapsed"]),trim=0.05))