MathGroup Archive 2000

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

Search the Archive

Re: Unusual speedup of Table

  • To: mathgroup at smc.vnet.net
  • Subject: [mg25620] Re: Unusual speedup of Table
  • From: Albert Retey <albert.retey at visualanalysis.com>
  • Date: Mon, 16 Oct 2000 03:04:42 -0400 (EDT)
  • Organization: Visual Analysis
  • References: <8s1798$ii7@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi Steven,
 
> Why is the second call of Table below so much faster than the first? These
> results are from Mathematica 4.0.2.1 for Power Mac (400 MHz PPC 750, OS 9). It
> isn't some kind of cache effect because the times are consistent over many
> executions of both expressions. (And yes, I know I can do a lot better still
> for this particular computation with Drop and Take).
> 
> - Steve Tether
> 
> n = 10000;
> a = Table[Random[], {n}];
> Timing[Table[a[[j + 1]] - 2 a[[j]] + a[[j - 1]], {j, 2, n - 1}];]
> 
> {10.5333 Second, Null}
> 
> Timing[Table[Switch[j, _, a[[j + 1]] - 2 a[[j]] + a[[j - 1]]], {j, 2, n - 1}];]
> 
> {0.7 Second, Null}

I see the same on Linux. It is gone in the 4.1 beta, where the first is
a factor 3 faster than the second. Anyway, the second version became
slightly slower...

Albert


  • Prev by Date: Re: Unusual speedup of Table
  • Next by Date: Simple equation checking..
  • Previous by thread: Re: Unusual speedup of Table
  • Next by thread: Re: Unusual speedup of Table