[R] uniroot speed and vectorization?

From: ivo welch <ivowel_at_gmail.com>
Date: Sat, 02 Apr 2011 08:24:07 -0400


curiosity---given that vector operations are so much faster than scalar operations, would it make sense to make uniroot vectorized? if I read the uniroot docs correctly, uniroot() calls an external C routine which seems to be a scalar function. that must be slow. I am thinking a vectorized version would be useful for an example such as

  of <- function(x,a) ( log(x)+x+a )
  uniroot( of, c( 1e-7, 100 ), a=rnorm(1000000) )

I would have timed this, but I would have used a 'for' loop, which is probably not the "R way" of doing this. has someone already written a package that does this?

/iaw



Ivo Welch (ivo.welch_at_brown.edu, ivo.welch_at_gmail.com)

R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sat 02 Apr 2011 - 12:30:04 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 02 Apr 2011 - 22:40:26 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive