Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


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

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: 17,944
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 " <sjjhuisman@hotmail.com> wrote in message
news:l19ku9$e5l$1@newscl01ah.mathworks.com...
> 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));


Ditto.

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


Ditto.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com




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

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.