Tuesday, February 07, 2017

ode45 on octave

Trying the gnlse numerical solution for SCG from the Dudley book using GNU Octave - the Matlab clone. The Octave "port" needed some modifications.

  1. The report function doesn't work properly, so probably can be omitted. Instead of outputting a percentage for every step, it outputs at the end. Maybe it is a difference in the flags returned by the ode45 function.
  2. Had to add 'InitialStep', 0.001 to the odeset parameters - or else the error becomes too large and ode45 exits.
  3. Instead of Z which was linspace(0, flength, nsaves), gave [0, flength] as the parameter to ode45 - or else the ode45 in Octave ignores RelTol and AbsTol. 
  4. Then, spline to create a linearly spaced array of our desired spacing.
So, instead of 
[Z, AW]=ode45( @rhs, Z, ifft(A), options .... etc
called it as
[Zoctave, AWoctave]=ode45( @rhs, [0, flength], ifft(A), options .... etc
and then
Z     = linspace(0,flength, nsaves);
AW = spline(Zoctave, AWoctave,Z);


Then, running time - 

Octave modified ugnlse = 166 sec on i7
Matlab  = 281 sec on Athlon

Since python code got 9x speedup on the i7, I guess the Octave ode45 + spline is slower than the Matlab ode45. Still, running on the i7 gets the advantage of more RAM. Doesn't give the out of memory error so easily. 

No comments:

Post a Comment