MathGroup Archive 2003

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

Search the Archive

Re: Increase in efficiency with Module

  • To: mathgroup at smc.vnet.net
  • Subject: [mg40122] Re: Increase in efficiency with Module
  • From: "Carl K. Woll" <carlw at u.washington.edu>
  • Date: Fri, 21 Mar 2003 02:38:17 -0500 (EST)
  • References: <004201c2eef2$3966f420$0d1f0944@Main> <oprmceh6emamtwdy@smtp.cox-internet.com>
  • Sender: owner-wri-mathgroup at wolfram.com

Bobby,

The difference in timing between the n=200 and n=500 cases arises due to the
use of packed arrays. When the array length is longer than 250 (by default)
the array is automatically converted into a packed array. So, the n=200 case
uses unpacked arrays and hence is quite a bit slower than the n=500 case
which uses packed arrays. My code when run on unpacked arrays is slower than
the compiled versions, probably because the compiled versions automatically
convert the input to packed arrays. If you add a To PackedArray command to
carl (or carl2) you will find that the timings between the compiled versions
and my version are comparable.

Carl Woll
Physics Dept
U of Washington

----- Original Message -----
From: "Dr Bob" <drbob at bigfoot.com>
To: mathgroup at smc.vnet.net
<Hartmut.Wolf at t-systems.com>
Subject: [mg40122] Re: Increase in efficiency with Module


> That's very interesting!  First of all, it's a brilliantly simple
> implementation.
>
> With a list of size n=100, ftauc3PP is five times as fast as carl.  When
> n=200, it's still 4 times as fast.  So, 'carl' isn't always faster.
>
> It has far better complexity, though.  When n=500, the worm turns and carl
> is almost 4 times faster.  When n=1000, it's almost 6 times faster.  (On
my
> machine.)  For n=2000, it's almost 9 times faster.
>
> It's very odd that 'carl' handles n=500 in LESS time (14 msec) than n=200
> (40 msec).
>
> The following is another 7% faster for n=1000, 3% faster at n=2000, and 5%
> faster at n=3000:
>
> carl2[t_] := Block[{s = 0},
>     Nest[(s += Tr[Sign[# - First[#]]]; Rest[#]) &, t, Length[t]];
>     s]
>
> Those differences are small, but statistically significant.
>
> Bobby
>




  • Prev by Date: RE: Finding solutions to differential eqns
  • Next by Date: Re: Increase in efficiency with Module
  • Previous by thread: Re: RE: Increase in efficiency with Module
  • Next by thread: Re: Increase in efficiency with Module