MathGroup Archive 2000

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

Search the Archive

Finally...the results

  • To: mathgroup at smc.vnet.net
  • Subject: [mg22132] Finally...the results
  • From: "Jordan Rosenthal" <jr at ece.gatech.edu>
  • Date: Wed, 16 Feb 2000 02:34:49 -0500 (EST)
  • Organization: Georgia Institute of Technology, Atlanta GA, USA
  • References: <888ad7$c7d@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi all,

With some help I got my comparison code working.  Below are the results for
both a small and large vector sizes.  To make the comparison valid I had to
change some of the code sent to me slightly. ( For instance, all functions
were changed so that they checked the input to make sure it was a vector
with f[v_?vectorQ]. )

The clear "winner" in terms of execution time is David Park.  Here is his
function:

  f["David Park"][v_?VectorQ] :=
    Module[{w, l = Length[v]},
    w = Join[Table[0, {l - 1}], Reverse[v], Table[0, {l - 1}]];
    Table[Take[w, {2l - i, 3l - 1 - i}], {i, 1, 2l - 1}] ]

If you are interested in seeing the definitions for the other functions, let
me know and I'll send you the notebook I used for the tests.

For moderately sized vectors all functions were fast and the differences
were minor.  As the size of the vector increased, the executation times
broke into distinct groups according to the methods used.  The numbers below
change each time I run it, but these are pretty typical.  (Note: In the
length 2000 example below, Paul Abbot's version takes much longer than the
rest.  The time is correct.  I checked it individually and found that it
must use a large amount of memory because my disk drive starts to thrash.)

I'm using the Mathematica 4.0 on Windows 98.

Jordan

PS Thanks to all for your help.  This little project sure taught me quite a
bit about Mathematica!

======================
Vector Size = 100:

results =
  Sort[{List @@ (Part[#, 1, 1] &) /@
              Timing /@ Through[ (Hold @@ f /@ authornames)[Range[100]]],
          authornames} // Transpose ] // TableForm

        0         Allan Hayes
        0         Andrzej Kozlowski
        0         Bojan Bistrovic (2)
        0         David Park
        0         Hartmut Wolf
        0         Luci Ellis (1)
        0         Luci Ellis (2)
        0         Matt Johnson (1)
        0         Rob Pratt
        0         Ted Ersek
        0         Tom Burton (2)
        0.05    Tom Burton (1)
        0.06    Matt Johnson (2)
        0.06    Paul Abbot
        0.10    Bojan Bistrovic (1)
======================
Vector Size = 1500:

results =
  Sort[{List @@ (Part[#, 1, 1] &) /@
              Timing /@ Through[ (Hold @@ f /@ authornames)[Range[1500]]],
          authornames} // Transpose ] // TableForm

       0.28     David Park
       1.05     Ted Ersek
       1.15     Matt Johnson (2)
       1.15     Tom Burton (2)
       1.15     Luci Ellis (1)
       1.16     Matt Johnson (1)
       1.21     Luci Ellis (2)
       1.42     Allan Hayes
       1.54     Andrzej Kozlowski
       1.54     Tom Burton (1)
       1.59     Hartmut Wolf\"
       2.36     Paul Abbot
       3.13     Rob Pratt
       4.4       Bojan Bistrovic (2)
       9.67     Bojan Bistrovic (1)
======================
Vector Size = 2000:

results =
  Sort[{List @@ (Part[#, 1, 1] &) /@
              Timing /@ Through[ (Hold @@ f /@ authornames)[Range[2000]]],
          authornames} // Transpose ] // TableForm

        0.55       David Park
        1.92       Ted Ersek
        2.19       Luci Ellis (1)
        2.20       Matt Johnson (2)
        2.20       Tom Burton (2)
        2.26       Luci Ellis (2)
        2.31       Matt Johnson (1)
        2.41       Allan Hayes
        2.91       Andrzej Kozlowski
        2.91       Hartmut Wolf
        3.07       Tom Burton (1)
        5.60       Rob Pratt
        7.58       Bojan Bistrovic (2)
        16.48     Bojan Bistrovic (1)
        236.95   Paul Abbot





  • Prev by Date: Re: How to call by reference for particular argument(s)?
  • Next by Date: Re: What is happening here?
  • Previous by thread: Re: Function to transform lists
  • Next by thread: letter