## Copyright (C) 2013 Leonardo Araujo
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; If not, see .
## -*- texinfo -*-
## @deftypefn {Function File} {[@var{a}, @var{e}] = } lpc (@var{x}, @var{p})
## @deftypefnx {Function File} {@var{a} = } lpc (@var{x}, @var{p})
##
## Determines the forward linear predictor by minimizing the prediction error
## in the least squares sense. Use the Durbin-Levinson algorithm to solve
## the Yule-Walker equations obtained by the autocorrelation of the input signal.
##
## @table @var
## @item x
## data vector used to estimate the model
## @item p
## the order of the linear prediction polynomial
## @item a
## predictor coefficientes
## @item e
## prediction error
## @end table
## @end deftypefn
## @seealso{aryule,levinson}
function [a,e] = lpc(x,p)
if ( nargin~=2 )
print_usage;
elseif ( ~isvector(x) || length(x)<2 )
error( 'lpc: arg 1 (x) must be vector of length >1' );
elseif ( ~isscalar(p) || fix(p)~=p || p > length(x)-1 || p < 1)
error( 'lpc: arg 2 (p) must be an integer >0 and