Skip to content
Back to formatted view

Raw Message

Message-ID: <14431.42863.62537.411008@gargle.gargle.HOWL>
Date: 1999-12-21T16:14:39Z
From: Martin Maechler
Subject: generating a sequence --- need fast [lt]apply ()
In-Reply-To: <199912211523.PAA14129@toucan.stats.ox.ac.uk>

>>>>> On Tue, 21 Dec 1999 15:23:49 +0000 (GMT), Prof Brian Ripley <ripley at stats.ox.ac.uk> said:

    BDR> OK, so we have now seen essentially three solutions:
    BDR> Me:

    BDR> A <- matrix(1, n-1, n-1)
    BDR> rA <- row(A)
    BDR> rA[rA + col(A) <= n]

    BDR> Jonathan Rougier:

    BDR> rA <- outer(1:n, 1:n, "-")
    BDR> rA[rA>=1]

    BDR> Andy Royle:

    BDR> sequence((n-1):1)

    BDR> Timings for n=500 on a 1994 Sun Sparc 20:

    BDR> 3.29, 4.68 and 23.86 seconds.

    BDR> I deliberately did not use outer, as it calls apply and 
    BDR> is normally quite slow.  row and col are internal operations and fast.

Thanks a lot.

I hope this reminds more people than just me
that we (R users) "desperately" need someone who

rewrites  apply(),lapply(), and tapply()  
to become much faster (as they are with S-plus [34].y, but not 5.[12])...

Anyone working on this ?

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help 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-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._