Path: news.mathworks.com!not-for-mail
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$1@newscl01ah.mathworks.com>
References: <jor8fr$a4n$1@newscl01ah.mathworks.com> <jorekp$86u$1@newscl01ah.mathworks.com> <jori3c$nm3$1@newscl01ah.mathworks.com> <jorjpq$266$1@newscl01ah.mathworks.com> <joseij$t1m$1@newscl01ah.mathworks.com> <josf5b$1v8$1@newscl01ah.mathworks.com> <joslg3$p6u$1@newscl01ah.mathworks.com> <jotljb$42u$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-00-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1337089926 11328 172.30.248.45 (15 May 2012 13:52:06 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 15 May 2012 13:52:06 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1440443
Xref: news.mathworks.com comp.soft-sys.matlab:767917

"Matt J" wrote in message <jotljb$42u$1@newscl01ah.mathworks.com>...
> "Roger Stafford" wrote in message <joslg3$p6u$1@newscl01ah.mathworks.com>...
> >
> >   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.