function [y]=orthofilter(psi,u)
%----------------------------------------------------------------------------
% Usage:
%         y=orthofilter(psi,u)
%----------------------------------------------------------------------------
% Author: Juan Carlos Gomez
% Last modified: May 02, 2002
%----------------------------------------------------------------------------
% This function filters the signal 'u' with the orthonormal bases with 
% fixed poles at the locations given in vector 'psi'. The orthonormal
% bases are defined as
%
%                  sqrt(1 - |psi_0|^2)
%       B_0 (q) = ---------------------
%                       q - psi_0
%
%                  sqrt(1 - |psi_k|^2)                     1 - q psi_i^*
%       B_k (q) = --------------------- Prod_[i=0]^[k-1] ----------------
%                       q - psi_k                          q - psi_i
%       for k >= 1
%
%       psi=[psi_0,psi_1, ..., psi_{p-1)]     real stable poles
%		  y: matrix of filtered inputs. Each column of y is given by B_k(q)u(n)
%----------------------------------------------------------------------------
p=length(psi);
num1=sqrt(1-psi(1)^2);
den1=[1 -psi(1)];
num=num1;
den=den1;
y=dlsim(num,den,u);
for k=2:p
   numk=conv(num,[-psi(k-1) 1])*sqrt(1-psi(k)^2)/sqrt(1-psi(k-1)^2);
   denk=conv(den,[1 -psi(k)]);
   num=numk;
   den=denk;
   yk=dlsim(num,den,u);
   y=[y,yk];
end
