From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: 30% faster for-loop when changing loop variable from default(double) to int
Date: Tue, 15 May 2012 13:52:06 +0000 (UTC)
Organization: Xoran Technologies
Lines: 14
Message-ID: <jotn26$b20$>
References: <jor8fr$a4n$> <jorekp$86u$> <jori3c$nm3$> <jorjpq$266$> <joseij$t1m$> <josf5b$1v8$> <joslg3$p6u$> <jotljb$42u$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1337089926 11328 (15 May 2012 13:52:06 GMT)
NNTP-Posting-Date: Tue, 15 May 2012 13:52:06 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1440443
Xref: comp.soft-sys.matlab:767917

"Matt J" wrote in message <jotljb$42u$>...
> "Roger Stafford" wrote in message <joslg3$p6u$>...
> >
> >   Since the type of the argument N and therefore i is changed from double to int32 as Hao has indicated in the last two articles, the difference in speeds seems quite plausible to me.  It ought to be faster to increment a counter by 1 in int32 format than a 64-bit floating point format number.
> ===============
> The loop counter in Hao's examples is not in int32 type, though.
> The pre-casting of i to int32 is negated once the for-loop begins: 

Never mind, I didn't notice that N was also pre-cast.

Still, when I run both versions, I don't see a significant speed difference either.