function [v,info] = doubles (g,d,h,tol,maxit) % % DOUBLES Solves a Sylvester equation using doubling % % [v,info] = doubles (g,d,h,tol,maxit) uses a doubling algorithm % to solve the Sylvester equation % v = d + g v h % for v. Currently, the output variable info is not set. % % Iteration is stopped at iteration n when either n=maxit or when % % norm{v(n) - v(n-1)} <= tol* norm{v(n)} % % where v(n) is the approximation for v computed in the % nth iteration and norm is the matrix one norm. % % REFERENCES: % B.D.O Anderson and Moore(1979) % E.W. Anderson, L.P. Hansen, E.R McGrattan and T.J Sargent(1996) % L.P. Hansen and T.J. Sargent (1995) % % PROGRAM WRITTEN BY: E. W. Anderson Nov 26, 1994 % MODIFIED: 12/26/98 v = d; for i =1:maxit, vadd = g*v*h; v = v+vadd; if norm (vadd,1) <= (tol*norm(v,1)), break; end g = g*g; h = h*h; end info=0;