Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Summing consecutively signed integers
Date: Mon, 26 Nov 2012 22:42:19 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 6
Message-ID: <k90r8b$ddn$1@newscl01ah.mathworks.com>
References: <k90dmu$oq9$1@newscl01ah.mathworks.com> <k90kti$l3c$1@newscl01ah.mathworks.com> <k90lid$ncb$1@newscl01ah.mathworks.com> <k90njp$uir$1@speranza.aioe.org> <k90p6c$64m$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 1353969739 13751 172.30.248.45 (26 Nov 2012 22:42:19 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 26 Nov 2012 22:42:19 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:783542

"K" wrote in message <k90p6c$64m$1@newscl01ah.mathworks.com>...
> Darn, I was afraid of that.
- - - - - - - - -
  I agree with dpb.  I see a vectorized method that would give you the answer you are asking for, but I don't want to give it to you, because it is very awkward and inferior to an obvious and simple for-loop method.  You should realize that for-loop and while-loop code constructs provide a very powerful means of algorithm computation and there is nothing disgraceful about using them.  Buried within the underlying C compiler code of nearly all Mathworks "elegant" functions are the equivalent of many for-loops, and I don't think their programmers are in the least bit reluctant about using them.  The thing you should always strive for is an efficient algorithm in terms of the operations a computer must perform, never mind whether it uses for-loops or not.

Roger Stafford