27 lines
759 B
Matlab
27 lines
759 B
Matlab
function [Q,R] = qr2(X)
|
|
% 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.
|
|
%
|
|
% part of DYNARE, copyright Dynare Team (2006-2008)
|
|
% Gnu Public License.
|
|
[Q,R] = qr(X);
|
|
indx = find(diag(R)<0);
|
|
if ~isempty(indx)
|
|
Q(:,indx) = -Q(:,indx);
|
|
R(indx,:) = -R(indx,:);
|
|
end |