An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110605/6523b97f/attachment.pl>
kronecker sum
3 messages · Lara Poplarski, Duncan Murdoch, (Ted Harding)
On 11-06-05 9:36 AM, Lara Poplarski wrote:
Dear All, Could someone please suggest how to find the Kronecker sum of two 2x2 matrices, i.e. given two matrices: -A A a -a and -B B b -b I need: -A-B A B 0 a -a-B 0 B b 0 -A-b A 0 b a -a-b
Why not do it in the obvious way? A <- matrix1[1,2] a <- matrix1[2,1] B <- matrix2[1,2] b <- matrix2[2,1] matrix(c(-A-B,a,b,0, A,-a-B,0,b, B,0,-A-b,a, 0,B,A,-a-b), 4,4) Duncan Murdoch
On 05-Jun-11 13:36:18, Lara Poplarski wrote:
Dear All, Could someone please suggest how to find the Kronecker sum of two 2x2 matrices, i.e. given two matrices: -A A a -a and -B B b -b I need: -A-B A B 0 a -a-B 0 B b 0 -A-b A 0 b a -a-b Many thanks, Lara
For example, let A=10, a=2, B=5, b=3 so that your
-A-B A B 0
a -a-B 0 B
b 0 -A-b A
0 b a -a-b
is
-15 10 5 0
2 -7 0 5
3 0 -13 10
0 3 2 -5
Then, in R,
M <- matrix(c(-10,10,2,-2),byrow=TRUE,ncol=2)
N <- matrix(c(-5,5,3,-3),byrow=TRUE,ncol=2)
I <- diag(1,2,2)
kronecker(I,M) + kronecker(N,I)
# [,1] [,2] [,3] [,4]
# [1,] -15 10 5 0
# [2,] 2 -7 0 5
# [3,] 3 0 -13 10
# [4,] 0 3 2 -5
See '?kronecker'.
Hoping this helps.
Ted.
--------------------------------------------------------------------
E-Mail: (Ted Harding) <ted.harding at wlandres.net>
Fax-to-email: +44 (0)870 094 0861
Date: 05-Jun-11 Time: 15:37:32
------------------------------ XFMail ------------------------------