[Top][All Lists]

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

Re: octave vs. matlab vectorization

From: Judd Storrs
Subject: Re: octave vs. matlab vectorization
Date: Mon, 14 Sep 2009 12:07:33 -0400

Matlab has used a JIT compiler for a while now so the vectorization penalty in loops often isn't nearly as severe as it once was. In the Q&A of a sales presentation a few years ago, I remember it was mentioned that Matlab's JIT compiler is able to recognize and vectorize some loops more efficiently than others. Octave doesn't have JIT.


On Mon, Sep 14, 2009 at 11:33 AM, matt <address@hidden> wrote:
i have used octave exclusively for a number of years and just
recently had to use matlab for teaching purposes.

since i was raised to vectorize loop structures whenever possible, i
thought i would illustrate the the speed-up for the students in the
class by comparing execution time for two codes--code 1 with loops,
and code 2 vectorized.

here is code 1:

for m=1:1000000
       for k=1:10,
               if tmp>50,

here is code 2:

for m=1:1000000

on my laptop, octave (3.0.5) takes 200 secs for the first code and
just 24 secs for the second--i thought i had proved my point.

however, on the department server (admittedly a much faster machine),
matlab ground through the first code in 0.82 secs while the second
code took 4.3 secs.

so, my question: has matlab been optimized for loops? is there some
sort of compilation going on? any insight gratefully received. i have
been writing code in octave for a while now and had assumed it would
almost be a straight port to matlab.



Help-octave mailing list

reply via email to

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