Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.


Mike
Posts:
17
Registered:
10/28/12


Re: Vectorization of nested for loops
Posted:
Aug 17, 2013 8:23 AM


> 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(r1,c,risk) on the right side is undefined on the first trip through the three nested forloops with risk = 6. In any case this would certainly make your execution very slow. The 'ec' array needs to be predefined 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.



