 v = np.roots(a)
    i = np.where(v != 0)
    vs = 0.5 * (np.sign(np.abs(v[i]) - 1) + 1)
    v[i] = (1 - vs) * v[i] + vs / np.conj(v[i])
    ind = np.where(a != 0)
    b = a[ind[0][0]] * np.poly(v)

    # Return only real coefficients if input was real:
    if not(np.sum(np.imag(a))):
        b = np.real(b)

    return b


def numf(h, a, nb):
    &#34;&#34;&#34;Get numerator B given impulse-response h of B/A and denominator A.&#34;&#34;&#34;
    nh = np.max(h.size)
    xn = np.concatenate((1, np.zeros((1, n