function [up,sp,vp,Gip] = CompPolDir( G, p );
   [A,B,C,D] = unpck( G );
   sd = svd( D );
   ms = max( max( sd ) );
   if ms == 0
      disp( 'Making system proper by adding a small term in D.' );
      Dm = [0.0001 0; 0 0.0001];
      G = pck( A, B, C, Dm );
   end
   Gi= minv( G );
%   Gi = sysbal( Gi );
   [Ai,Bi,Ci,Di] = unpck( Gi );
   Gip = Ci*inv(eye(size(Ai))*p-Ai)*Bi+Di;
   [up, sp, vp] = svd( Gip );
end
