function [am,bm,cm,dm] = sfr(Z1,Z2,Z3,Z4)
% [SS_M] = SFR(SS_) or
% [AM,BM,CM,DM] = SFR(A,B,C,D) produces a right spectral factorization
%      via the duality of SFL such thtat
%
%                 M(s)M'(-s) = I - G(s)G'(-s)
%
%                Input data:  G(s):= SS_ = MKSYS(A,B,C,D);
%                Output data: M(s):= SS_M = MKSYS(AM,BM,CM,DM);
%
%  The regular state-space can be recovered by "branch".

% R. Y. Chiang & M. G. Safonov 7/85
% Copyright (c) 1988 by the MathWorks, Inc.
% All Rights Reserved.
% ---------------------------------------------------------------------
%

inargs = '(a,b,c,d)';
eval(mkargs(inargs,nargin,'ss'))

[amm,bmm,cmm,dmm] = sfl(a',c',b',d');
am = amm';
bm = cmm';
cm = bmm';
dm = dmm';
%
if xsflag
   am = mksys(am,bm,cm,dm);
end
%
% ------ End of SFR.M ---- RYC/MGS 7/85 %
