Symmetric Kronecker product in Matlab

Is there any function available to compute the symmetric kronecker product in Matlab? Thanks in advance.

 Accepted Answer

Hi Marcelo,
Here is an attempt at symmetric kron of square matrices A and B of the same size. The whole task is to make the matrices U. I have not verified this but it gives the correct result for U when A and B are 2x2 and 3x3. Also for 10x10, symmetric kron of A,B and of B,A give the same answer.
n = 10;
A = rand(n,n);
B = rand(n,n);
M1 = sk(A,B);
M2 = sk(B,A);
siz = size(M1)
max(max(abs(M1-M2)))
function M = sk(A,B)
% symmetric kronecker product for two square matrices, each of size nxn
n = size(A,1)
U = eye(n^2);
a = reshape(1:n^2,n,n);
b = a';
U = U + U(b(:),:);
c = tril(a);
c = c(:);
c(c==0) = [];
U = U(c,:);
U(U==1) = sqrt(2);
U(U==2) = 1;
M = (1/2)*U*kron(A,B)*U';
end

1 Comment

Thanks a lot for the attention and for the script David Goodmanson, it seems works fine!

Sign in to comment.

More Answers (2)

syms a b c
kron([a, b, c], [c/(b+1), a])
ans =
[ (a*c)/(b + 1), a^2, (b*c)/(b + 1), a*b, c^2/(b + 1), a*c]
Looks okay?
It's difficult to me generalize the matrix "U" for any sized square matrix. It's easy calculate "by hand" in the paper, but hard to make a code/script for it. Imagine I have two matrices A and B 10x10 each one, the matrix U will have 55 rows by 100 columns. I need a code that I give the size of A or B matrices and this code automatically generate the matrix U. Thanks for the attention.

2 Comments

The definition is not quite right. It says U element of R^(n*(n+1))x(n^2) . If we substitute in n = 3, then U would have to be an element of R^(3*4)x(3x3) = R^(12)x(9) . However, the example output is 6 x 9 and the description of how the entries are labeled cannot support the 12 x 9 possibility.
The description only makes sense if R^(n*(n+1)/2)x(n^2)
"It's difficult to me generalize the matrix "U" for any sized square matrix."
U will only be square when n = 1.
I will need to think more about good ways to fill in such a matrix.
Yes the number of rows is n.(n+1)/2, it's missing de division by two, and columns is n^2 . "It's difficult to me generalize the matrix "U" for any sized square matrix." It means, from a given square matrix A or B from de definition of symmetric kronecker product, it's possible compute one matrix U of appropriate dimensions.

Sign in to comment.

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!