# v_lpcrr2am

## PURPOSE

V_LPCRR2AM Convert autocorrelation coefs to ar coef matrix [AM,EM]=(RR)

## SYNOPSIS

function [am,em]=v_lpcrr2am(rr);

## DESCRIPTION

```V_LPCRR2AM Convert autocorrelation coefs to ar coef matrix [AM,EM]=(RR)
AM is a 3-dimensional matrix of size (p+1,p+1,nf) where p is the lpc order
and nf the number of frames.
The matrix AM(:,:,*) is upper triangular with 1's on the main diagonal
and contains the lpc coefficients for all orders from p down to 0.

For lpc order p+1-r, AM(r,r:p+1,*), AM(p+1:-1:r,p+1,*) and EM(*,r) contain
the lpc coefficients, reflection coefficients and the residual energy respectively.

If A=am(:,:,*), R=toeplitz(rr(*,:)) and E=diag(em(*,:)), then
A*R*A'=E; inv(R)=A'*(1/E)*A; A*R is lower triangular with the same diagonal as E

This routine is equivalent to: c=chol(inv(toeplitz(rr))); d=diag(c).^-1; em=d.^2; am=diag(d)*c```

## CROSS-REFERENCE INFORMATION

This function calls:
This function is called by:

## SOURCE CODE

```0001 function [am,em]=v_lpcrr2am(rr);
0002 %V_LPCRR2AM Convert autocorrelation coefs to ar coef matrix [AM,EM]=(RR)
0003 %AM is a 3-dimensional matrix of size (p+1,p+1,nf) where p is the lpc order
0004 %and nf the number of frames.
0005 %The matrix AM(:,:,*) is upper triangular with 1's on the main diagonal
0006 %and contains the lpc coefficients for all orders from p down to 0.
0007 %
0008 %For lpc order p+1-r, AM(r,r:p+1,*), AM(p+1:-1:r,p+1,*) and EM(*,r) contain
0009 %the lpc coefficients, reflection coefficients and the residual energy respectively.
0010 %
0011 %If A=am(:,:,*), R=toeplitz(rr(*,:)) and E=diag(em(*,:)), then
0012 % A*R*A'=E; inv(R)=A'*(1/E)*A; A*R is lower triangular with the same diagonal as E
0013 %
0014 % This routine is equivalent to: c=chol(inv(toeplitz(rr))); d=diag(c).^-1; em=d.^2; am=diag(d)*c
0015
0016 %      Copyright (C) Mike Brookes 1997
0017 %      Version: \$Id: v_lpcrr2am.m 10865 2018-09-21 17:22:45Z dmb \$
0018 %
0019 %   VOICEBOX is a MATLAB toolbox for speech processing.
0021 %
0022 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0023 %   This program is free software; you can redistribute it and/or modify
0025 %   the Free Software Foundation; either version 2 of the License, or
0026 %   (at your option) any later version.
0027 %
0028 %   This program is distributed in the hope that it will be useful,
0029 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0030 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0031 %   GNU General Public License for more details.
0032 %
0033 %   You can obtain a copy of the GNU General Public License from
0034 %   http://www.gnu.org/copyleft/gpl.html or by writing to
0035 %   Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA.
0036 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0037
0038 [nf,p1]=size(rr);
0039 p=p1-1;
0040 p2=p1+1;
0041 am=zeros(nf,p1,p1);
0042 em=zeros(nf,p1);
0043 am(:,p1,p1)=1;
0044 em(:,p1)=rr(:,1);
0045 ar=ones(nf,p1);
0046 ar(:,2) = -rr(:,2)./rr(:,1);
0047 e = rr(:,1).*(ar(:,2).^2-1);
0048 for n = 2:p
0049    q=p2-n;
0050    em(:,q)=-e;
0051    am(:,q:p1,q)=ar(:,1:n);
0052    k = (rr(:,n+1)+sum(rr(:,n:-1:2).*ar(:,2:n),2)) ./ e;
0053    ar(:,2:n) = ar(:,2:n)+k(:,ones(1,n-1)).*ar(:,n:-1:2);
0054    ar(:,n+1) = k;
0055    e = e.*(1-k.^2);
0056 end
0057 em(:,1)=-e;
0058 am(:,:,1)=ar;
0059 am=permute(am,[3 2 1]);
0060```