       Re: possible bug in Mathematica?

• To: mathgroup at smc.vnet.net
• Subject: [mg25982] Re: possible bug in Mathematica?
• Date: Wed, 15 Nov 2000 02:09:36 -0500 (EST)
• References: <8ur0ag\$qsq@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```This is not a bug.  You have the syntax wrong.  For a matrix that
is "m" rows by "n" columns you specify the element with:

matrix[[row,column]

I have included an example.  Note that this format extends to more
that "2-dimensional" matrices.

In:=
vector = Table[i, {i, 1, 3}]

Out=
{1, 2, 3}

In:=
matrix = Table[i*j, {i, 1, 2}, {j, 1, 3}]

Out=
{{1, 2, 3}, {2, 4, 6}}

In:=
matrix[[1, 3]]

Out=
3

In:=
matrix[[2, 2]]

Out=
4

In article <8ur0ag\$qsq at smc.vnet.net>,
Peter Joseph <joseph at oasis.rad.upenn.edu> wrote:
>
> I am running Mathematica version 4.0 under Windows 98 2nd edition.
>
> Mathematica.  I am not sure if you consider the following problem to
be a
> question or a bug report.  I have already submitted this to Wolfram
as a
> bug report.
>
> (* The problem is how to redefine or recalculate the elments of a list
> with more than one dimension, such as a matrix
> First, demonstrate that there is no such problem with a simple list *)
>
> In:= vector = Table[0, {2}]
> Out= {0, 0}
>
> (* next redefine the values in the vector *)
>
> In:=vector[] = 1
> Out=1
>
> In:=vector[] = 2
> Out=2
>
> In:=vector
> Out={1, 2}
>
> (* That was successful, now try exactly the same technique with a
matrix
> *)
>
> In:=matrix = Table[0, {2}, {3}]
> Out={{0, 0, 0}, {0, 0, 0}}
>
> In:=matrix[][] = 11
> Set::"setps": "\!\(matrix \[LeftDoubleBracket] 1 \[RightDoubleBracket]
\)
> in \
> assignment of part is not a symbol."
> Out=11
>
> In:=matrix
> Out={{0, 0, 0}, {0, 0, 0}}
>
> (* evidently, Mathematica interprets the meaning of vector[] very
> differently than matrix[][]
> It considers the vector elements to be variables that can be
redefined,
> while it considers the matrix elements constants that are
> protected.  I tried using Unprotect in various forms, but that did not
> work.
>
> So the question is, how does one do computations on lists which are
nested
> more than one level deep?? *)
>
> Peter M. Joseph, Ph.D.
> Hospital of the University of Pennsylvania
> Telephone 215-662-6679