# v_lpcar2pp

## PURPOSE

V_LPCAR2PP LPC: Convert ar filter to power spectrum polynomial in cos(w) PP=(AR)

## SYNOPSIS

function pp=v_lpcar2pp(ar)

## DESCRIPTION

    V_LPCAR2PP LPC: Convert ar filter to power spectrum polynomial in cos(w) PP=(AR)
     the pp is a polynomial such that |polyval(ar,e^jw)|^2 = polyval(pp,cos(w))

## CROSS-REFERENCE INFORMATION

This function calls:

This function is called by:

## SOURCE CODE

    0001 function pp=v_lpcar2pp(ar)
    0002 %V_LPCAR2PP LPC: Convert ar filter to power spectrum polynomial in cos(w) PP=(AR)
    0003 % the pp is a polynomial such that |polyval(ar,e^jw)|^2 = polyval(pp,cos(w))
    0004
    0005 %      Copyright (C) Mike Brookes 1998
    0006 %      Version: $Id: v_lpcar2pp.m 10865 2018-09-21 17:22:45Z dmb $
    0007 %
    0008 %   VOICEBOX is a MATLAB toolbox for speech processing.
    0009 %   Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html
    0010 %
    0011 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    0012 %   This program is free software; you can redistribute it and/or modify
    0013 %   it under the terms of the GNU Lesser General Public License as published by
    0014 %   the Free Software Foundation; either version 3 of the License, or
    0015 %   (at your option) any later version.
    0016 %
    0017 %   This program is distributed in the hope that it will be useful,
    0018 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
    0019 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    0020 %   GNU Lesser General Public License for more details.
    0021 %
    0022 %   You can obtain a copy of the GNU Lesser General Public License from
    0023 %   https://www.gnu.org/licenses/ .
    0024 %
    0025 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    0026
    0027 persistent tp;
    0028 [nf,p1]=size(ar);
    0029 ra=zeros(nf,p1);
    0030 for i=1:p1
    0031    ra(:,i)=sum(ar(:,1:p1+1-i).*ar(:,i:p1),2);
    0032 end
    0033 % we check here if p is the same as before and reuse the tp matrix
    0034 if size(tp,1)~=p1
    0035    p=p1-1;
    0036    % chebyshev polynomials up to order p
    0037    tp=zeros(p1,p1);
    0038    tp(1,p1)=2;
    0039    tp(2,p)=2;
    0040    for i=3:p1
    0041       tp(i,p+2-i:p)=2*tp(i-1,p+3-i:p1)-tp(i-2,p+2-i:p);
    0042       tp(i,p1)=-tp(i-2,p1);
    0043    end
    0044    tp(1,p1)=1;
    0045 end
    0046 pp=ra*tp;