help-octave
[Top][All Lists]
Advanced

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

Re: octave-speed


From: Paul Thomas
Subject: Re: octave-speed
Date: Sat, 5 Feb 2005 07:54:53 +0100

As Paul Kienzle has said, there is a performance hit of ~10 for loop operations in octave, relative to Matlab 5. This is, in particular due to index operations. Most of this time is absorbed by the function subsref and the difference in timing between octave and Matlab is reflected in their manifestations of this function. There was lengthy correspondence on the lists about this during the first half of last year.

For a variety of reasons, I am coming to think that the difference in performance is due to the exploitation of C++'s virtual functions in the octave classes. I have a TODO on demonstrating that this is the case.

In the mean time, to get back to Rafael's original question:

(i) Performance improvement in octave and Matlab is very often effected by vectorization. See the following, which is a must for users of either product:
http://www.mathworks.com/access/helpdesk/help/techdoc/ref/filter.html

(ii) Your sample programme can be rewritten as:

tic;
Ns=1e5;
m=[1:Ns-1];
T=sqrt(m.*(m+1));
n=zeros(1,Ns);
n(1)=8;
for i=m
 n(i+1)=sqrt(T(i)*n(i));
end
printf("time=%g\n",toc);
printf("n=%g\n",n(1,Ns));

which exposes the core iteration - n(i+1) = function ( weight(i) * n(i) ). If this were linear, you could use the trick with filter, given in (i). As it is, as Paul Kienzle advised you, you will have to write a C++ function to do the job.

Try: http://perso.wanadoo.fr/prthomas/intro.html for a relatively painless how-to-do.

Regards

Paul T



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