def ellipap(N, rp, rs):
if abs(int(N)) != N:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>elif N == <NUM_LIT:0>:<EOL><INDENT>return numpy.array([]), numpy.array([]), <NUM_LIT:10>**(-rp/<NUM_LIT:20>)<EOL><DEDENT>elif N == <NUM_LIT:1>:<EOL><INDENT>p = -sqrt(<NUM_LIT:1.0> / (<NUM_LIT:10> ** (<NUM_LIT:0.1> * rp) - <NUM_LIT:1.0>))<EOL>k = -p<EOL>z = []<EOL>return asarray(z), asarray(p), k<EOL><DEDENT>eps = numpy.sqrt(<NUM_LIT:10> ** (<NUM_LIT:0.1> * rp) - <NUM_LIT:1>)<EOL>ck1 = eps / numpy.sqrt(<NUM_LIT:10> ** (<NUM_LIT:0.1> * rs) - <NUM_LIT:1>)<EOL>ck1p = numpy.sqrt(<NUM_LIT:1> - ck1 * ck1)<EOL>if ck1p == <NUM_LIT:1>:<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>val = special.ellipk([ck1 * ck1, ck1p * ck1p])<EOL>if abs(<NUM_LIT:1> - ck1p * ck1p) < EPSILON:<EOL><INDENT>krat = <NUM_LIT:0><EOL><DEDENT>else:<EOL><INDENT>krat = N * val[<NUM_LIT:0>] / val[<NUM_LIT:1>]<EOL><DEDENT>m = optimize.fmin(_kratio, [<NUM_LIT:0.5>], args=(krat,), maxfun=<NUM_LIT>, maxiter=<NUM_LIT>,<EOL>disp=<NUM_LIT:0>)<EOL>if m < <NUM_LIT:0> or m > <NUM_LIT:1>:<EOL><INDENT>m = optimize.fminbound(_kratio, <NUM_LIT:0>, <NUM_LIT:1>, args=(krat,), maxfun=<NUM_LIT>,<EOL>maxiter=<NUM_LIT>, disp=<NUM_LIT:0>)<EOL><DEDENT>capk = special.ellipk(m)<EOL>j = numpy.arange(<NUM_LIT:1> - N % <NUM_LIT:2>, N, <NUM_LIT:2>)<EOL>jj = len(j)<EOL>[s, c, d, phi] = special.ellipj(j * capk / N, m * numpy.ones(jj))<EOL>snew = numpy.compress(abs(s) > EPSILON, s, axis=-<NUM_LIT:1>)<EOL>z = <NUM_LIT:1.0> / (sqrt(m) * snew)<EOL>z = <NUM_LIT> * z<EOL>z = numpy.concatenate((z, conjugate(z)))<EOL>r = optimize.fmin(_vratio, special.ellipk(m), args=(<NUM_LIT:1.> / eps, ck1p * ck1p),<EOL>maxfun=<NUM_LIT>, maxiter=<NUM_LIT>, disp=<NUM_LIT:0>)<EOL>v0 = capk * r / (N * val[<NUM_LIT:0>])<EOL>[sv, cv, dv, phi] = special.ellipj(v0, <NUM_LIT:1> - m)<EOL>p = -(c * d * sv * cv + <NUM_LIT> * s * dv) / (<NUM_LIT:1> - (d * sv) ** <NUM_LIT>)<EOL>if N % <NUM_LIT:2>:<EOL><INDENT>newp = numpy.compress(abs(p.imag) > EPSILON *<EOL>numpy.sqrt(numpy.sum(p * numpy.conjugate(p),<EOL>axis=<NUM_LIT:0>).real),<EOL>p, axis=-<NUM_LIT:1>)<EOL>p = numpy.concatenate((p, conjugate(newp)))<EOL><DEDENT>else:<EOL><INDENT>p = numpy.concatenate((p, conjugate(p)))<EOL><DEDENT>k = (numpy.prod(-p, axis=<NUM_LIT:0>) / numpy.prod(-z, axis=<NUM_LIT:0>)).real<EOL>if N % <NUM_LIT:2> == <NUM_LIT:0>:<EOL><INDENT>k = k / numpy.sqrt((<NUM_LIT:1> + eps * eps))<EOL><DEDENT>return z, p, k<EOL>
Return (z,p,k) of Nth order elliptic analog lowpass filter.

    The filter is a normalized prototype that has `rp` decibels of ripple
    in the passband and a stopband `rs` decibels down.

    The filter's angular (e.g. rad/s) cutoff frequency is normalized to 1,
    defined as the point at which the gain first drops below ``-rp``.

    References
    ----------
    Lutova, Tosic, and Evans, "Filter Design for Signal Processing", Chapters 5
    and 12.