Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: Strange bug

  • To: mathgroup at smc.vnet.net
  • Subject: [mg53288] Re: Strange bug
  • From: Bill Rowe <readnewsciv at earthlink.net>
  • Date: Tue, 4 Jan 2005 03:13:49 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

On 1/3/05 at 4:29 AM, stevebg at adelphia.net (Steve Gray) wrote:

>I have procedural function "ordermat." It works ok if the
>next-to-last (useless) line is there but if I remove that one line,
>I get error messages due to the last line,  at execution time:

>Set::write: Tag Times in Null\{0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
>\[LeftSkeleton]1\ \[RightSkeleton]} is Protected.

>("intersect" returns a small integer and computes "tafr.")

>I've seen bugs like this before. I'm using 5.0.1.0 with Windows.
>Any clues? Thanks in advance.

>ordermat[gon_] := Module[{row, rx, cx},
>    gonl = Length[gon];
>    matx = Table[0, {i, 1, gonl}, {j, 1, gonl}];
>    gona = Join[gon, gon];
>    For [ rx = 1, rx <= gonl, rx++,
>       row  = Table[0, {2*gonl}];
>       row[[rx]] = 1;
>       row[[rx + 1]] = 2;
>               ab = gona[[rx]];
>       ae = gona[[rx + 1]];
>       For [ cx = 1, cx <= gonl - 3, cx++,
>                  bb = gona[[cx + rx + 1]];
>                  be = gona[[cx + rx + 2]];
>                  int = intersect[ab, ae, bb, be];
>                  If [ int == 3, row[[cx + rx + 1]] = tafr + 1];
>              ]
>               rx;                  (*   Error unless some expression is here.?? *)
>               matx[[rx]] = Table[Max[row[[i]], row[[i + gonl]]], {i, gonl}];
>           ]
>    ] 

As near as I can tell, this code simply creates a square matrix whose first row is {1,2,0,0...} and every subsequent row is rotated one position right. If so, the following code does the same thing much more efficiently

ordermat[n_]:= 
  Module[{row = PadRight[{1, 2}, n]},
    Join[{row}, RotateRight[row, #1]&/@Range[n-1]]]


and

matx = ordermat[Length@gon]

produces the same result as your code.

--
To reply via email subtract one hundred and four


  • Prev by Date: Re: Strange bug
  • Next by Date: Re: Strange bug
  • Previous by thread: Re: Strange bug
  • Next by thread: Re: Strange bug