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: Vectorization of nested for loops
Replies: 9   Last Post: Aug 20, 2013 10:20 AM

Advanced Search

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

Posts: 16
Registered: 10/28/12
Re: Vectorization of nested for loops
Posted: Aug 17, 2013 8:23 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

> I am puzzled by your two earlier lines:
>
> ec = zeros(rows+1, cols, riskLevels);
> ec(1, :, :) = 100;
>
> where riskLevels = 3. If this is what you really do, you ought to get error messages stating that ec(r-1,c,risk) on the right side is undefined on the first trip through the three nested for-loops with risk = 6. In any case this would certainly make your execution very slow. The 'ec' array needs to be pre-defined up to risk = 18 in the third dimension of your allocation if the nested loops are going to extend it that far.
>
> Roger Stafford


You're right there...the risk level values I posted are not really the values I'm working with.

Over the last hour I've done some testing with your vectorized version of the code and I noticed that the vectorized version (for whatever reason) seems to be slower than the original version - and the differences in speed become worse the larger the input data are.



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.