Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: faster way to multiply 100,000 times (in ODE)

Subject: faster way to multiply 100,000 times (in ODE)

From: Chris

Date: 13 May, 2008 08:13:03

Message: 1 of 4

One step is bogging down an ode file that simulates network
activity. I've got to multiply an initial conditions
vector of length 1000 by the 1000x1000 connectivity
matrix. The 1Kx1K matrix has 10% ones and is declared
sparse. Essentially I'm just running IC*Connectivity.

This multiplication needs to occur once every iteration of
solving the ODE's. It's such a basic operation, but I'm
wondering if there is anything that may speed it up. 90%
of the ODE run time is spent doing this multiplication (an
it's not a simple set of ODE's either).

Thanks!

Subject: Re: faster way to multiply 100,000 times (in ODE)

From: David

Date: 13 May, 2008 09:58:03

Message: 2 of 4

"Chris " <cag44@removethispitt.edu> wrote in message
<g0biif$g5p$1@fred.mathworks.com>...
> One step is bogging down an ode file that simulates
network
> activity. I've got to multiply an initial conditions
> vector of length 1000 by the 1000x1000 connectivity
> matrix. The 1Kx1K matrix has 10% ones and is declared
> sparse. Essentially I'm just running IC*Connectivity.
>
> This multiplication needs to occur once every iteration
of
> solving the ODE's. It's such a basic operation, but I'm
> wondering if there is anything that may speed it up.
90%
> of the ODE run time is spent doing this multiplication
(an
> it's not a simple set of ODE's either).
>
> Thanks!

does it really have to be done every step? i
would 'assume' the ic's don't change, does the
connectivity matrix change each time step? if not then
just do the multiplication once outside the loop.


Subject: Re: faster way to multiply 100,000 times (in ODE)

From: Tim Davis

Date: 13 May, 2008 13:21:02

Message: 3 of 4

"Chris " <cag44@removethispitt.edu> wrote in message
<g0biif$g5p$1@fred.mathworks.com>...
> One step is bogging down an ode file that simulates network
> activity. I've got to multiply an initial conditions
> vector of length 1000 by the 1000x1000 connectivity
> matrix. The 1Kx1K matrix has 10% ones and is declared
> sparse. Essentially I'm just running IC*Connectivity.
>
> This multiplication needs to occur once every iteration of
> solving the ODE's. It's such a basic operation, but I'm
> wondering if there is anything that may speed it up. 90%
> of the ODE run time is spent doing this multiplication (an
> it's not a simple set of ODE's either).
>
> Thanks!

If you don't have MATLAB 7.6, upgrade; the sparse-times-full
is faster there (see the release notes). The speedup is
more for A*B when B has more than one column, though, so you
might not see much improvement.

Another option is to compute C'*B instead, where C=A'. That
sounds counter-intuitive, but it's faster in MATLAB 7.6 (and
perhaps earlier), if I recall. It has to do with the sparse
matrix storage. For sparse-times-full matrix, I think it's
faster if the sparse matrix is stored in row major order.
That's from memory, though (mine, not the computers...) from
lots of experiments I've played with. Memory may be faulty.

Storing a matrix in row order is the same as doing C=A'.
Then when MATLAB does C'*B it's smart enough not to compute
C' first.

Subject: Re: faster way to multiply 100,000 times (in ODE)

From: Chris

Date: 13 May, 2008 19:26:03

Message: 4 of 4

Thanks for the advice guys - I have to do the
multiplication each time becase it's a network simulation
and I need to add up the contributions of all connected
nodes @ each time point.

The connectivity matrix (1000x1000) never changes, but the
activity vector (1000) does each time.

I'll upgrade because anything to make this run faster would
be great.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
sparse multiply Tim Davis 13 May, 2008 09:25:10
large matrix multiplication Chris 13 May, 2008 04:27:00
ode Chris 13 May, 2008 04:26:45
rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics