R-alpha: loop speed

Ross Ihaka ihaka@stat.auckland.ac.nz
Tue, 11 Nov 1997 09:00:55 +1300 (NZDT)


	From r-devel-owner@stat.math.ethz.ch Tue Nov 11 05:58 NZD 1997
	Date: Mon, 10 Nov 1997 11:56:06 -0500
	From: Paul Gilbert <pgilbert@bank-banque-canada.ca>

	 S> unix.time(res1 <-
	cbind(x*y,x-y,x+y,x/y)[cbind(seq(along=x),match(op,c("*", "-", "+",
	"/")))])
	 [1] 0.40000010 0.04999995 0.00000000 0.00000000 0.00000000

	 R> unix.time(res1 <-
	cbind(x*y,x-y,x+y,x/y)[cbind(seq(along=x),match(op,c("*", "-", "+",
	"/")))])
	 [1] 1.55 0.07 2.00 0.00 0.00

We have received a patch from someone in CS at Berkeley which will
be in 0.60 and should claw back a decent fraction of the difference
between R and S in this comparison.  [ It eliminates our use of the
% operator in the loops for +, -, * / etc. ]

The looping speed was an original design goal for R.  It's good to
know that it hasn't been fixed (yet).

	Ross
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=