%-----------------------------------------------------------------------
  function R = PadeCoeff(p,q)
% R = PadeCoeff(p,q)
% p and q are nonnegative integers and R is a representation of the
% (p,q)-Pade approximation N(x)/D(x) to exp(x):
% R.num   is a row (p+1)-vector whose entries are the coefficients of the
%         p-degree numerator   polynomial N(x).
% R.den   is a row (q+1)-vector whose entries are the coefficients of the
%         q-degree denominator polynomial D(x).
% Thus,
%               R.num[1] + R.num[2]x +R.num[3]x^2
%              -----------------------------------
%                       R.den[1] + R.den[2]x
% is the (2,1) Pade approximation.
p = p-1; q = q-1;
   a(1)   = 1;
for k=1:p,
   a(k+1) =  a(k)*(p-k+1)/(k*(p+q-k+1));
end
   b(1)   = 1;
for k=1:q,
   b(k+1) = -b(k)*(q-k+1)/(k*(p+q-k+1));
end
R = struct('num',a,'den',b); 
