From p.dalgaard@biostat.ku.dk  Fri May 29 17:04:30 1998
From: p.dalgaard@biostat.ku.dk (Peter Dalgaard BSA)
Date: 29 May 1998 18:04:30 +0200
Subject: performance of apply
In-Reply-To: Luke Tierney's message of Fri, 29 May 1998 10:45:53 -0500 (CDT)
References: <9805291545.AA08154@nokomis.stat.umn.edu>
Message-ID: <x2af81t65t.fsf@blueberry.kubism.ku.dk>

Luke Tierney <luke@stat.umn.edu> writes:


> > > That is, the computation of the sums of the rows of a 10000x10 matrix
> > > with apply takes about 100sec on average, where a simple for-loop does
> > > the same job in about 2sec.
> 
> It looks like M1 and M3 are O(n^2) but M1 is O(n). I see where that
> comes from in M3, but it surprises me for M1.

Oh, dear. Looking at apply, we have right in the middle of it:

            for (i in 1:d2) ans[[i]] <- FUN(array(newX[, i], d.call, 
                    dn.call), ...)

Assignment to the tail of a very long list... 

I think I'm beginning to understand why Ross keeps talking about
generic vectors. Either that or we need to add some low-level list
primitives to the language. 

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


performance of apply
Peter Dalgaard BSA