|
From: | matt |
Subject: | Re: octave vs. matlab vectorization |
Date: | Tue, 15 Sep 2009 13:01:05 +0100 |
thanks for the insight on compiler issues.the matlab JIT compiler is doing something clever in the simple- minded codes i was experimenting with but i realise now that a lot of the problem is the overhead in allocating and defining arrays.
i had a vector q of length 10. in the loops code, it was fast to check through it elementwise; in the (semi) vectorized code, time was being spent setting up q and also tmp and (tmp>50), both length 10.
replacing 10 by 1000 puts the two codes on a par as now the overhead to set up the vectors is relatively small.
in octave, of course, the vectorized version wins by miles.
[Prev in Thread] | Current Thread | [Next in Thread] |