[Rcpp-devel] Timings for a program

Christian Gunning xian at unm.edu
Sat Jan 7 05:03:42 CET 2017


Why is there a dot in ".*"? Are you perhaps thinking of Matlab?

On Fri, Jan 6, 2017 at 8:53 PM, Shaami <nzshaam at gmail.com> wrote:
> I have deleted two for loops from my code and trying to use vectors in place
> of them.

For reference, there's very little benefit to removing loops in a
compiled language.  What Martyn said is exactly correct - it's your
responsibility to understand the difference between an interpreted
language like R and a compiled language like C++.

Some rules of thumb:
* In both R and C++, avoid unnecessary memory allocations.
* In R, minimize the number of distinct function calls.
  - A single function call: val = sum(1:10)
  - 10 function calls: val = 0; for (ii in 1:10) { val = val + ii}


-- 
A man, a plan, a cat, a ham, a yak, a yam, a hat, a canal – Panama!


More information about the Rcpp-devel mailing list