what is wrong here?
- To: mathgroup@smc.vnet.net
- Subject: [mg12103] what is wrong here?
- From: rao@supermod.egr.uh.edu (Dr. Jagannatha Rao)
- Date: Sat, 25 Apr 1998 01:30:34 -0400
- Organization: University of Houston
I am having a lot of difficulty in trying to use commands on a matrix as follows: matrix[[{i,j,k},{i,j,k}]] = matrix[[{i,j,k},{i,j,k}]] + some 3x3 matrix. See the example below. When i,j,k areconsecutive indices, there seems to be no problem. When the indices are, say {3,4,7,8}, the program always crashes with a bus error. ---------------------------------------------------------- supermod 103$ math Mathematica 3.0 for NEXTSTEP Intel Copyright 1988-97 Wolfram Research, Inc. -- Motif graphics initialized -- In[1]:= matrix = Table[a , {i,8},{j,8}] Out[1]= {{a, a, a, a, a, a, a, a}, {a, a, a, a, a, a, a, a}, > {a, a, a, a, a, a, a, a}, {a, a, a, a, a, a, a, a}, > {a, a, a, a, a, a, a, a}, {a, a, a, a, a, a, a, a}, > {a, a, a, a, a, a, a, a}, {a, a, a, a, a, a, a, a}} In[2]:= matrix[[{1,2,3,4},{1,2,3,4}]] //MatrixForm Out[2]//MatrixForm= a a a a a a a a a a a a a a a a In[3]:= temp=Table[b, {i,4},{j,4}] Out[3]= {{b, b, b, b}, {b, b, b, b}, {b, b, b, b}, {b, b, b, b}} In[4]:= matrix[[{1,2,3,4},{1,2,3,4}]] = \ matrix[[{1,2,3,4},{1,2,3,4}]] + temp Out[4]= {{a + b, a + b, a + b, a + b}, {a + b, a + b, a + b, a + b}, > {a + b, a + b, a + b, a + b}, {a + b, a + b, a + b, a + b}} In[5]:= matrix //MatrixForm Out[5]//MatrixForm= > a + b a + b a + b a + b a a a a a + b a + b a + b a + b a a a a a + b a + b a + b a + b a a a a a + b a + b a + b a + b a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a In[6]:= matrix = Table[a , {i,8},{j,8}] Out[6]= {{a, a, a, a, a, a, a, a}, {a, a, a, a, a, a, a, a}, > {a, a, a, a, a, a, a, a}, {a, a, a, a, a, a, a, a}, > {a, a, a, a, a, a, a, a}, {a, a, a, a, a, a, a, a}, > {a, a, a, a, a, a, a, a}, {a, a, a, a, a, a, a, a}} In[7]:= matrix[[{3,4,7,8},{3,4,7,8}]]= \ matrix[[{3,4,7,8},{3,4,7,8}]] + temp Bus error supermod 104$ -- Jagannatha Rao E-mail:rao@uh.edu Associate Professor Department of Mechanical Engineering Tel :(713) 743-4535 University of Houston Fax :(713) 743-4503 Houston, TX 77204-4792