Re: [R] Speed up sum of outer products?

2011-03-16 Thread AjayT
Hi Stefan, thats really interesting - I never though of trying to benchmark Linux-64 against OSX (a friend who works on large databases, says OSX performs better than Linux in his work!). Thanks for posting your comparison, and your hints :) i) I guess you have a very fast CPU (Core i7 or so, I

Re: [R] Speed up sum of outer products?

2011-03-15 Thread AjayT
Hi Dennis, sorry for the delayed reply and thanks for the article. I digged into it and found that if you have a GPU, the CUBLAS library beats the BLAS/ATLAS implementation in the Matrix package for 'large' problems. Here's what I mean, its = 2500 dim = 1750 X = matrix(rnorm(its*dim),its, dim)

Re: [R] Speed up sum of outer products?

2011-03-15 Thread Stefan Evert
Hi Ajay, thanks for this comparison, which prodded me to give CUDA another try on my now somewhat aging MacBook Pro. Hi Dennis, sorry for the delayed reply and thanks for the article. I digged into it and found that if you have a GPU, the CUBLAS library beats the BLAS/ATLAS implementation in

[R] Speed up sum of outer products?

2011-03-01 Thread AjayT
Hi, I'm new to R and stats, and I'm trying to speed up the following sum, for (i in 1:n){ C = C + (X[i,] %o% X[i,]) # the sum of outer products - this is very slow according to Rprof() } where X is a data matrix (nrows=1000 X ncols=50), and n=1000. The sum has to be

Re: [R] Speed up sum of outer products?

2011-03-01 Thread Phil Spector
What you're doing is breaking up the calculation of X'X into n steps. I'm not sure what you mean by very slow: X = matrix(rnorm(1000*50),1000,50) n = 1000 system.time({C=matrix(0,50,50);for(i in 1:n)C = C + (X[i,] %o% X[i,])}) user system elapsed 0.096 0.008 0.104 Of course, you

Re: [R] Speed up sum of outer products?

2011-03-01 Thread Doran, Harold
-boun...@r-project.org] On Behalf Of Phil Spector Sent: Tuesday, March 01, 2011 12:31 PM To: AjayT Cc: r-help@r-project.org Subject: Re: [R] Speed up sum of outer products? What you're doing is breaking up the calculation of X'X into n steps. I'm not sure what you mean by very slow: X

Re: [R] Speed up sum of outer products?

2011-03-01 Thread AjayT
Hey thanks alot guys !!! That really speeds things up !!! I didn't know %*% and crossprod, could operate on matrices. I think you've saved me hours in calculation time. Thanks again. system.time({C=matrix(0,50,50);for(i in 1:n)C = C + (X[i,] %o% X[i,])}) user system elapsed 0.450.00

Re: [R] Speed up sum of outer products?

2011-03-01 Thread Dennis Murphy
...and this is where we cue the informative article on least squares calculations in R by Doug Bates: http://cran.r-project.org/doc/Rnews/Rnews_2004-1.pdf HTH, Dennis On Tue, Mar 1, 2011 at 10:52 AM, AjayT ajaytal...@googlemail.com wrote: Hey thanks alot guys !!! That really speeds things up