function [p,gain] = butt (ap,as,oms)
%BUTT	Butterworth analog lowpass filter prototype.
%	[p,gain] = BUTT(ap,as,oms) returns poles and gain
%	of a normalized prototype Butterworth analog lowpass filter transfer function
%	with ap decibels on the passband edge, as decibels is minimal
%	attenuation on the start of the stopband and oms is normalized 
%	frequency of the start of the stopband.
%
%	See also BUTTER, CHEB, INVCHEBY, INVCHEBY2, CHEB1AP, and CHEB2AP.
%
%	Author(s): J. Vrbata 14.9.2000
%	This is a version for GNU OCTAVE 2.0.14

% Secondary parameters

eps=sqrt(10^(0.1*ap)-1);
k=1/oms;
k1=1/sqrt((10^(0.1*as)-1)/(10^(0.1*ap)-1));

pom=(log10(1/k1))/(log10(1/k));
if (pom-floor(pom)>0) n=floor(pom+1); else n=floor(pom); end

asnew=10*log10(1+(eps^2/k1^2));
if (ceil(n/2)==n/2) m=floor(n/2); else m=floor((n-1)/2); end

for f=1:n;
	alfa=-1/(eps^(1/n))*sin(((2*f-1)/n)*(pi/2));
	beta=1/(eps^(1/n))*cos(((2*f-1)/n)*(pi/2));
	p(f)=alfa+beta*i;
	%p(n-f+1)=alfa-beta*i;
end;

gain=1/eps;
