Skip to content
Back to formatted view

Raw Message

Message-ID: <CADNH-Pu+hWtxocfNJuEC+KhfYrUseCtQaBDx9EpCr9WXkCrJkw@mail.gmail.com>
Date: 2017-01-07T04:03:42Z
From: Christian Gunning
Subject: [Rcpp-devel] Timings for a program

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!