


solves iteratively ax+bxc=d


0001 function [x0, flag]=sylvester3a(x0,a,b,c,dd) 0002 % solves iteratively ax+bxc=d 0003 0004 % Copyright (C) 2005-2012 Dynare Team 0005 % 0006 % This file is part of Dynare. 0007 % 0008 % Dynare is free software: you can redistribute it and/or modify 0009 % it under the terms of the GNU General Public License as published by 0010 % the Free Software Foundation, either version 3 of the License, or 0011 % (at your option) any later version. 0012 % 0013 % Dynare is distributed in the hope that it will be useful, 0014 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0015 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0016 % GNU General Public License for more details. 0017 % 0018 % You should have received a copy of the GNU General Public License 0019 % along with Dynare. If not, see <http://www.gnu.org/licenses/>. 0020 0021 a_1 = inv(a); 0022 b = a_1*b; 0023 flag=0; 0024 for j=1:size(dd,3), 0025 d = a_1*dd(:,:,j); 0026 e = 1; 0027 iter = 1; 0028 while e > 1e-8 && iter < 500 0029 x = d-b*x0(:,:,j)*c; 0030 e = max(max(abs(x-x0(:,:,j)))); 0031 x0(:,:,j) = x; 0032 iter = iter + 1; 0033 end 0034 if iter == 500 0035 sprintf('sylvester3a : Only accuracy of %10.8f is achieved after 500 iterations',e); 0036 flag=1; 0037 end 0038 end