Search All of the Math Forum:

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

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

 Messages: [ Previous | Next ]
 Steven Lord Posts: 18,038 Registered: 12/7/04
Re: vpa-function Performance
Posted: Sep 17, 2013 10:16 AM

"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
http://www.mathworks.com

Date Subject Author
9/17/13 Sjoerd
9/17/13 Steven Lord
9/17/13 Sjoerd
9/17/13 Sjoerd
9/17/13 dpb
9/17/13 Sjoerd
9/18/13 dpb