[R] R vs Matlab {R in Industry}"
Martin Maechler
maechler at stat.math.ethz.ch
Fri Feb 9 09:46:39 CET 2007
>>>>> "Ravi" == Ravi Varadhan <rvaradhan at jhmi.edu>
>>>>> on Thu, 8 Feb 2007 14:39:41 -0500 writes:
Ravi> Here is a function to create a Toeplitz matrix of any size, and an example
Ravi> of a 220 x 220 toeplitz matrix, which was created in almost no time:
Thanks Ravi,
but note two things
- ?toeplitz tells you that R already has a fast (R-code-only)
toeplitz() function
- The point of that benchmark is not to measure how fast you can
build a Toeplitz matrix but simply to exercise a double
(actually triple) for loop.
{and the benchmark R script says so as comment in the code}
BTW {not to Ravi, but on the subject}:
1) When comparing this (the for-loop benchmark) --- with
Matlab I would want to be sure that Matlab is not simply
using an internal short cut since the benchmark is maybe
too simplistic:
for(i in 1:N) for(j in 1:N) b[i,j] <- abs(i - j)
{and it maybe interesting to see if R's experimental byte
compiler would speed that up}
2) The above is very fast (IMO) and I cannot say why this could
be too slow in a realistic situation.
3) The tables I've seen said that Matlab was about a factor of 2
faster for the above loop benchmark. That's scarcely a
reason for downgrading (from R to Matlab).
Martin
More information about the R-help
mailing list