New matlab functions to be used if a dll is missing.
git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@1810 ac1d8469-bf42-47a9-8791-bf33cf982152time-shift
parent
7eb6fa3ed1
commit
e6a060d64e
|
@ -0,0 +1,25 @@
|
|||
function E = gensylv(fake,A,B,C,D)
|
||||
% Solves a Sylvester equation.
|
||||
%
|
||||
% INPUTS
|
||||
% fake Unused argument (for compatibility with the mex file)
|
||||
% A
|
||||
% B
|
||||
% C
|
||||
% D
|
||||
%
|
||||
% OUTPUTS
|
||||
% E
|
||||
%
|
||||
% ALGORITHM
|
||||
% none.
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none.
|
||||
%
|
||||
%
|
||||
% part of DYNARE, copyright Dynare Team (1996-2008)
|
||||
% Gnu Public License.
|
||||
C = kron(C,C);
|
||||
x0 = sylvester3(A,B,C,D);
|
||||
E = sylvester3a(x0,A,B,C,D);
|
|
@ -0,0 +1,71 @@
|
|||
function D = A_times_B_kronecker_C(A,B,C)
|
||||
% Computes A * kron(B,C).
|
||||
%
|
||||
% INPUTS
|
||||
% A [double] mA*nA matrix.
|
||||
% B [double] mB*nB matrix.
|
||||
% C [double] mC*nC matrix.
|
||||
%
|
||||
% OUTPUTS
|
||||
% D [double] mA*(nC*nB) or mA*(nB*nB) matrix.
|
||||
%
|
||||
% ALGORITHM
|
||||
% none.
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none.
|
||||
%
|
||||
%
|
||||
% part of DYNARE, copyright Dynare Team (1996-2008)
|
||||
% Gnu Public License.
|
||||
|
||||
% Chek number of inputs and outputs.
|
||||
if nargin>3 | nargin<2
|
||||
error('Two or Three input arguments required!')
|
||||
end
|
||||
if nargout>1
|
||||
error('Too many output arguments!')
|
||||
end
|
||||
% Get & check dimensions. Initialization of the output matrix.
|
||||
[mA,nA] = size(A);
|
||||
[mB,nB] = size(B);
|
||||
if nargin == 3
|
||||
[mC,nC] = size(C);
|
||||
if mB*mc ~= nA
|
||||
error('Input dimension error!')
|
||||
end
|
||||
D = zeros(mA,nB*nC);
|
||||
loop = (mB*nB*mC*nC > 1e7);
|
||||
else
|
||||
if mB*mB ~= nA
|
||||
error('Input dimension error!')
|
||||
end
|
||||
D = D = zeros(mA,nB*nB);
|
||||
loop = (mB*nB*mB*nB > 1e7);
|
||||
end
|
||||
% Computational part.
|
||||
if loop
|
||||
if nargin == 3
|
||||
k1 = 1;
|
||||
for i1=1:nB
|
||||
for i2=1:nC
|
||||
D(:,k1) = A * kron(B(:,i1),C(:,i2));
|
||||
k1 = k1 + 1;
|
||||
end
|
||||
end
|
||||
else
|
||||
k1 = 1;
|
||||
for i1=1:nB
|
||||
for i2=1:nB
|
||||
D(:,k1) = A * kron(B(:,i1),B(:,i2));
|
||||
k1 = k1 + 1;
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
if nargin == 3
|
||||
D = A * kron(B,C);
|
||||
else
|
||||
D = A * kron(B,B);
|
||||
end
|
||||
end
|
|
@ -0,0 +1,22 @@
|
|||
function D = sparse_hessian_times_B_kronecker_C(A,B,C)
|
||||
% Computes A * kron(B,C) where A is a sparse matrix.
|
||||
%
|
||||
% INPUTS
|
||||
% A [double] mA*nA matrix.
|
||||
% B [double] mB*nB matrix.
|
||||
% C [double] mC*nC matrix.
|
||||
%
|
||||
% OUTPUTS
|
||||
% D [double] mA*(nC*nB) or mA*(nB*nB) matrix.
|
||||
%
|
||||
% ALGORITHM
|
||||
% none.
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none.
|
||||
%
|
||||
%
|
||||
% part of DYNARE, copyright Dynare Team (1996-2008)
|
||||
% Gnu Public License.
|
||||
|
||||
D = A_times_B_kronecker_C(A,B,C);
|
|
@ -0,0 +1,63 @@
|
|||
function [ss,tt,w,sdim,eigval,info] = mjdgges(e,d,qz_criterium)
|
||||
% QZ decomposition, Sims' codes are used.
|
||||
%
|
||||
% INPUTS
|
||||
% e [double] real square (n*n) matrix.
|
||||
% d [double] real square (n*n) matrix.
|
||||
% qz_criterium [double] scalar (1+epsilon).
|
||||
%
|
||||
% OUTPUTS
|
||||
% ss [complex] (n*n) matrix.
|
||||
% tt [complex] (n*n) matrix.
|
||||
% w [complex] (n*n) matrix.
|
||||
% sdim [integer] scalar.
|
||||
% eigval [complex] (n*1) vector.
|
||||
% info [integer] scalar.
|
||||
%
|
||||
% ALGORITHM
|
||||
% Sims's qzdiv routine is used.
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none.
|
||||
%
|
||||
%
|
||||
% part of DYNARE, copyright Dynare Team (1996-2008)
|
||||
% Gnu Public License.
|
||||
|
||||
% Chek number of inputs and outputs.
|
||||
if nargin>3 | nargin<2
|
||||
error('Three or two input arguments required!')
|
||||
end
|
||||
if nargout>6
|
||||
error('No more than six output arguments!')
|
||||
end
|
||||
% Check the first two inputs.
|
||||
[me,ne] = size(e);
|
||||
[md,nd] = size(d);
|
||||
if ( ~isdouble(e) | ~isdouble(d) | iscomplex(e) | iscomplex(d) | me~=ne | md~=nd | me~nd)
|
||||
% info should be negative in this case, see dgges.f.
|
||||
error('MYDGGES requires two square real matrices of the same dimension.')
|
||||
end
|
||||
% Set default value of qz_criterium.
|
||||
if nargin <3
|
||||
qz_criterium = 1 + 1e-6;
|
||||
end
|
||||
% Initialization of the output arguments.
|
||||
ss = zeros(ne,ne);
|
||||
tt = zeros(ne,ne);
|
||||
w = zeros(ne,ne);
|
||||
sdim = 0;
|
||||
eigval = zeros(ne,1);
|
||||
info = 0;
|
||||
% Computational part.
|
||||
try
|
||||
[ss,tt,qq,w] = qz(e,d);
|
||||
[ss,tt,qq,w] = qzdiv(qz_criterium,tt,ss,qq,w);
|
||||
warning_old_state = warning;
|
||||
warning off;
|
||||
eigval = diag(ss)./diag(tt);
|
||||
warning warning_old_state;
|
||||
sdim = sum( abs(eigval) < qz_criterium );
|
||||
catch
|
||||
info = 1;% Not as precise as lapack's info!
|
||||
end
|
Loading…
Reference in New Issue