Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: bottleneck calculation
Date: Thu, 3 Apr 2008 10:15:04 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 63
Message-ID: <ft2an8$nif$1@fred.mathworks.com>
References: <ft05oa$46f$1@fred.mathworks.com> <muyod8sgouc.fsf@G99-Boettcher.llan.ll.mit.edu>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1207217704 24143 172.30.248.37 (3 Apr 2008 10:15:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 3 Apr 2008 10:15:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1338633
Xref: news.mathworks.com comp.soft-sys.matlab:460782



Peter Boettcher <boettcher@ll.mit.edu> wrote in message 
<muyod8sgouc.fsf@G99-Boettcher.llan.ll.mit.edu>...
> 
> Please include quotes for context.
> 
> Dave first wrote:
> 
> > > > Hi, I have a calculation which i'm trying to speed 
up with 
> > > > no great success. It is quite a bottleneck for an 
> > > > optimisation run.
> > > >
> > > > Basically I have lots of 2x2 matrices which all 
need 
> > > > multiplying and this is the bottleneck in my code. 
This is 
> > > > currently achieved by:
> > > >
> > > > for g=1:length(r0i)
> > > > prodH=prodH*[ai(g),bi(g);ci(g),di(g)];
> > > > end
> > > >
> > > > Any improvement in this would significantly speed 
up the 
> > > > calculation; is there a better way of doing this? 
Feel free 
> > > > to ask me questions if i've not been clear. Thanks 
for your 
> > > > help.
> 
> To which I responded:
> 
> > > See the mex file NDFUN at 
http://www.mit.edu/~pwb/matlab/
> > > 
> > > The 'mprod' subfunction will do this, if you assemble 
your ai/bi/ci/di
> > > into a 3D matrix, one 2x2 matrix per "page".
> 
> 
> "Dave Brackett" <davebrackett@hotmail.com> writes:
> 
> > sorry i'm still not getting it! :S 
> >
> > do you think you could show how i can change my code 
using 
> > the method you suggest please?
> > thanks for your patience, and sorry for the double post!
> 
> Assume ai/bi/ci/di are all column vectors:
> 
> M = reshape([ai bi ci di].', 2, 2, []);
> 
> % Now M(:,:,1) is the first 2x2 matrix, M(:,:,2) is the 
second, etc.
> 
> prodH = ndfun('mprod', M);
> 
> 
> -Peter


ah ok, i get it now thanks for bearing with me! Cheers.