> On 4 Nov 2016, at 19:27, Berend Hasselman <b...@xs4all.nl> wrote:
> 
>> 
>> On 4 Nov 2016, at 16:41, Jeff Newmiller <jdnew...@dcn.davis.ca.us> wrote:
>> 
>> Sara wins on memory use.
>> 
>> Rui wins on speed.
>> 
>> Bert wins on clarity.
>> 
>> library(microbenchmark)
>> 
>> N <- 1000
>> x <- matrix( runif( N*N ), ncol=N )
>> y <- seq.int( N )
>> 
>> microbenchmark( { t( y * t(x) ) }
>>             , { x %*% diag( y ) }
>>             , { sweep( x, 2, y, `*` ) }
>>             )
>> Unit: milliseconds
>>                       expr       min        lq    median        uq      max 
>> neval
>>        {     t(y * t(x)) }  6.659562  7.475414  7.871341  8.182623 47.01105 
>> 100
>>      {     x %*% diag(y) }  9.859292 11.014021 11.281334 11.733825 48.79463 
>> 100
>> {     sweep(x, 2, y, `*`) } 16.535938 17.682175 18.283572 18.712342 55.47159 
>> 100
> 
> 
> I get different results with R3.2.2 on Mac OS X (using reference BLAS).
> 

Correction: I meant R3.3.2

Berend
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to