help-octave
[Top][All Lists]
Advanced

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

Re: lsode parameters slows down solution ?


From: Oz Nahum
Subject: Re: lsode parameters slows down solution ?
Date: Tue, 30 Mar 2010 21:58:33 +0200

Hi,
Thanks for your answer.

Basically I already sent the files to the mailing list, but maybe they mailman is configured not to foreward the attachments.

So here it is, as zip file, again.

I hope maybe this time they rich directly to you, and to the mailing list to.

I've also attaced the matlab scripts.

Thanks,
Oz

On Tue, Mar 30, 2010 at 8:52 PM, Jaroslav Hajek <address@hidden> wrote:


On Sun, Mar 28, 2010 at 1:22 PM, Oz Nahum <address@hidden> wrote:
Hi Everyone,

I'm trying to compare Octave to Matlab speed of ODE solution.

when I solve the ODE with passing parameter to the function octave slows down significantly, wheres
without parameters, octave is faster then Matlab.

I'm trying to understand if I'm doing something wrong. Could it be that there is a better way to pass parameters to the functions ?

here are the function definitions in octave and matlab, note that matlab has to unpack much more variables, and still it's faster.

Matlab:
function f=batch1_rate(t,c1,ko,ks,Ys,Yo,Kdec,umax,kb)

or without parameters:
function f=batch1_rate(t,c1)
 
Octave:
function f=batch1_rate(c1,t,ko)

or without parameters:
function f=batch1_rate(c1,t)

the solving calls are the following in matlab:
 
timerange=[0:3600:43*86400];
tic()
[t,c]=ode15s(@batch1_rate_matlab,timerange,c1,[],ko,ks,Ys,Yo,Kdec,umax,kb);
toc()

without params:
tic()
timerange=[0:3600:43*86400];
[t,c]=ode15s(@batch1b_rate_matlab,timerange,c1,[]);
toc()

or with Octave:
g = @(x,t) batch1_rate(x, t, ko);
tic()
timerange=[0: 3600: 43*86400];
%[t,c]=ode15s(@batch1_rate,timerange,c1,[],ko,ks,Ys,Yo,Kdec,umax,kb);
[c,t]=lsode(g,c1,timerange,ko);
toc()

without params:
tic()
timerange=[0: 3600: 43*86400];
%[t,c]=ode15s(@batch1_rate,timerange,c1,[],ko,ks,Ys,Yo,Kdec,umax,kb);
[c,t]=lsode("batch1b_rate",c1,timerange);
toc()


The results of the CPU times on my computer (1GB RAM and 1.6 MHZ Intel Pentium) are in seconds:

no params with params
matlab 0.14840 0.14677
octave 0.03766 1.64757

So, Octave is MUCH faster without parameters, but really falls down when I pass parameters. Would be great to know why, and how I can improve it.

I also attached here the code of my files, in case someone wants to have a look.

Thanks in advance,


It would help if you posted a  complete script to reproduce the issue. In the above, c1 and ko are missing.



--
RNDr. Jaroslav Hajek, PhD
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz



--
Oz Nahum
Graduate Student
Zentrum für Angewandte Geologie
Universität Tübingen

---

Imagine there's no countries
it isn't hard to do
Nothing to kill or die for
And no religion too
Imagine all the people
Living life in peace



reply via email to

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