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: Liam Groener
Subject: Re: lsode parameters slows down solution ?
Date: Tue, 30 Mar 2010 15:35:53 -0700


On Mar 30, 2010, at 12:58 PM, Oz Nahum wrote:


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 paramswith params
matlab0.148400.14677
octave0.037661.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, 

Shouldn't line 32 of batch1.m read:

[c,t]=lsode(g,c1,timerange);

rather than;

[c,t]=lsode(g,c1,timerange,ko);

Is ko really a singularity time?


reply via email to

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