def arcovar_marple(x, order):
assert len(x) >= order, "<STR_LIT>"<EOL>x = np.array(x)<EOL>N = len(x)<EOL>r0 = sum(abs(x)**<NUM_LIT>)<EOL>r1 = abs(x[<NUM_LIT:0>])**<NUM_LIT:2><EOL>rN = abs(x[N-<NUM_LIT:1>])**<NUM_LIT:2><EOL>pf = r0 - r1<EOL>pb = r0 - rN<EOL>delta = <NUM_LIT:1.> - r1 / r0<EOL>gamma = <NUM_LIT:1.> - rN / r0<EOL>c = np.zeros(N, dtype=complex)<EOL>d = np.zeros(N, dtype=complex)<EOL>r = np.zeros(N, dtype=complex)<EOL>af = np.zeros(N, dtype=complex)<EOL>ab = np.zeros(N, dtype=complex)<EOL>c[<NUM_LIT:0>] = x[N-<NUM_LIT:1>].conjugate() / r0<EOL>d[<NUM_LIT:0>] = x[<NUM_LIT:0>].conjugate() / r0<EOL>if order == <NUM_LIT:0>:<EOL><INDENT>pf = r0 / float(N)<EOL>pb = pf<EOL>return af, pf, ab, pb, <NUM_LIT:0><EOL><DEDENT>pbv = []<EOL>for m in range(<NUM_LIT:0>, order+<NUM_LIT:1>):<EOL><INDENT>logging.debug('<STR_LIT>', m)<EOL>logging.debug(c[<NUM_LIT:0>:<NUM_LIT:2>])<EOL>logging.debug(d[<NUM_LIT:0>:<NUM_LIT:2>])<EOL>r1 = <NUM_LIT:1.>/pf<EOL>r2 = <NUM_LIT:1.>/pb<EOL>r3 = <NUM_LIT:1.>/delta<EOL>r4 = <NUM_LIT:1.>/gamma<EOL>temp = <NUM_LIT:0.>+<NUM_LIT><EOL>for k in range(m+<NUM_LIT:1>, N):<EOL><INDENT>temp = temp + x[k]*x[k-m-<NUM_LIT:1>].conjugate()<EOL><DEDENT>r[m] =  temp.conjugate()<EOL>theta = x[<NUM_LIT:0>] * c[m]<EOL>if m == <NUM_LIT:0>:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>for k in range(<NUM_LIT:0>, m):<EOL><INDENT>theta = theta + x[m-k] * c[k]                   <EOL>r[k] = r[k] - x[N-m-<NUM_LIT:1>] * x[N-m+k].conjugate() <EOL>temp = temp + af[m-k-<NUM_LIT:1>] * r[k].conjugate()<EOL><DEDENT><DEDENT>"""<STR_LIT>"""<EOL>c1 = -temp * r2<EOL>c2 = -r1 * temp.conjugate()<EOL>c3 = theta * r3<EOL>c4 = r4 *theta.conjugate()<EOL>af[m] = c1                    <EOL>ab[m] = c2                    <EOL>save = c[m]<EOL>c[m] = save + c3*d[m]<EOL>d[m] = d[m] + c4*save<EOL>if m == <NUM_LIT:0>:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>for k in range(<NUM_LIT:0>, m):<EOL><INDENT>save = af[k]<EOL>af[k] = save + c1 * ab[m-k-<NUM_LIT:1>] <EOL>ab[m-k-<NUM_LIT:1>] = ab[m-k-<NUM_LIT:1>] + c2 * save   <EOL>save = c[k]<EOL>c[k] = save + c3*d[k]       <EOL>d[k] = d[k] + c4*save       <EOL><DEDENT><DEDENT>r5 = temp.real**<NUM_LIT:2> + temp.imag**<NUM_LIT:2><EOL>pf = pf - r5*r2         <EOL>pb = pb - r5*r1         <EOL>r5 = theta.real**<NUM_LIT:2> + theta.imag**<NUM_LIT:2><EOL>delta = delta - r5*r4               <EOL>gamma = gamma - r5*r3               <EOL>if m != order-<NUM_LIT:1>:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>pf = pf / float(N-m-<NUM_LIT:1>)<EOL>pb = pb / float(N-m-<NUM_LIT:1>)<EOL>break<EOL><DEDENT>if pf > <NUM_LIT:0> and pb > <NUM_LIT:0>:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>ValueError("<STR_LIT>")<EOL><DEDENT>if (delta > <NUM_LIT:0.> and delta <=<NUM_LIT:1> and gamma > <NUM_LIT:0.> and gamma <=<NUM_LIT:1>):<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>ValueError("<STR_LIT>")<EOL><DEDENT>r1 = <NUM_LIT:1.>/pf<EOL>r2 = <NUM_LIT:1.>/pb<EOL>r3 = <NUM_LIT:1.>/delta<EOL>r4 = <NUM_LIT:1.>/gamma<EOL>ef = x[m+<NUM_LIT:1>]<EOL>eb = x[(N-<NUM_LIT:1>)-m-<NUM_LIT:1>]<EOL>for k in range(<NUM_LIT:0>,m+<NUM_LIT:1>):<EOL><INDENT>ef = ef + af[k] * x[m-k]             <EOL>eb = eb + ab[k] * x[N-m+k-<NUM_LIT:1>]                   <EOL><DEDENT>c1 = ef*r3<EOL>c2 = eb*r4<EOL>c3 = eb.conjugate() * r2<EOL>c4 = ef.conjugate() * r1<EOL>for k in range(m, -<NUM_LIT:1>, -<NUM_LIT:1>):<EOL><INDENT>save = af[k]<EOL>af[k] = save + c1 * d[k]                    <EOL>d[k+<NUM_LIT:1>] = d[k] + c4 * save                    <EOL>save = ab[k]<EOL>ab[k] = save + c2 * c[m-k]                 <EOL>c[m-k] = c[m-k] + c3 * save              <EOL><DEDENT>c[m+<NUM_LIT:1>] = c3<EOL>d[<NUM_LIT:0>] = c4<EOL>r5 = ef.real**<NUM_LIT:2> + ef.imag**<NUM_LIT:2><EOL>pf = pf - r5 * r3                              <EOL>delta = delta-r5 * r1                        <EOL>r5 = eb.real**<NUM_LIT:2> + eb.imag**<NUM_LIT:2><EOL>pb = pb - r5 * r4                              <EOL>gamma = gamma-r5*r2                        <EOL>pbv.append(pb)<EOL>if (pf > <NUM_LIT:0.> and pb > <NUM_LIT:0.>):<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>ValueError("<STR_LIT>")<EOL><DEDENT>if (delta > <NUM_LIT:0.> and delta <= <NUM_LIT:1.>) and (gamma > <NUM_LIT:0.> and gamma <= <NUM_LIT:1.>):<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>ValueError("<STR_LIT>")<EOL><DEDENT><DEDENT>return af, pf, ab, pb, pbv<EOL>
r"""Estimate AR model parameters using covariance method

    This implementation is based on [Marple]_. This code is far more
    complicated and slower than :func:`arcovar` function, which is now the official version.
    See :func:`arcovar` for a detailed description of Covariance method.

    This function should be used in place of arcovar only if order<=4, for
    which :func:`arcovar` does not work.

    Fast algorithm for the solution of the covariance least squares normal
    equations from Marple.

    :param array X:  Array of complex data samples
    :param int oder: Order of linear prediction model

    :return:
        * AF   - Array of complex forward linear prediction coefficients
        * PF   - Real forward linear prediction variance at order IP
        * AB   - Array of complex backward linear prediction coefficients
        * PB   - Real backward linear prediction variance at order IP
        * PV   - store linear prediction coefficients

    .. note:: this code and the original code in Marple diverge for ip>10.
        it seems that this is related to single precision used with
        complex type in fortran whereas numpy uses double precision for
        complex type.

    :validation: the AR parameters are the same as those returned by
        a completely different function :func:`arcovar`.

    :References: [Marple]_