fork download
  1. a <- matrix(rnorm(10000000),ncol = 1000);
  2. dim(a)
  3. b <- matrix(rnorm(200000), nrow = 1000);
  4. dim(b)
  5.  
  6. start <- proc.time();
  7. d1 <- a%*%b;
  8. end <- proc.time();
  9. end - start;
  10.  
  11. start <- proc.time();
  12. d2 <- apply(a,1,function(x) x%*%b)
  13. end <- proc.time();
  14. end - start;
  15.  
  16. start <- proc.time();
  17. a1 <- apply(a,1,function(x) list((x)));
  18. d3 <- lapply(a1, function(x) x[[1]]%*%b)
  19. end <- proc.time();
  20. end - start;
Success #stdin #stdout #stderr 4.99s 551424KB
stdin
Standard input is empty
stdout
[1] 10000  1000
[1] 1000  200
   user  system elapsed 
  0.116   0.004   0.134 
   user  system elapsed 
  3.884   0.092   3.981 
stderr
/bin/bash: line 15:  7268 CPU time limit exceeded R --vanilla --quiet --slave --encoding=UTF-8 --file=/home/f8TY50/prog.r > a.out