Skip to content
Prev 170726 / 398506 Next

Alternate to for-loop

Stefan Evert wrote:
indeed, thanks;  i've already posted a correction, and as you say, it
doesn't make much difference for these particular benchmark values.
indeed, and pat seems correct in blaming for loops for the inefficiency
of replicate in cases where log10(n/m) > 2.
depends how and where you use them.  in the problem discussed here, they
do slow down the code for some class of inputs and do not speedup for
the others, compared to the array version of pat.
hmm, would you be saying that r's vectorised performance is overhyped? 
or is it just that non-vectorised code in r is slow?
sure;  it's even more pronounced when n = 10^6 and m=10.

vQ