function [PF,QF]= tf2lsf(A)
% [PF,QF] = tf2lsf(A)
%
% Convert direct-form LPC coefficients into line spectral frequencies.
%

% First, create coefficients of the polynomials P and Q
Pcofs = [A 0] + [0 fliplr(A)];
Qcofs = [A 0] - [0 fliplr(A)];

% Second, find the imaginary part of the log roots of the polynomials
Prts = sort(angle(roots(Pcofs)));
Qrts = sort(angle(roots(Qcofs)));

% Finally, pick out the positive roots
PF = Prts(Prts > 0 & Prts < pi)';
QF = Qrts(Qrts > 0 & Qrts < pi)';

