Home > matlab > AIM > SPExact_shift.m

SPExact_shift

PURPOSE ^

[h,q,iq,nexact] = exact_shift(h,q,iq,qrows,qcols,neq)

SYNOPSIS ^

function [h,q,iq,nexact] = SPExact_shift(h,q,iq,qrows,qcols,neq)

DESCRIPTION ^

 [h,q,iq,nexact] = exact_shift(h,q,iq,qrows,qcols,neq)

 Compute the exact shiftrights and store them in q.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % [h,q,iq,nexact] = exact_shift(h,q,iq,qrows,qcols,neq)
0002 %
0003 % Compute the exact shiftrights and store them in q.
0004 
0005 % Original author: Gary Anderson
0006 % Original file downloaded from:
0007 % http://www.federalreserve.gov/Pubs/oss/oss4/code.html
0008 % Adapted for Dynare by Dynare Team.
0009 %
0010 % This code is in the public domain and may be used freely.
0011 % However the authors would appreciate acknowledgement of the source by
0012 % citation of any of the following papers:
0013 %
0014 % Anderson, G. and Moore, G.
0015 % "A Linear Algebraic Procedure for Solving Linear Perfect Foresight
0016 % Models."
0017 % Economics Letters, 17, 1985.
0018 %
0019 % Anderson, G.
0020 % "Solving Linear Rational Expectations Models: A Horse Race"
0021 % Computational Economics, 2008, vol. 31, issue 2, pages 95-113
0022 %
0023 % Anderson, G.
0024 % "A Reliable and Computationally Efficient Algorithm for Imposing the
0025 % Saddle Point Property in Dynamic Models"
0026 % Journal of Economic Dynamics and Control, 2010, vol. 34, issue 3,
0027 % pages 472-489
0028 
0029 function [h,q,iq,nexact] = SPExact_shift(h,q,iq,qrows,qcols,neq)
0030 
0031 %hs=SPSparse(h);
0032 hs=sparse(h);
0033 nexact = 0;
0034 left   = 1:qcols;
0035 right  = qcols+1:qcols+neq;
0036 zerorows = find( sum(abs( hs(:,right)' ))==0 );
0037 
0038 while( any(zerorows) && iq <= qrows )
0039    nz = length(zerorows);
0040    q(iq+1:iq+nz,:) = hs(zerorows,left);
0041    hs(zerorows,:)   = SPShiftright(hs(zerorows,:),neq);
0042    iq     = iq + nz;
0043    nexact = nexact + nz;
0044    zerorows = find( sum(abs( hs(:,right)' ))==0 );
0045 end
0046 h=full(hs);
0047

Generated on Mon 21-May-2012 02:42:43 by m2html © 2005