       Re: Matrix Operations in Mma

• To: mathgroup at yoda.physics.unc.edu
• Subject: Re: Matrix Operations in Mma
• From: colinr at sue.econ.su.oz.au (Colin Rose)
• Date: Wed, 29 Sep 93 1:13:12 EET

```      Martin Rickli writes:
>>    How can I assign a matrix to a part of another matrix?
>>    eg. Replace the lower right 2x2 matrix in a 3x3 Identity matrix
>>    by say {{a,b},{c,d}} to get the result   { {1,0,0},
>>                                               {0,a,b},
>>                                               {0,c,d} }

One way of doing this would be to define a function  Hi[A, S, {x, y}]
that substitutes the matrix S into matrix A at element {x, y}. For instance:

Hi[A_, S_, {x_, y_}] := (k=A;  Do[k=ReplacePart[k, S[[i,j]], {i+x-1,j+y-1}],
{i, Dimensions[S][]}, {j, Dimensions[S][]}]; k)

In[]:=      M = IdentityMatrix;
R = { {a, b}, {c, d} };
Hi[M, R, {2, 2}]

Out[]=      1   0   0
0   a   b
0   c   d

Here is another example:

In[]:=      M = IdentityMatrix;
R = { {a, b, c}, {d, e, f} };
Hi[M, R, {3, 2}]

Out[]=      1   0   0   0   0
0   1   0   0   0
0   a   b   c   0
0   d   e   f   0
0   0   0   0   1

Regards

Colin

Colin Rose
Dept. of Economics
University of Sydney
colinr at extro.ucc.su.oz.au
*************************

```

• Prev by Date: chemical kinetics
• Next by Date: Serious problem with DelaunayTriangulation package?
• Previous by thread: the problem
• Next by thread: Serious problem with DelaunayTriangulation package?