Last active
September 13, 2017 02:49
-
-
Save RianWardana/a22acdceccb3a7d9ebcb62e47160ade3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [flag] = pdtest(P) | |
% Mencari nilai N, yaitu besarnya matrix P | |
% Matrix P harus merupakan rectangular matrix | |
[row, column] = size(P); | |
if row ~= column | |
error('Matrix harus rectangular'); | |
end | |
N = row; | |
% Menguji sifat positive definite matrix P dengan Sylvester's criterion | |
% Yaitu dengan menguji determinan submatrix 1x1, 2x2, ... NxN | |
order = 0; | |
for iterDet = 1:N | |
if det(P(1:iterDet, 1:iterDet)) > 0 | |
order = order + 1; | |
end | |
end | |
% Apabila jumlah determinan submatrix yang positif sama dengan N, | |
% maka matriks P adalah matriks positive definite | |
if order == N | |
flag = 1; | |
else | |
flag = 0; | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment