Rcpp examples from http://adv-r.had.co.nz/Rcpp.html