function [l,p] = rlsppd(b_num,a_den,char_poly)
%RLSPPD	Discrete pole placement (difference operator formulation)
%
%	Computes the controller polynomials given the discrete time
%	system defined by the polynomials A and B, and the desired poles
%	of the closed loop defined by Am.
%
%	The control law is defined by:
%	     -1    -1       -1    -1      -1       -1    -1     -1
%	( L(z  )A(z  ) + B(z  )P(z  ) )y(z  ) = B(z  )P(z  )uc(z  )
%
%	    -1    -1        -1     -1
%	Am(z  )y(z  ) = Bm(z  )uc(z  )
%
%	where:
%
%		B :	plant numerator polynomial
%		A :	plant denominator polynomial
%		P :	controller numerator polynomial
%		L :	controller denominator polynomial
%
%	The solution for L and P given Am is defined by:
%		  -1
%	[l p] = Me  * Am
%
%	where
%
%	     | a0             b0             |
%	     | a1             b1             |
%	     | .              .              |
%	     | .              .              |
%	     | .              .              |
%	Me = | an             bn             |
%	     |     an             bn         |
%	     |         an             bn     |
%	     |            an              bn |
%
%	See also: pp 146-148, "Adaptive Filtering, Prediction, and Control",
%	G. C. Goodwin & K. S. Sin.
%

%	Rick Spada 6-17-92
%	Copyright (c) 1990-94 by The MathWorks, Inc.

%

	n = length (a_den) - 1;
	Me = zeros (2 * n);
	for i = 1:n
	    Me(i:i+n,i) = a_den';
	    Me(i:i+n,i+n) = b_num';
	end
%
	if rcond (Me) > eps
		lp = Me \ char_poly';
		l = lp(1:n)';
		p = lp(n+1:2*n)';
	else
		disp('The eliminant matrix is singular.');
		l = [];
		p = [];
	end
%
end





