       Re: Manually nested Tables faster than builtin nesting?

• To: mathgroup at smc.vnet.net
• Subject: [mg113459] Re: Manually nested Tables faster than builtin nesting?
• From: "Carl K. Woll" <carlw at wolfram.com>
• Date: Fri, 29 Oct 2010 06:30:00 -0400 (EDT)

```On 10/28/2010 3:28 AM, Bob Hanlon wrote:
> I get similar results and Outer falls between the others.
>
> imax = jmax = 5000;
>
> (tabletable = Table[Table[i*j, {i, imax}], {j, jmax}];) //
>    Timing // First
>
> 1.96097
>
> (table = Table[i*j, {i, imax}, {j, jmax}];) // Timing // First
>
> 24.0062
>
> (outer = Outer[#1*#2&, Range[imax], Range[jmax]];) // Timing // First
>
> 14.2569
>
>

Using Outer[Times, Range[imax], Range[jmax]] would be much, much faster:

In:= table1 = Outer[#1*#2 &, Range[imax], Range[jmax]]; // Timing

Out= {12.433, Null}

In:= table2 = Outer[Times, Range[imax], Range[jmax]]; // Timing

Out= {0.078, Null}

Carl Woll
Wolfram Research

> tabletable == table == outer
>
> True
>
>
> Bob Hanlon
>
> ---- Sebastian Schmitt<sschmitt at physi.uni-heidelberg.de>  wrote:
>
> =============
> Dear all!
>
> 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:= imax = jmax = 5000;
>
> In:= (tabletable = Table[Table[i*j, {i, imax}], {j, jmax}];) //
>    Timing // First
>
> Out= 1.84
>
> In:= (table = Table[i*j, {i, imax}, {j, jmax}];) // Timing // First
>
> Out= 14.55
>
> In:= tabletable == table
>
> Out= True
>
> Thanks,
>
> Sebastian
>
>
>

```

• Prev by Date: Re: If and Piecewise don't quite do what I need
• Next by Date: Re: Visualization for Dummies
• Previous by thread: Re: Manually nested Tables faster than builtin nesting?
• Next by thread: Re: Manually nested Tables faster than builtin nesting?