Re: Behavior of Array[]
- To: mathgroup at smc.vnet.net
- Subject: [mg19461] Re: [mg19444] Behavior of Array[]
- From: "Andrzej Kozlowski" <andrzej at tuins.ac.jp>
- Date: Sat, 28 Aug 1999 15:52:57 -0400
- Sender: owner-wri-mathgroup at wolfram.com
Let's take an example. The command Array[a,{3,3}] assumes that a is a function of two variables and constructs a 3 times 3 matrix (an array): In[30]:= Array[a, {3, 3}] Out[30]= {{a[1, 1], a[1, 2], a[1, 3]}, {a[2, 1], a[2, 2], a[2, 3]}, {a[3, 1], a[3, 2], a[3, 3]}} This is exactly the same as thing that you get from In[1]:= Table[a[i, j], {i, 1, 3}, {j, 1, 3}] Out[1]= {{a[1, 1], a[1, 2], a[1, 3]}, {a[2, 1], a[2, 2], a[2, 3]}, {a[3, 1], a[3, 2], a[3, 3]}} so I assume that will is at least agree that each of these is as consistent as the other. Of course a is here a function, not an array! Now suppose you define an array b with In[2]:= b = Array[a, {3, 3}] Out[2]= {{a[1, 1], a[1, 2], a[1, 3]}, {a[2, 1], a[2, 2], a[2, 3]}, {a[3, 1], a[3, 2], a[3, 3]}} Now we have two objects, an array b and a function a. You have to clearly distinuish these two, for example the definition a=Array[a,{3,3}] will immediately get you into an infinite loop. Thus to get the first element of the first row of b you use the command In[3]:= b[[1, 1]] Out[3]= a[1, 1] In words: the element of the array b in position {1,1} is the value of the function a at (1,1). This is, in my opinion, perfectly consistent and exactly as it should be. -- Andrzej Kozlowski Toyama International University JAPAN http://sigma.tuins.ac.jp http://eri2.tuins.ac.jp ---------- >From: jslater at cs.wright.edu (Joseph C. Slater) To: mathgroup at smc.vnet.net >To: mathgroup at smc.vnet.net >Subject: [mg19461] [mg19444] Behavior of Array[] >Date: Wed, Aug 25, 1999, 6:25 AM > > I've been using Mathematica for many years and one thing still puzzles me. > Elements of the array defined by the variable 'a' can be obtained using > a[[i,j]]=expression. However, the command Array creates arrays comprised > of elements named in the form 'a[i,j]'. Note the single brackets. > Everything I see in the Mathematica book about brackets says that these > are functions. This seems inconsistant to me. Shouldn't they be listed as > 'a[[i,j]]' until they are defined? What are the single brackets supposed > to mean if not elements of the array 'a'? > Thanks in advance, > > Joe Slater > > -- > ________________________________________________________________ > Dr. Joseph C. Slater mailto:joseph.slater at wright.edu > Mechanical and Materials Engineering office:+1 (937) 775-5085 > Wright State University fax:+1 (937) 775-5009 > Dayton, OH 45435 http://www.cs.wright.edu/~jslater > >