


function test = ispd(A) Tests if a square matrix is positive definite. INPUTS o A [double] a square matrix. OUTPUTS o test [integer] is equal to one if A is pd, 0 otherwise. SPECIAL REQUIREMENTS None.


0001 function test = ispd(A) 0002 0003 % function test = ispd(A) 0004 % Tests if a square matrix is positive definite. 0005 % 0006 % INPUTS 0007 % o A [double] a square matrix. 0008 % 0009 % OUTPUTS 0010 % o test [integer] is equal to one if A is pd, 0 otherwise. 0011 % 0012 % SPECIAL REQUIREMENTS 0013 % None. 0014 0015 % Copyright (C) 2007-2009 Dynare Team 0016 % 0017 % This file is part of Dynare. 0018 % 0019 % Dynare is free software: you can redistribute it and/or modify 0020 % it under the terms of the GNU General Public License as published by 0021 % the Free Software Foundation, either version 3 of the License, or 0022 % (at your option) any later version. 0023 % 0024 % Dynare is distributed in the hope that it will be useful, 0025 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0026 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0027 % GNU General Public License for more details. 0028 % 0029 % You should have received a copy of the GNU General Public License 0030 % along with Dynare. If not, see <http://www.gnu.org/licenses/>. 0031 0032 m = length(A);% I do not test for a square matrix... 0033 test = 1; 0034 0035 for i=1:m 0036 if ( det( A(1:i, 1:i) ) < 2.0*eps ) 0037 test = 0; 0038 break 0039 end 0040 end