Re: Assignment to submatrices
- To: mathgroup@smc.vnet.net
- Subject: [mg11339] Re: Assignment to submatrices
- From: Allan Hayes <hay@haystack.demon.co.uk>
- Date: Fri, 6 Mar 1998 00:40:58 -0500
- References: <6dg8no$2up@smc.vnet.net>
David E. Cox wrote: > Is there any way to assign directly to submatrices, without building a > higher order tensor? ie if A and B are 2x2's how do I create the 4x4 > matrix [0 I2x2; A B]. Dave, The Add-on LinearAlgebra`MatrixManipulation` does the job. In[1]:= A= Array[a,{2,2}]; In[2]:= B = Array[b,{2,2}]; In[3]:= I22 =IdentityMatrix[2]; In[4]:= Z=0 I22; In[5]:= <<LinearAlgebra`MatrixManipulation` In[6]:= BlockMatrix[{{Z,I22},{A,B}}]//MatrixForm Out[6]//MatrixForm= 0 0 1 0 0 0 0 1 a[1, 1] a[1, 2] b[1, 1] b[1, 2] a[2, 1] a[2, 2] b[2, 1] b[2, 2] -- Allan Hayes Training and Consulting Leicester, UK hay@haystack.demon.co.uk http://www.haystack.demon.co.uk voice: +44 (0)116 271 4198 fax: +44 (0)116 271 8642