function c=a2c0(a,alpha,p,cp);

%Function A2C0: Computation of cepstral coeficients from AR coeficients.
%
%Usage: c=a2c0(a,alpha,p,cp);
%   a   - vector of AR coefficients ( without a[0] = 1 )
%   p   - order of AR model ( number of coefficients without a[0] )
%   alpha - square error of forward prediction
%   c   - vector of cepstral coefficients ( with c[0] )
%   cp  - order of cepstral model ( number of coefficients without c[0] )


%                               Made by PP
%                              26 March 2023
%                         CVUT FEL K331, Prague

% Computation of coefficients c[1] ... c[cp]

for n=1:cp,

  sum=0;

  if n<p+1,
    for k=1:n-1,
      sum=sum+(n-k)*c(n-k)*a(k);
    end;
    c(n)=-a(n)-sum/n;
  else
    for k=1:p,
      sum=sum+(n-k)*c(n-k)*a(k);
    end;
    c(n)=-sum/n;
  end;

end;

% Computation of coefficient c[0]


c=[2*log(sqrt(alpha)) c];


c=c(:)'; 
