フィルターのクリア

Determinant of integer matrices

1 回表示 (過去 30 日間)
Rudolf Fruehwirth
Rudolf Fruehwirth 2021 年 4 月 23 日
コメント済み: Matt J 2021 年 4 月 23 日
Is there a version of the det function in R2020a that alway gives determinant 0 for small singular integer matrices?
  4 件のコメント
Rudolf Fruehwirth
Rudolf Fruehwirth 2021 年 4 月 23 日
And it should work without prior knowledge whether the entries are integer or not. Probably asking too much...
Matt J
Matt J 2021 年 4 月 23 日
And it should work without prior knowledge whether the entries are integer or not. Probably asking too much...
No, one of hte answers below meets that requirement.

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

回答 (2 件)

Matt J
Matt J 2021 年 4 月 23 日
編集済み: Matt J 2021 年 4 月 23 日
Since you know A is an integer matrix, can't you just do,
d=round(det(A));
  3 件のコメント
Matt J
Matt J 2021 年 4 月 23 日
OK. Well, maybe the A(i,j) are supposed to be "small" in mangitude as well...
John D'Errico
John D'Errico 2021 年 4 月 23 日
A = randi(3,29,30);
A(end+1,:) = round(rand(1,29)*2-1)*A
A = 30×30
2 3 2 3 2 1 1 2 2 2 1 1 1 3 3 2 3 2 1 3 3 1 2 2 1 1 1 3 3 2 1 3 3 2 2 3 1 1 2 1 1 2 3 3 2 2 2 2 2 1 1 1 2 2 2 2 1 1 1 1 1 2 3 1 1 1 3 3 1 1 1 2 2 1 1 3 2 3 2 1 3 3 2 1 1 2 3 1 2 3 3 1 2 1 2 3 3 1 1 1 1 1 1 1 1 2 2 2 1 2 3 3 1 2 2 1 2 3 1 2 3 2 2 1 1 1 3 1 2 1 2 1 2 1 2 2 1 3 2 3 1 3 3 3 3 2 2 3 3 1 1 3 1 3 1 3 1 1 1 2 2 2 2 1 1 3 1 2 2 3 3 1 2 2 1 1 1 1 1 3 3 1 1 3 3 3 3 1 1 1 1 3 1 3 1 1 3 2 1 3 1 3 2 3 2 1 2 1 3 3 3 2 3 3 3 1 3 1 1 1 3 2 3 2 3 3 3 1 3 1 3 2 2 1 3 3 1 3 2 3 2 3 3 3 3 1 2 2 1 3 1 2 3 3 2 1 1 1 3 1 2 3 3 3 3 1 3 3 2 1 3 2 1 2 2 3 1 1 3 2 3 1 2 3 3 1 3 1 1 3 1 2 1 2 3 2 2 3 1 2
rank(A)
ans = 29
det(A)
ans = 0.5894
round(det(A))
ans = 1
Ok, I guess it works, some of the time. But not this one.
If the matrix is truly tiny, well yes.
A = magic(4)
A = 4×4
16 2 3 13 5 11 10 8 9 7 6 12 4 14 15 1
rank(A)
ans = 3
det(A)
ans = 5.1337e-13
round(det(A))
ans = 0
But you really cannot trust that rounding the determinant will work unless things are truly tiny.

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


Matt J
Matt J 2021 年 4 月 23 日
編集済み: Matt J 2021 年 4 月 23 日
This might work,
A = randi(10000,[9,10]);
A(end+1,:) = randi(10,[1,9])*A;
determinant=double(det(sym(A)))
determinant = 0

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by