2007-01-22 14:40:05 +01:00
|
|
|
function [Q,R] = qr2(X)
|
2007-11-08 18:23:53 +01:00
|
|
|
% 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.
|
|
|
|
%
|
|
|
|
% OUTPUTS
|
|
|
|
% See matlab's documentation.
|
|
|
|
%
|
|
|
|
% ALGORITHM
|
|
|
|
% None.
|
2007-01-22 14:40:05 +01:00
|
|
|
%
|
2007-11-08 18:23:53 +01:00
|
|
|
% SPECIAL REQUIREMENTS
|
|
|
|
% None.
|
|
|
|
%
|
|
|
|
%
|
|
|
|
% stephane.adjemian@ens.fr [12-07-2005]
|
|
|
|
% part of DYNARE, copyright Dynare Team (2007)
|
|
|
|
% Gnu Public License.
|
2007-01-22 14:40:05 +01:00
|
|
|
[Q,R] = qr(X);
|
|
|
|
indx = find(diag(R)<0);
|
|
|
|
if ~isempty(indx)
|
|
|
|
Q(:,indx) = -Q(:,indx);
|
|
|
|
R(indx,:) = -R(indx,:);
|
|
|
|
end
|