MathGroup Archive 2000

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

Search the Archive

Re: possible bug in Mathematica?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg25985] Re: [mg25967] possible bug in Mathematica?
  • From: Andrzej Kozlowski <andrzej at tuins.ac.jp>
  • Date: Wed, 15 Nov 2000 02:09:38 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

You can achieve exactly what you want by using the assignment:

matrix[[1, 1]] = 11

instead of 

matrix[[1]][[1]] = 11

Which does not work.

Although the documentation for Par says that matrix[[1,1]] and
matrix[[1]][[1]] are equivalent, this does not apply to assignments. Thi sis
really not anything particular to lists or matrices but the way Set works.
consider the following exampe which does not involve lists:

In[5]:=
t = x^2 + y^2;

In[6]:=t[[1,1]] = z;

In[7]:=t

Out[7]=
 2    2
y  + z

On the other hand, this does not work:

In[8]:=
t[[1]][[1]] = x;

Set::setps: t[[1]] in assignment of part is not a symbol.

In[9]:=t

Out[9]=
 2    2
y  + z

-- 
Andrzej Kozlowski
Toyama International University
JAPAN

http://platon.c.u-tokyo.ac.jp/andrzej/
http://sigma.tuins.ac.jp/


on 00.11.14 5:46 PM, Peter Joseph at joseph at oasis.rad.upenn.edu wrote:

> 
> I am running Mathematica version 4.0 under Windows 98 2nd edition.
> 
> I only recently discovered your newsgroup on technical questions about
> 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[8]:= vector = Table[0, {2}]
> Out[8]= {0, 0}
> 
> (* next redefine the values in the vector *)
> 
> In[9]:=vector[[1]] = 1
> Out[9]=1
> 
> In[10]:=vector[[2]] = 2
> Out[10]=2
> 
> In[11]:=vector
> Out[11]={1, 2}
> 
> (* That was successful, now try exactly the same technique with a matrix
> *)
> 
> In[12]:=matrix = Table[0, {2}, {3}]
> Out[12]={{0, 0, 0}, {0, 0, 0}}
> 
> In[13]:=matrix[[1]][[1]] = 11
> Set::"setps": "\!\(matrix \[LeftDoubleBracket] 1 \[RightDoubleBracket]\)
> in \
> assignment of part is not a symbol."
> Out[13]=11
> 
> In[14]:=matrix
> Out[14]={{0, 0, 0}, {0, 0, 0}}
> 
> (* evidently, Mathematica interprets the meaning of vector[[1]] very
> differently than matrix[[1]][[1]]
> 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.
> Professor of Radiologic Physics in Radiology
> Hospital of the University of Pennsylvania
> Philadelphia, PA, 19104-4283
> Telephone 215-662-6679
> email joseph at rad.upenn.edu
> 
> 
> 
> 




  • Prev by Date: Re: MathLink
  • Next by Date: RE: possible bug in Mathematica?
  • Previous by thread: Re: possible bug in Mathematica?
  • Next by thread: RE: possible bug in Mathematica?