Home > source > sylvester.m

sylvester

PURPOSE ^

Sylvester's criterion.

SYNOPSIS ^

function bool = sylvester( A )

DESCRIPTION ^

Sylvester's criterion.

This function check if the given matrix A is symmetric, definite positive, using the Sylvester's Criterion.

Prototype: bool = sylvester(A)

Input:     The A matrix to check.

Output:    It returns 1 (TRUE) if A is symmetric, definite positive.
           It returns 0 (FALSE) if A is NOT symmetric, definite positive.

Author: Esposito Gianluca (N.Matr.056/100858)
Revision Claudio Fantacci, Alessandro Martini.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %Sylvester's criterion.
0002 %
0003 %This function check if the given matrix A is symmetric, definite positive, using the Sylvester's Criterion.
0004 %
0005 %Prototype: bool = sylvester(A)
0006 %
0007 %Input:     The A matrix to check.
0008 %
0009 %Output:    It returns 1 (TRUE) if A is symmetric, definite positive.
0010 %           It returns 0 (FALSE) if A is NOT symmetric, definite positive.
0011 %
0012 %Author: Esposito Gianluca (N.Matr.056/100858)
0013 %Revision Claudio Fantacci, Alessandro Martini.
0014 
0015 function bool = sylvester( A )
0016 
0017 bool = -1;
0018 [row,col] = size(A);
0019 
0020 %Is A a square matrix?
0021 if (row ~= col)
0022    fprintf(' Impossibile proseguire: matrice non quadrata\n');
0023    return
0024 end
0025 
0026 eps_value = eps;
0027 
0028 %Is A symmetric?
0029 At = A';
0030 for i = 1 : row
0031    for j = 1 : col
0032       if (abs(At(i,j) - A(i,j)) >= eps_value)
0033          fprintf(' Impossibile proseguire: matrice non simmetrica\n');
0034          return
0035       end
0036    end
0037 end
0038 
0039 %The Sylvester's criterion
0040 for k = 1 : row
0041    if (det(A(1:k,1:k)) <= eps_value)
0042       bool = 0;
0043       return
0044    end
0045 end
0046 bool = 1;

Generated on Thu 24-Sep-2009 17:17:32 by m2html © 2005