MATLAB: Symmetric Kronecker product in Matlab

mathematicsMATLABmatrix manipulationoptimization

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

Best 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
Related Question