<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/166824</link>
    <title>MATLAB Central Newsreader - bottleneck calculation</title>
    <description>Feed for thread: bottleneck calculation</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Wed, 02 Apr 2008 14:38:02 -0400</pubDate>
      <title>bottleneck calculation</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/166824#424225</link>
      <author>Dave Brackett</author>
      <description>Hi, I have a calculation which i'm trying to speed up with &lt;br&gt;
no great success. It is quite a bottleneck for an &lt;br&gt;
optimisation run.&lt;br&gt;
&lt;br&gt;
Basically I have lots of 2x2 matrices which all need &lt;br&gt;
multiplying and this is the bottleneck in my code. This is &lt;br&gt;
currently achieved by:&lt;br&gt;
&lt;br&gt;
for g=1:length(r0i)&lt;br&gt;
prodH=prodH*[ai(g),bi(g);ci(g),di(g)];&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
Any improvement in this would significantly speed up the &lt;br&gt;
calculation; is there a better way of doing this? Feel free &lt;br&gt;
to ask me questions if i've not been clear. Thanks for your &lt;br&gt;
help.</description>
    </item>
    <item>
      <pubDate>Wed, 02 Apr 2008 14:44:09 -0400</pubDate>
      <title>Re: bottleneck calculation</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/166824#424227</link>
      <author>Peter Boettcher</author>
      <description>&quot;Dave Brackett&quot; &amp;lt;davebrackett@hotmail.com&amp;gt; writes:&lt;br&gt;
&lt;br&gt;
&amp;gt; Hi, I have a calculation which i'm trying to speed up with &lt;br&gt;
&amp;gt; no great success. It is quite a bottleneck for an &lt;br&gt;
&amp;gt; optimisation run.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Basically I have lots of 2x2 matrices which all need &lt;br&gt;
&amp;gt; multiplying and this is the bottleneck in my code. This is &lt;br&gt;
&amp;gt; currently achieved by:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; for g=1:length(r0i)&lt;br&gt;
&amp;gt; prodH=prodH*[ai(g),bi(g);ci(g),di(g)];&lt;br&gt;
&amp;gt; end&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Any improvement in this would significantly speed up the &lt;br&gt;
&amp;gt; calculation; is there a better way of doing this? Feel free &lt;br&gt;
&amp;gt; to ask me questions if i've not been clear. Thanks for your &lt;br&gt;
&amp;gt; help.&lt;br&gt;
&lt;br&gt;
See the mex file NDFUN at &lt;a href=&quot;http://www.mit.edu/~pwb/matlab/&quot;&gt;http://www.mit.edu/~pwb/matlab/&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
The 'mprod' subfunction will do this, if you assemble your ai/bi/ci/di&lt;br&gt;
into a 3D matrix, one 2x2 matrix per &quot;page&quot;.&lt;br&gt;
&lt;br&gt;
-Peter</description>
    </item>
    <item>
      <pubDate>Wed, 02 Apr 2008 14:57:02 -0400</pubDate>
      <title>Re: bottleneck calculation</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/166824#424229</link>
      <author>Dave Brackett</author>
      <description>Hi, thanks for your reply. Could you elaborate a bit more &lt;br&gt;
on how I can do this? I am a relative novice with Matlab &lt;br&gt;
and do not really understand what you mean. I have had a &lt;br&gt;
look at the ndfun file but cannot find the mprod &lt;br&gt;
subfunction you refer to. thanks a lot.</description>
    </item>
    <item>
      <pubDate>Wed, 02 Apr 2008 15:08:05 -0400</pubDate>
      <title>Re: bottleneck calculation</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/166824#424235</link>
      <author>Peter Boettcher</author>
      <description>&quot;Dave Brackett&quot; &amp;lt;davebrackett@hotmail.com&amp;gt; writes:&lt;br&gt;
&lt;br&gt;
&amp;gt; Hi, thanks for your reply. Could you elaborate a bit more &lt;br&gt;
&amp;gt; on how I can do this? I am a relative novice with Matlab &lt;br&gt;
&amp;gt; and do not really understand what you mean. I have had a &lt;br&gt;
&amp;gt; look at the ndfun file but cannot find the mprod &lt;br&gt;
&amp;gt; subfunction you refer to. thanks a lot.&lt;br&gt;
&lt;br&gt;
help ndfun:&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;'mprod' behaves differently.  It cumulatively multiplies a set&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;of matrices and produces a single 2D output.  The equivalent&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;code is:&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;C = A(:,:,1);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;for i=2:N&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;C = C * A(:,:,i);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;end&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2D inputs return themselves.  Inputs with more than 3&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dimensions collapse the 3rd dimension only.  So with an A of&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;size [2 2 7 3 4],&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;C = ndfun('mprod', A);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;is equivalent to&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;for i=1:3&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;for j=1:4&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;C(:,:,i,j)=ndfun('mprod',M(:,:,:,i,j));&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;end&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;end&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;and C will have size [2 2 3 4].&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
-Peter</description>
    </item>
    <item>
      <pubDate>Wed, 02 Apr 2008 15:19:03 -0400</pubDate>
      <title>Re: bottleneck calculation</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/166824#424240</link>
      <author>Dave Brackett</author>
      <description>sorry i'm still not getting it! :S &lt;br&gt;
&lt;br&gt;
do you think you could show how i can change my code using &lt;br&gt;
the method you suggest please?&lt;br&gt;
thanks for your patience, and sorry for the double post!</description>
    </item>
    <item>
      <pubDate>Wed, 02 Apr 2008 17:15:39 -0400</pubDate>
      <title>Re: bottleneck calculation</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/166824#424272</link>
      <author>Peter Boettcher</author>
      <description>&lt;br&gt;
Please include quotes for context.&lt;br&gt;
&lt;br&gt;
Dave first wrote:&lt;br&gt;
&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Hi, I have a calculation which i'm trying to speed up with &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; no great success. It is quite a bottleneck for an &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; optimisation run.&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Basically I have lots of 2x2 matrices which all need &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; multiplying and this is the bottleneck in my code. This is &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; currently achieved by:&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; for g=1:length(r0i)&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; prodH=prodH*[ai(g),bi(g);ci(g),di(g)];&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; end&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Any improvement in this would significantly speed up the &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; calculation; is there a better way of doing this? Feel free &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; to ask me questions if i've not been clear. Thanks for your &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; help.&lt;br&gt;
&lt;br&gt;
To which I responded:&lt;br&gt;
&lt;br&gt;
&amp;gt; &amp;gt; See the mex file NDFUN at &lt;a href=&quot;http://www.mit.edu/~pwb/matlab/&quot;&gt;http://www.mit.edu/~pwb/matlab/&lt;/a&gt;&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; The 'mprod' subfunction will do this, if you assemble your ai/bi/ci/di&lt;br&gt;
&amp;gt; &amp;gt; into a 3D matrix, one 2x2 matrix per &quot;page&quot;.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&quot;Dave Brackett&quot; &amp;lt;davebrackett@hotmail.com&amp;gt; writes:&lt;br&gt;
&lt;br&gt;
&amp;gt; sorry i'm still not getting it! :S &lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; do you think you could show how i can change my code using &lt;br&gt;
&amp;gt; the method you suggest please?&lt;br&gt;
&amp;gt; thanks for your patience, and sorry for the double post!&lt;br&gt;
&lt;br&gt;
Assume ai/bi/ci/di are all column vectors:&lt;br&gt;
&lt;br&gt;
M = reshape([ai bi ci di].', 2, 2, []);&lt;br&gt;
&lt;br&gt;
% Now M(:,:,1) is the first 2x2 matrix, M(:,:,2) is the second, etc.&lt;br&gt;
&lt;br&gt;
prodH = ndfun('mprod', M);&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
-Peter</description>
    </item>
    <item>
      <pubDate>Thu, 03 Apr 2008 10:15:04 -0400</pubDate>
      <title>Re: bottleneck calculation</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/166824#424441</link>
      <author>Dave Brackett</author>
      <description>Peter Boettcher &amp;lt;boettcher@ll.mit.edu&amp;gt; wrote in message &lt;br&gt;
&amp;lt;muyod8sgouc.fsf@G99-Boettcher.llan.ll.mit.edu&amp;gt;...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Please include quotes for context.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Dave first wrote:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; Hi, I have a calculation which i'm trying to speed &lt;br&gt;
up with &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; no great success. It is quite a bottleneck for an &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; optimisation run.&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; Basically I have lots of 2x2 matrices which all &lt;br&gt;
need &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; multiplying and this is the bottleneck in my code. &lt;br&gt;
This is &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; currently achieved by:&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; for g=1:length(r0i)&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; prodH=prodH*[ai(g),bi(g);ci(g),di(g)];&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; end&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; Any improvement in this would significantly speed &lt;br&gt;
up the &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; calculation; is there a better way of doing this? &lt;br&gt;
Feel free &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; to ask me questions if i've not been clear. Thanks &lt;br&gt;
for your &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; help.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; To which I responded:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; See the mex file NDFUN at &lt;br&gt;
&lt;a href=&quot;http://www.mit.edu/~pwb/matlab/&quot;&gt;http://www.mit.edu/~pwb/matlab/&lt;/a&gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; The 'mprod' subfunction will do this, if you assemble &lt;br&gt;
your ai/bi/ci/di&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; into a 3D matrix, one 2x2 matrix per &quot;page&quot;.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &quot;Dave Brackett&quot; &amp;lt;davebrackett@hotmail.com&amp;gt; writes:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; sorry i'm still not getting it! :S &lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; do you think you could show how i can change my code &lt;br&gt;
using &lt;br&gt;
&amp;gt; &amp;gt; the method you suggest please?&lt;br&gt;
&amp;gt; &amp;gt; thanks for your patience, and sorry for the double post!&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Assume ai/bi/ci/di are all column vectors:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; M = reshape([ai bi ci di].', 2, 2, []);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; % Now M(:,:,1) is the first 2x2 matrix, M(:,:,2) is the &lt;br&gt;
second, etc.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; prodH = ndfun('mprod', M);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; -Peter&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
ah ok, i get it now thanks for bearing with me! Cheers.</description>
    </item>
  </channel>
</rss>

