Home > matlab > qr2.m

qr2

PURPOSE ^

This routine performs a qr decomposition of matrix X such that the

SYNOPSIS ^

function [Q,R] = qr2(X)

DESCRIPTION ^

 This routine performs a qr decomposition of matrix X such that the
 diagonal scalars of the upper-triangular matrix R are positive. If X 
 is a full (column) rank matrix, then R is also the cholesky
 factorization of X'X. This property is needed for the Del Negro 
 & Schorfheides's identification scheme.
 
 INPUTS 
   See matlab's documentation for QR decomposition.
     
 OUTPUTS 
   See matlab's documentation for QR decomposition.

 ALGORITHM
   None.       

 SPECIAL REQUIREMENTS
   None.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [Q,R] = qr2(X)
0002 % This routine performs a qr decomposition of matrix X such that the
0003 % diagonal scalars of the upper-triangular matrix R are positive. If X
0004 % is a full (column) rank matrix, then R is also the cholesky
0005 % factorization of X'X. This property is needed for the Del Negro
0006 % & Schorfheides's identification scheme.
0007 %
0008 % INPUTS
0009 %   See matlab's documentation for QR decomposition.
0010 %
0011 % OUTPUTS
0012 %   See matlab's documentation for QR decomposition.
0013 %
0014 % ALGORITHM
0015 %   None.
0016 %
0017 % SPECIAL REQUIREMENTS
0018 %   None.
0019 
0020 % Copyright (C) 2006-2009 Dynare Team
0021 %
0022 % This file is part of Dynare.
0023 %
0024 % Dynare is free software: you can redistribute it and/or modify
0025 % it under the terms of the GNU General Public License as published by
0026 % the Free Software Foundation, either version 3 of the License, or
0027 % (at your option) any later version.
0028 %
0029 % Dynare is distributed in the hope that it will be useful,
0030 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0031 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0032 % GNU General Public License for more details.
0033 %
0034 % You should have received a copy of the GNU General Public License
0035 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
0036 
0037 [Q,R] = qr(X);
0038 indx = find(diag(R)<0);
0039 if ~isempty(indx)
0040     Q(:,indx) = -Q(:,indx);
0041     R(indx,:) = -R(indx,:);
0042 end

Generated on Tue 22-May-2012 02:40:23 by m2html © 2005