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

 採用された回答

David Goodmanson
David Goodmanson 2017 年 10 月 17 日

0 投票

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 件のコメント

marcelo martines
marcelo martines 2017 年 10 月 17 日
Thanks a lot for the attention and for the script David Goodmanson, it seems works fine!

サインインしてコメントする。

その他の回答 (2 件)

Walter Roberson
Walter Roberson 2017 年 10 月 16 日

0 投票

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?
marcelo martines
marcelo martines 2017 年 10 月 16 日

0 投票

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 件のコメント

Walter Roberson
Walter Roberson 2017 年 10 月 16 日
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.
marcelo martines
marcelo martines 2017 年 10 月 16 日
編集済み: marcelo martines 2017 年 10 月 16 日
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.

サインインしてコメントする。

カテゴリ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by