<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/169157</link>
    <title>MATLAB Central Newsreader - faster way to multiply 100,000 times (in ODE)</title>
    <description>Feed for thread: faster way to multiply 100,000 times (in ODE)</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2008 by The 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>The MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Tue, 13 May 2008 08:13:03 -0400</pubDate>
      <title>faster way to multiply 100,000 times (in ODE)</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/169157#431732</link>
      <author>Chris </author>
      <description>One step is bogging down an ode file that simulates network &lt;br&gt;
activity.  I've got to multiply an initial conditions &lt;br&gt;
vector of length 1000 by the 1000x1000 connectivity &lt;br&gt;
matrix.  The 1Kx1K matrix has 10% ones and is declared &lt;br&gt;
sparse.  Essentially I'm just running IC*Connectivity.&lt;br&gt;
&lt;br&gt;
This multiplication needs to occur once every iteration of &lt;br&gt;
solving the ODE's.  It's such a basic operation, but I'm &lt;br&gt;
wondering if there is anything that may speed it up.   90% &lt;br&gt;
of the ODE run time is spent doing this multiplication (an &lt;br&gt;
it's not a simple set of ODE's either).&lt;br&gt;
&lt;br&gt;
Thanks!&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Tue, 13 May 2008 09:58:03 -0400</pubDate>
      <title>Re: faster way to multiply 100,000 times (in ODE)</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/169157#431750</link>
      <author>David </author>
      <description>"Chris " &amp;lt;cag44@removethispitt.edu&amp;gt; wrote in message &lt;br&gt;
&amp;lt;g0biif$g5p$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; One step is bogging down an ode file that simulates &lt;br&gt;
network &lt;br&gt;
&amp;gt; activity.  I've got to multiply an initial conditions &lt;br&gt;
&amp;gt; vector of length 1000 by the 1000x1000 connectivity &lt;br&gt;
&amp;gt; matrix.  The 1Kx1K matrix has 10% ones and is declared &lt;br&gt;
&amp;gt; sparse.  Essentially I'm just running IC*Connectivity.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; This multiplication needs to occur once every iteration &lt;br&gt;
of &lt;br&gt;
&amp;gt; solving the ODE's.  It's such a basic operation, but I'm &lt;br&gt;
&amp;gt; wondering if there is anything that may speed it up.   &lt;br&gt;
90% &lt;br&gt;
&amp;gt; of the ODE run time is spent doing this multiplication &lt;br&gt;
(an &lt;br&gt;
&amp;gt; it's not a simple set of ODE's either).&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks!&lt;br&gt;
&lt;br&gt;
does it really have to be done every step?  i &lt;br&gt;
would 'assume' the ic's don't change, does the &lt;br&gt;
connectivity matrix change each time step?  if not then &lt;br&gt;
just do the multiplication once outside the loop.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Tue, 13 May 2008 13:21:02 -0400</pubDate>
      <title>Re: faster way to multiply 100,000 times (in ODE)</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/169157#431790</link>
      <author>Tim Davis</author>
      <description>"Chris " &amp;lt;cag44@removethispitt.edu&amp;gt; wrote in message&lt;br&gt;
&amp;lt;g0biif$g5p$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; One step is bogging down an ode file that simulates network &lt;br&gt;
&amp;gt; activity.  I've got to multiply an initial conditions &lt;br&gt;
&amp;gt; vector of length 1000 by the 1000x1000 connectivity &lt;br&gt;
&amp;gt; matrix.  The 1Kx1K matrix has 10% ones and is declared &lt;br&gt;
&amp;gt; sparse.  Essentially I'm just running IC*Connectivity.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; This multiplication needs to occur once every iteration of &lt;br&gt;
&amp;gt; solving the ODE's.  It's such a basic operation, but I'm &lt;br&gt;
&amp;gt; wondering if there is anything that may speed it up.   90% &lt;br&gt;
&amp;gt; of the ODE run time is spent doing this multiplication (an &lt;br&gt;
&amp;gt; it's not a simple set of ODE's either).&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks!&lt;br&gt;
&lt;br&gt;
If you don't have MATLAB 7.6, upgrade; the sparse-times-full&lt;br&gt;
is faster there (see the release notes).  The speedup is&lt;br&gt;
more for A*B when B has more than one column, though, so you&lt;br&gt;
might not see much improvement.&lt;br&gt;
&lt;br&gt;
Another option is to compute C'*B instead, where C=A'.  That&lt;br&gt;
sounds counter-intuitive, but it's faster in MATLAB 7.6 (and&lt;br&gt;
perhaps earlier), if I recall.  It has to do with the sparse&lt;br&gt;
matrix storage.  For sparse-times-full matrix, I think it's&lt;br&gt;
faster if the sparse matrix is stored in row major order. &lt;br&gt;
That's from memory, though (mine, not the computers...) from&lt;br&gt;
lots of experiments I've played with.  Memory may be faulty.&lt;br&gt;
&lt;br&gt;
Storing a matrix in row order is the same as doing C=A'. &lt;br&gt;
Then when MATLAB does C'*B it's smart enough not to compute&lt;br&gt;
C' first.&lt;br&gt;
&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Tue, 13 May 2008 19:26:03 -0400</pubDate>
      <title>Re: faster way to multiply 100,000 times (in ODE)</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/169157#431886</link>
      <author>Chris </author>
      <description>Thanks for the advice guys - I have to do the &lt;br&gt;
multiplication each time becase it's a network simulation &lt;br&gt;
and I need to add up the contributions of all connected &lt;br&gt;
nodes @ each time point.  &lt;br&gt;
&lt;br&gt;
The connectivity matrix (1000x1000) never changes, but the &lt;br&gt;
activity vector (1000) does each time.&lt;br&gt;
&lt;br&gt;
I'll upgrade because anything to make this run faster would &lt;br&gt;
be great.&lt;br&gt;
</description>
    </item>
  </channel>
</rss>
