help-octave
[Top][All Lists]
Advanced

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

Re: RE: using binary octave 2.9.12


From: Michael Goffioul
Subject: Re: RE: using binary octave 2.9.12
Date: Thu, 21 Jun 2007 14:16:25 +0200

On 6/21/07, asha g <address@hidden> wrote:
> Can you explain what you mean by octave performed
> badly was " for " loops. I ask this as one of my
> programs with plenty of "for" loops written in
> OCtave
> 2.9.12 running on Fedora 5.2 is taking about 3 hours
> to execute. While I did not do the same number of
> iterations in MATLAB, I do think it was quicker.
> Could
> this be an OCtave issue or the computer or both?

The problem with for-loops is that there are interpreted and this
takes quite some time (compared to native for-loops). Matlab has
a built-in just-in-time compiler, which compiles for-loops into
native code at run-time, speeding up execution by a few decades
(in the most optimistic cases). This JIT compiler has some
limitations, but in usual simple cases, it works pretty well.
Octave does not have such JIT compiler and all for-loops are
still interpreted.

So the advise is: vectorize your code as much as possible.
This is also true for Matlab.
As an example: in a project I've been working on, by vectorizing
the code, I could decrease the simulation time in Matlab from
~15min to ~20sec. It of course depends on the application, but
it really pays off.

Michael.


reply via email to

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