Re: Manually nested Tables faster than builtin nesting?

*To*: mathgroup at smc.vnet.net*Subject*: [mg113429] Re: Manually nested Tables faster than builtin nesting?*From*: Bill Rowe <readnews at sbcglobal.net>*Date*: Thu, 28 Oct 2010 04:27:23 -0400 (EDT)

On 10/27/10 at 5:13 AM, sschmitt at physi.uni-heidelberg.de (Sebastian Schmitt) wrote: >I find that manually nested Tables are faster (factor 2 in my >example) compared to the builtin nesting. I probably do a stupid >thinko. Could you please have a look? >In[52]:= imax = jmax = 5000; >In[53]:= (tabletable = Table[Table[i*j, {i, imax}], {j, jmax}];) // >Timing // First >Out[53]= 1.84 >In[54]:= (table = Table[i*j, {i, imax}, {j, jmax}];) // Timing // >First >Out[54]= 14.55 I get similar timing results. My speculation is as follows: When you use the built-in nesting, you explicitly do 25 million multiplies. No possibility of vector processing. But when you use explicit nesting, you are multiplying a packed array by a scalar. My guess is Mathematica employs some vector processing here and gains a speed up over individual multiplies. If my speculation is right, then there should be some operations which will not gain such a dramatic speed-up.