function fhndls = latcmaparse
%LATCMAPARSE  Parser for LATCMA filter objects.
%   FHNDLS = LATCMAPARSE returns a 3 element vector of function handles, 
%   FHNDLS, that point to the three functions required by DFILTPARSE
%   when called form any DFILT constructor.
%
%   For more information on what the 3 functions do, see the help for
%   DFILTPARSE.

%   Author(s): R. Losada
%   Copyright 1988-2000 The MathWorks, Inc.
%   $Revision: 1.3 $  $Date: 2000/06/13 21:22:53 $ 

fhndls = [@latcmadefaultfilt,@formcelllatcma,@checklatcma];

%----------------------------------------------------------------------------------
function coeffs = latcmadefaultfilt
%LATCMADEFAULTFILT  Default filter to use in latcma objects.

% Create a default min-phase filter
coeffs = {{0}};

%-----------------------------------------------------------------------------------
function [coeffs,msg] = formcelllatcma(varargin)
%FORMCELLLATCMA  Form cell array of coefficients of latcma object.

msg = '';

for n = 1:nargin
    coeffs{n} = {varargin{n}};
end

%----------------------------------------------------------------------------------
function [c,msg] = checklatcma(c)
%CHECKLATCMA Check if cell contains valid reflection coefficients.

msg = '';

k = c{1};

if isempty(k),
    k = 0;
end

if max(abs(k)) > 1,
    msg = 'All reflection coefficients must be less or equal to one.';
    return
end

% Check that k is a vector
if prod(size(k)) ~= max(size(k)),
    msg = 'Reflection coeffs. must be given in a vector.';
end
    
k = k(:); % Always store the coefficients as a column vector

c = {k};
