[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: A faster sum
From: |
Victor Eijkhout |
Subject: |
Re: A faster sum |
Date: |
Sat, 21 May 2005 15:20:45 -0400 |
On May 21, 2005, at 12:22 PM, Mike Miller wrote:
It is clearer now that "sum" takes twice as long as "ones" and that,
for both, CPU times are porportional to n^2.
Harumpf. Matrix-matrix multiply is only n^3 if both matrices are
square. I'm an idiot.
Damn. I thought the sum would be slower because it was hitting the
cache lines the wrong way. Nope:
octave:27> n=4000; X=rand(n) ; t=cputime(); s=sum(X) ; cputime()-t
ans = 0.80000
octave:28> n=4000; X=rand(n) ; t=cputime(); s=sum(X,2) ; cputime()-t
ans = 3.2900
To show consistency:
octave:29> n=4000; X=rand(n) ; t=cputime(); s=ones(1,n)*X ; cputime()-t
ans = 0.21000
octave:30> n=4000; X=rand(n) ; t=cputime(); s=X*ones(n,1) ; cputime()-t
ans = 0.74000
Are matrices in octave stored by rows or by columns? If it's by columns
(fortran style) these results make sense to me. Otherwise I'm truly
stymied.
Victor.
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------
- A faster sum, Keith Goodman, 2005/05/21
- Re: A faster sum, Victor Eijkhout, 2005/05/21
- Re: A faster sum, Keith Goodman, 2005/05/21
- Re: A faster sum, Mike Miller, 2005/05/21
- Re: A faster sum,
Victor Eijkhout <=
- Re: A faster sum, Keith Goodman, 2005/05/21
- Re: A faster sum, Victor Eijkhout, 2005/05/21
- Re: A faster sum, Mike Miller, 2005/05/21
- Re: A faster sum, John W. Eaton, 2005/05/21