help-octave
[Top][All Lists]
Advanced

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

Re: How much time to count from 1 to 1e7?


From: Etienne Grossmann
Subject: Re: How much time to count from 1 to 1e7?
Date: Thu, 09 Aug 2001 08:39:55 +0100
User-agent: WEMI/1.13.7 (Shimada) FLIM/1.13.2 (Kasanui) Emacs/20.7 (i386-debian-linux-gnu) (with unibyte mode)


From: Denis Pelletier <address@hidden>

#  computing the inverse of a matrix). But the "while" command of Octave
#  seems pretty slow compare to the one in Gauss. With Octave the following
#  program takes 146 seconds:
#  i=1;
#  tic;
#  while (i <= 1e7)
#    ++i;
#  endwhile
#  toc

#  The equivalent program in Gauss takes 12 seconds.

#  Am I doing something wrong? Is there a way to speed up Octave? An
#  optimization flag when compiling Octave?

  I think loops are just slow w/ octave (same for matlab). The idea is
to program without loops, replacing them with array operations. It's a
trick one catches.

#  Since my typical program use the "while" command (maximizing a
#  log-likelihod with the BFGS algorithm) it run a lot slower in Octave.

  Depending on the function you are optimizing (slow or fast), the
time will be spent more on function evaluations or optimizing
algorithm overhead.

   The style used for writing your optimization routine will probably
influence the speed. An optim. routine basically should have a single
(or two) 'while ! exit_condition, ...'  statement.

  For optimizing functions that evaluate quickly, the overhead will
always represent most of the computation time. If time is very
important for youm, you may want to code a function in C++ directly.

  Cheers,


  Etienne


ps : Note that this is faster than while (P2, 350MHz)(won't do for
    unkown number of loops, though)

octave:122> tic; for i = 1:1e7, end; toc
ans = 43.791



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