% POLE2RESIDUE finds the residues if the poles are known.
%
%  a = POLE2RESIDUE(b) finds the residues a of a simple pole expansion
%  when the poles b are known, 
%
%               1                      a(1)     a(2)           a(N)
%  -------------------------------- = ------ + ------ + ... + ------
%  (z-b(1))*(z-b(2))* ... *(z-b(N))   z-b(1)   z-b(2)         z-b(N)

function residues = pole2residue(poles)

poles=poles(:);
N = length(poles);
pdm = ones(N,1)*poles.' - poles*ones(1,N); % pdm: 'pole difference matrix'
for ii = 1:N
  pdm(ii,ii) = 1;
end
residues = 1./prod(pdm);
