Determining Smith Form of a rectangular matrix
26 ビュー (過去 30 日間)
古いコメントを表示
Akshay Vivek Panchwagh
2022 年 7 月 5 日
コメント済み: Akshay Vivek Panchwagh
2022 年 7 月 7 日
I need to find Smith Form of a rectangular 3x2 matrix in MATLAB. I searched for documentation but all the solutions it has are for square matrices. Can anyone please help me in determining how I can find the Smith Form using smithForm for a rectangular matrix?
0 件のコメント
採用された回答
Rohit Kulkarni
2022 年 7 月 5 日
Hi,
Open the Functions tab, which is besides the overview tab, it contains the function to evaluate smith form.
I don't think there is any way to use "smithForm" to find the smith form of non-square matrices and one will have to write an algorithm to compute it.
3 件のコメント
Rohit Kulkarni
2022 年 7 月 7 日
Hey, I tried some examples myself, I think its working right
A = [40 -20 36 12; -24 -4 28 48; 0 4 0 -8; 8 0 0 -8]
MNsmithForm(A)
B = [1 1; -2 6; 0 8]
MNsmithForm(B)
C = [6 -6 4; -6 -12 -8]
MNsmithForm(C)
Function in the link provided in the answer above:
function [SA, invFact, D] = MNsmithForm(A)
row = size(A,1);
col = size(A,2);
n = min(row,col);
minors = cell(1,n);
D0 = 1;
D0 = sym(D0);
D = sym(NaN(1,n));
invFact = sym(NaN(1,n));
for i = 1:n;
rowindex = false(1,row);
rowindex(1:i) = true;
rowperms = unique(perms(rowindex),'rows');
colindex = false(1,col);
colindex(1:i) = true;
colperms = unique(perms(colindex),'rows');
rownum = size(rowperms,1);
colnum = size(colperms,1);
minors{i} = sym(NaN(rownum,colnum));
for j=1:rownum;
for k=1:colnum;
Atmp = A;
Atmp = Atmp(rowperms(j,:),:);
Atmp = Atmp(:,colperms(k,:));
minors{i}(j,k) = det(Atmp);
end
end
rowlen = rownum*colnum; %(row - (i-1))*(col - (i-1));
minors{i} = reshape(minors{i},1,rowlen);
minors{i}(minors{i} == 0) = [];
D(i) = gcd(minors{i});
if i == 1
invFact(i) = D(i)/D0;
else
invFact(i) = D(i)/D(i-1);
end
end
SA = diag(invFact);
if row>col
zerorows = zeros(row-col,col);
SA = [SA;zerorows];
elseif col>row
zerocols = zeros(row,col-row);
SA = [SA, zerocols];
end
end
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Visualization and Data Export についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!