MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: RE: puzzling difference in speed


Hartmut Wolf remarked with respect to the given examples::

> Obviously the computing machinery for Array behaves differently when the
> dimensions are given explicitly or introduced as an expression (to be
> evaluated)
>


It seems to be more complicated. Have a look at the following results:

In[1]:=
n=100; t1 = Table[0, {n},{n},{n}];

In[2]:=
t = array[Plus, Dimensions[t1]];
u = array[Plus, {100, 100, 100}];
Equal[t, u]

Out[4]= True

In[5]:=
ReplaceAll[t, array\[Rule]Array]; // Timing
ReplaceAll[u ,array\[Rule]Array]; // Timing

Out[5]=
{0.65 Second,Null}
Out[6]=
{0.77 Second,Null}

In[7]:=
Apply[Array, t]; // Timing
Apply[Array, u]; // Timing

Out[7]=
{4.51 Second,Null}
Out[8]=
{0.72 Second,Null}

Despite the fact that t equals u, we have the same difference in timing.
Does Mathematica 'remember' the way the expression t has been computed?

Fred Simons
Eindhoven University of Technology




  • Prev by Date: RE: PlotVectorField
  • Next by Date: Re: On Limit[ f[x,y], x->x0 ]
  • Previous by thread: RE: puzzling difference in speed
  • Next by thread: Re: puzzling difference in speed