function has = tospecifyord(h,hasmin)
%TOSPECIFYORD   Convert from minimum-order to specify order.

%   Copyright 1999-2017 The MathWorks, Inc.

% Get values from objects
wp = hasmin.Wpass;
ws = hasmin.Wstop;
rp = hasmin.Apass;
rs = hasmin.Astop;

str = h.MatchExactly;

eratio = sqrt((10^(rs/10)-1)/(10^(rp/10)-1));

w = ws/wp;

N = ceil(acosh(eratio)/acosh(w));

if N <=0
  error(message('signal:sigtools:fmethod:CannotDetermineFilterOrder'))
end

% Compute revised ripple
switch str
    case 'passband'
        % Do nothing
    case 'stopband'
        rp = 10*log10(1+(10^(rs/10)-1)/(cosh(N*acosh(w))^2));
    otherwise
        error(message('signal:fmethod:abstractcheby1:tospecifyord:InvalidParam'));
end

% Bandpass and bandstop filters must double the filter order
if doubleord(h), N = 2*N; end


if any(strcmpi(h.FilterStructure,{'cascadeallpass','cascadewdfallpass'}))
    % allpass implementation may require order to be increased 
    N = modifyord(h,N); 
end

has = fspecs.alppass(N,wp,rp);


% [EOF]
