Commit b87a453c authored by sebastien's avatar sebastien
Browse files

v4 matlab:

* removed sylvester3.m and sylvester3a.m (have been moved to gensylv/ subdir)
* display an error message when dynare called without argument


git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@1852 ac1d8469-bf42-47a9-8791-bf33cf982152
parent a31789dc
......@@ -18,10 +18,17 @@ function dynare(fname, varargin)
%
% part of DYNARE, copyright Dynare Team (2001-2008)
% Gnu Public License.
dynareroot = dynare_config();
if nargin < 1
error('You must provide the name of the MOD file in argument');
end
if ~ischar(fname)
error ('The argument in DYNARE must be a text string.') ;
end
dynareroot = dynare_config();
% Testing if file have extension
% If no extension defalut .mod is added
if isempty(strfind(fname,'.'))
......
......@@ -72,6 +72,5 @@ for i=1:number_of_mex_files
message = '[mex] ';
end
disp([ message mex_status{i,3} '.' ])
disp([])
end
disp(' ')
\ No newline at end of file
% solves a*x+b*x*c=d
function x=sylvester3(a,b,c,d)
n = size(a,1);
m = size(c,1);
if n == 1
x=d./(a*ones(1,m)+b*c);
return
end
if m == 1
x = (a+c*b)\d;
return;
end
x=zeros(n,m);
[u,t]=schur(c);
[aa,bb,qq,zz]=qz(full(a),full(b),'real'); % available in Matlab version 6.0
d=qq*d*u;
i = 1;
while i < m
if t(i+1,i) == 0
if i == 1
c = zeros(n,1);
else
c = bb*(x(:,1:i-1)*t(1:i-1,i));
end
x(:,i)=(aa+bb*t(i,i))\(d(:,i)-c);
i = i+1;
else
if i == n
c = zeros(n,1);
c1 = zeros(n,1);
else
c = bb*(x(:,1:i-1)*t(1:i-1,i));
c1 = bb*(x(:,1:i-1)*t(1:i-1,i+1));
end
z = [aa+bb*t(i,i) bb*t(i+1,i); bb*t(i,i+1) aa+bb*t(i+1,i+1)]...
\[d(:,i)-c;d(:,i+1)-c1];
x(:,i) = z(1:n);
x(:,i+1) = z(n+1:end);
i = i + 2;
end
end
if i == m
c = bb*(x(:,1:m-1)*t(1:m-1,m));
x(:,m)=(aa+bb*t(m,m))\(d(:,m)-c);
end
x=zz*x*u';
% 01/25/03 MJ corrected bug for i==m (sign of c in x determination)
% 01/31/03 MJ added 'real' to qz call
% solves iteratively ax+bxc=d
function x=sylvester3a(x0,a,b,c,d)
a_1 = inv(a);
b = a_1*b;
d = a_1*d;
e = 1;
iter = 1;
while e > 1e-8 & iter < 500
x = d-b*x0*c;
e = max(max(abs(x-x0)));
x0 = x;
iter = iter + 1;
end
if iter == 500
warning('sylvester3a : Only accuracy of %10.8f is achieved after 500 iterations')
end
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment