%
%   Function INPCPRFACT finds factorization such that G(s) = W(s)^{-1}*V(s),
%   where V(jw)^H*V(jw) = I, and both W and V are stable. That means
%   all RHP-zeros in V and all RHP-poles as RHP-zeros in W. 
%   System G must be square and have no jw-axis poles. 
%   This is performed by factorizing G^T(s) = N(s)*M^{-1}(s) with
%   INPCRPFACT. The filters are then given by N(s) = V^T(s) and
%   Q = M^T(s).
%
%   The outputs: Q, R, E, X and Xerr are outputs returned from OUTCRPFACT.
%
%   Reference: Morari M. ``Robust Process Control'', Prentice Hall 1989.
%

function [V, W, Wi, Q, R, E, X, Xerr] = inpcprfact( G, deps, epp )

   GT = transp(G);
   
   [N, M, Mi, Q, R, E, X, Xerr] = outcprfact( GT, deps, epp );
   
   V  = transp(N);
   W  = transp(M);
   Wi = transp(Mi);

end
