Re: (Q:) ReplacePart + SubMatrix replacement
- To: mathgroup at smc.vnet.net
- Subject: [mg7066] Re: [mg7033] (Q:) ReplacePart + SubMatrix replacement
- From: Allan Hayes <hay at haystack.demon.co.uk>
- Date: Sat, 3 May 1997 22:04:56 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Fri, 2 May 1997 "m.r." <schaferk at communique.net> [mg7033] (Q:) ReplacePart + SubMatrix replacement > For A,B n-by-n, matrices, > K non empty subset of CartesianProduct[Range[n],Range[n]]... > i wish to replace the block A[[K]] with the block B[[K]] As you comment in your full message (copied below ****) ReplacePart does not seem to perform as expected. However: A = Table[0,{3},{3}] {{0,0,0},{0,0,0},{0,0,0}} B = Table[1,{3},{3}] {{1,1,1},{1,1,1},{1,1,1}} A[[{1,3},{2,3}]] = B[[{1,3},{2,3}]]; A {{0,1,1},{0,0,0},{0,1,1}} Of course, much more is possible using this technique Allan Hayes hay at haystack.demon.co.uk http://haystack.demon.co.uk ********************************* Begin forwarded message: >From: "m.r." <schaferk at communique.net> >To: mathgroup at smc.vnet.net >Subject: [mg7033] (Q:) ReplacePart + SubMatrix replacement >Organization: Communique Inc. greetings: Mma3.0 has added a form of ReplacePart not found in Mma2.2.2: ?ReplacePart[expr,new,pos,npos] ReplacePart[expr,new,pos,npos] replaces parts at positions pos in expr by parts at positions npos in new. For A,B n-by-n, matrices, K non empty subset of CartesianProduct[Range[n],Range[n]] one can use ReplacePart[A,B,K,{1,1}] to replace the block A[[K]] with B[[1,1]]. (no problem) what i wish ( though perhaps unrealistically) is for ReplacePart[A,B,K,K] to replace the block A[[K]] with the block B[[K]]. am i misreading the above usage message for ReplacePart? if so, how does one do a simple block replace in "one fell swoop"? sincerely. m. r. email replies to schaferk at tennessee.nrlssc.navy.mil