What is happening here?

• To: mathgroup at smc.vnet.net
• Subject: [mg22107] What is happening here?
• From: "Jordan Rosenthal" <jr at ece.gatech.edu>
• Date: Mon, 14 Feb 2000 02:03:58 -0500 (EST)
• Organization: Georgia Institute of Technology, Atlanta GA, USA
• Sender: owner-wri-mathgroup at wolfram.com

```Hi all,

I finally had a chance to try and compare all the different methods people
sent me for computing the matrix

( 1 0 0 )
( 2 1 0 )
( 3 2 1 )
( 0 3 2 )
( 0 0 3 )

from the vector {1,2,3} (using much larger vectors).  I am running into a
strange problem that I can't explain.

I started by creating a function for each contributer.  Here is an example
for two of the defintions (picked arbitrarily for this example because they
were first and last in the alphabet):

-------------------------------------------------------
f["Paul Abbot"][v_?VectorQ] := Module[
{n = Length[v]},
NestList[RotateRight,
Range[2n - 1, 3n - 2]]]
]

f["Hartmut Wolf"][v_?VectorQ] := With[{r = Length[v] - 1},
Transpose[NestList[RotateRight, Join[v, Table[0, {r}]], r]]]
-------------------------------------------------------

Running the following code (based on a suggestion from Hartmut Wolf) works
great:

-------------------------------------------------------
vLarge = Range[400];

List @@ (Part[#, 1, 1] &) /@
Timing /@ Through[ Hold[f["Paul Abbot"], f["Hartmut Wolf"]][vLarge]]

{0.49 Null, 0.27 Null}
-------------------------------------------------------

This works great; it gives me a list of timings for the two methods.  But
because I have a large list I wanted to instead run code like this (where
authornames would be a larger vector):

-------------------------------------------------------
authornames = {"Paul Abbot", "Hartmut Wolf"};

List @@ (Part[#, 1, 1] &) /@
Timing /@ Through[ FullForm[Hold @@ (f /@ authornames)][vLarge]]

{0. Null}
-------------------------------------------------------

but this doesn't work the same way.  So I tried to compare the difference
between the two versions by checking the difference between the code I
replaced and my code.  Shown below, the two expressions have the same
FullForms and Attributes:

-------------------------------------------------------
expr1 = Hold[ f["Paul Abbot"], f["Hartmut Wolf"] ];
expr2 = Hold @@ (f /@ authornames);

FullForm[expr1]==FullForm[expr2]
True

Attributes[expr1]==Attributes[expr2]
True

expr1 == expr2
True
-------------------------------------------------------

If the two expression have the same FullForm and Attributes, why do I not
get the same results if I substitute one for the other?

Humbly perplexed,

Jordan

```

• Prev by Date: Re: Sorting
• Next by Date: Re: Re: Re: Re: Orientation of characters in FrameLabel
• Previous by thread: Re: How to call by reference for particular argument(s)?
• Next by thread: Re: What is happening here?