The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: vpa-function Performance
Replies: 6   Last Post: Sep 18, 2013 10:13 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Steven Lord

Posts: 18,038
Registered: 12/7/04
Re: vpa-function Performance
Posted: Sep 17, 2013 10:16 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Sjoerd " <> wrote in message
> Hai,
> I want too perform the following calculations, but I'm surprised about the
> performance of the operation. Is there a way to speed things up?
> WM is a 1000x1000 matrix with values between zero and one.
> AM is a 1000x1000 matrix with values zero OR one.
> OM_old is a 1x1000 matrix with values between zero and one.
> Elapsed time is 0.039411 seconds.
> => wm_self = vpa(diag(WM));
> Elapsed time is 0.150876 seconds.
> => om_self = vpa(diag(WM).*transpose(OM_old));

Break this into two pieces and time each one:

y = diag(WM).*transpose(OM_old);
om_self = vpa(y);

I bet you the first piece takes most of the time.

> Elapsed time is 966.512410 seconds. => Takes too long
> => wm_friends = vpa(sum(WM.*AM, 2));


> Elapsed time is 1120.104194 seconds. => Takes too long
> => om_friends = vpa(sum(WM.*AM.*repmat(OM_old, length(AM), 1),2));


Steve Lord
To contact Technical Support use the Contact Us link on

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.