Skip to content

performance of apply

2 messages · Luke Tierney, Peter Dalgaard

#
Douglas Bates wrote:
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.

luke
#
Luke Tierney <luke@stat.umn.edu> writes:
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.