I cannot say if that is true – it would a big surprise for me. In particular if you are a little careful in your C++ calling. However, GPU optimized code etc can do a lot today. Perhaps certain underlying routines in Matlab are optimized for multi-cores/GPUs etc.


What I do know is that you have to be careful how you measure your time. In particular clock() is not good to use in small loops (granularity of 10 ms, if I remember correctly). Either call you your routine 1000 times an measure time outside or use a better timer. I think there is one called something like QueryPerformanceCounter()


However, I am not following the recent trends…so my information might be a little stale…





From: Friedmann Y. [mailto:Y.Friedmann@swansea.ac.uk]
Sent: 16. maj 2012 15:55
To: Ian Scott
Cc: Vxl-Users
Subject: Re: [Vxl-users] vectorise image


so how is it that the vectorised calcs are so much faster in matlab?

-----Original Message-----
From: Ian Scott [mailto:scottim@imorphics.com]
Sent: Wed 16/05/2012 14:15
To: Friedmann Y.
Cc: Vxl-Users
Subject: Re: [Vxl-users] vectorise image

On 16/05/2012 13:49, Friedmann Y. wrote:
> So is it right to assume that when using vectors in MATLAB to do the
> same calculations, their 10 times higher efficiency is due to compiler
> optimization?
> Yasmin

It is long time since I used matlab proper, but at that time it was a
not a compiled language. Octave, the GPL matlab-clone behaves that way
now. Everything was looked up on demand.  Not just indexing, but even
variable name dereferencing. Loop content was evaluated (and possibly
even parsed) afresh every iteration. No compilation - therefore no
opportunity for any optimisation.