Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: vectorize finding upper envelope of vector
Date: Fri, 14 Mar 2008 17:29:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 28
Message-ID: <frecku$39$1@fred.mathworks.com>
References: <frbrrt$n43$1@fred.mathworks.com> <frcc2m$h6i$1@fred.mathworks.com> <fre6ll$p28$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1205515742 105 172.30.248.35 (14 Mar 2008 17:29:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 14 Mar 2008 17:29:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:457288



"Jos " <DELjos@jasenDEL.nl> wrote in message <fre6ll$p28
$1@fred.mathworks.com>...
> A one-line vectorized cumulative maximum function:
> 
>   a = [2 3 4 2 7 5 8] % row vector
>   CMA = max(triu(toeplitz(a)))
> 
>   % -> CMA =  2  3  4  4  7   7   8
> 
> which, however(!), will create an intermediate (numel(A).^2)
> matrix that may cause memory troubles for long vectors.
> 
> SLIDEFUN on the File Exchange may be of interest to you as
> well (shameful self promotion ...).
> 
> hth
> Jos
-------
  Thanks Jos.  I stand corrected.  I should have done more thorough searching 
before making my claim.

  However, I do worry about its execution speed since it is an order n^2 
algorithm rather than the order n of the OP's for-loop method.  On my 
ancient matlab version it runs about three times as long as the for-loop, even 
for a 32-element vector.

Roger Stafford