help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: simple matrix problem


From: taltman
Subject: Re: simple matrix problem
Date: Wed, 5 Nov 2003 19:17:55 +0000 (UTC)

You are clearly a better expositor of my point that I am. Thanks! :-)

~Tomer

On Nov 5, 2003 at 12:13pm, Dmitri A. Sergatskov wrote:

dmitri >Date: Wed, 05 Nov 2003 12:13:52 -0700
dmitri >From: Dmitri A. Sergatskov <address@hidden>
dmitri >To: address@hidden
dmitri >Cc: help-octave <address@hidden>
dmitri >Subject: Re: simple matrix problem
dmitri >Resent-Date: Wed, 05 Nov 2003 13:13:57 -0600
dmitri >Resent-From: address@hidden
dmitri >
dmitri >address@hidden wrote:
dmitri >> On Nov 5, 2003 at 2:47pm, Geraint Paul Bevan wrote:
dmitri >> 
dmitri >> g.beva >data = [ data ( : , 1 ) , detrend ( data ( : , 2 ) ) ]
dmitri >> 
dmitri >> Not to knit-pick, but an in-place assignment is faster than
dmitri >> re-allocating memory via the [...] operator:
dmitri >> 
dmitri >> ---
dmitri >> octave> version
dmitri >> ans = 2.1.50
dmitri >> octave> A = rand(50,50);
dmitri >> octave> tic;A(:,1) = rand(50,1);toc
dmitri >> ans = 0.0013770
dmitri >> octave> tic;A = [ rand(50,1), A(:,2:50)];toc
dmitri >> ans = 0.0026010
dmitri >> ---
dmitri >> 
dmitri >
dmitri >Though I do not disagree with the conclusion I do not think those number
dmitri >make much sense (tic;toc timing is not that accurate):
dmitri >
dmitri >address@hidden dima]$ octave
dmitri >GNU Octave, version 2.1.50 (i686-pc-linux-gnu).
dmitri >...
dmitri >octave:1> A = rand(50,50);
dmitri >octave:2> tic;A(:,1) = rand(50,1);toc
dmitri >ans = 0.0082260
dmitri >octave:3> tic;A = [ rand(50,1), A(:,2:50)];toc
dmitri >ans = 0.00092900
dmitri >octave:4>
dmitri >
dmitri >
dmitri >> It's almost exactly twice as fast. Sorry Geraint, this is just my
dmitri >> curiosity running amok! :-)
dmitri >> 
dmitri >
dmitri >So [...] almost 10 times as fast! Sure...
dmitri >
dmitri >You need to make a test case that takes few seconds, eg.:
dmitri >octave:5> A = ones(5000,5000);
dmitri >octave:6> tic;A(:,1) = rand(5000,1);toc
dmitri >ans = 0.0099300
dmitri >octave:7> tic;A = [ rand(5000,1), A(:,2:5000)];toc
dmitri >ans = 28.603
dmitri >
dmitri >> ~Tomer
dmitri >> 
dmitri >
dmitri >Regards,
dmitri >
dmitri >Dmitri.
dmitri >
dmitri >
dmitri >
dmitri >-------------------------------------------------------------
dmitri >Octave is freely available under the terms of the GNU GPL.
dmitri >
dmitri >Octave's home on the web:  http://www.octave.org
dmitri >How to fund new projects:  http://www.octave.org/funding.html
dmitri >Subscription information:  http://www.octave.org/archive.html
dmitri >-------------------------------------------------------------
dmitri >
dmitri >



-------------------------------------------------------------
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
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]