Path: news.mathworks.com!newsfeed-00.mathworks.com!newscon02.news.prodigy.net!prodigy.net!nx01.iad01.newshosting.com!newshosting.com!69.28.186.77.MISMATCH!hwmpeer03.lga!news.highwinds-media.com!llnews!53ab2750!not-for-mail
From: Peter Boettcher <boettcher@ll.mit.edu>
Newsgroups: comp.soft-sys.matlab
Subject: Re: bottleneck calculation
References: <ft05oa$46f$1@fred.mathworks.com>
Message-ID: <muyod8sgouc.fsf@G99-Boettcher.llan.ll.mit.edu>
Organization: MIT Lincoln Laboratory
User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/23.0.0 (gnu/linux)
Cancel-Lock: sha1:4VlqLYlX2R8JQ8NSlDE8kZDlqVA=
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Lines: 48
Date: Wed, 02 Apr 2008 13:15:39 -0400
NNTP-Posting-Host: 155.34.163.114
X-Complaints-To: news@ll.mit.edu
X-Trace: llnews 1207155945 155.34.163.114 (Wed, 02 Apr 2008 13:05:45 EDT)
NNTP-Posting-Date: Wed, 02 Apr 2008 13:05:45 EDT
Xref: news.mathworks.com comp.soft-sys.matlab:460612




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