 function C = compan(p)

       p = p(:).';        % make sure p is a row
       n = max(size(p));

       if  n > 1
            C = zeros(n,n);
            for i=  1:n-1, C(i,i+1)=1; end
       else
            C = 1;
       end
       C(n,:) = -p(n:-1:1);