[R] kronecker sum
Duncan Murdoch
murdoch.duncan at gmail.com
Sun Jun 5 15:41:23 CEST 2011
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
More information about the R-help
mailing list