(f, K, inf=None, sup=None, exclude=None)
return _winding_number(T, F)
Count all roots in [u + v*I, s + t*I] rectangle using Collins-Krandick algorithm.
Count all roots in [u + v*I, s + t*I] rectangle using Collins-Krandick algorithm.
Count all roots in [ u + v * I s + t * I ] rectangle using Collins - Krandick algorithm .
def dup_count_complex_roots(f, K, inf=None, sup=None, exclude=None):
    """Count all roots in [u + v*I, s + t*I] rectangle using Collins-Krandick algorithm. """
    if not K.is_ZZ and not K.is_QQ:
        raise DomainError("complex root counting is not supported over %s" % K)

    if K.is_ZZ:
        R, F = K, K.get_field()
    else:
        R, F = K.get_ring(), K

    f = dup_convert(f, K, F)

    if inf is None or sup is None:
        n, lc = dup_degree(f), abs(dup_LC(f, F))
        B = 2*max([ F.quo(abs(c), lc) for c in f ])

    if inf is None:
        (u, v) = (-B, -B)
    else:
        (u, v) = inf

    if sup is None:
        (s, t) = (+B, +B)
    else:
        (s, t) = sup

    f1, f2 = dup_real_imag(f, F)

    f1L1F = dmp_eval_in(f1, v, 1, 1, F)
    f2L1F = dmp_eval_in(f2, v, 1, 1, F)

    _, f1L1R = dup_clear_denoms(f1L1F, F, R, convert=True)
    _, f2L1R = dup_clear_denoms(f2L1F, F, R, convert=True)

    f1L2F = dmp_eval_in(f1, s, 0, 1, F)
    f2L2F = dmp_eval_in(f2, s, 0, 1, F)

    _, f1L2R = dup_clear_denoms(f1L2F, F, R, convert=True)
    _, f2L2R = dup_clear_denoms(f2L2F, F, R, convert=True)

    f1L3F = dmp_eval_in(f1, t, 1, 1, F)
    f2L3F = dmp_eval_in(f2, t, 1, 1, F)

    _, f1L3R = dup_clear_denoms(f1L3F, F, R, convert=True)
    _, f2L3R = dup_clear_denoms(f2L3F, F, R, convert=True)

    f1L4F = dmp_eval_in(f1, u, 0, 1, F)
    f2L4F = dmp_eval_in(f2, u, 0, 1, F)

    _, f1L4R = dup_clear_denoms(f1L4F, F, R, convert=True)
    _, f2L4R = dup_clear_denoms(f2L4F, F, R, convert=True)

    S_L1 = [f1L1R, f2L1R]
    S_L2 = [f1L2R, f2L2R]
    S_L3 = [f1L3R, f2L3R]
    S_L4 = [f1L4R, f2L4R]

    I_L1 = dup_isolate_real_roots_list(S_L1, R, inf=u, sup=s, fast=True, basis=True, strict=True)
    I_L2 = dup_isolate_real_roots_list(S_L2, R, inf=v, sup=t, fast=True, basis=True, strict=True)
    I_L3 = dup_isolate_real_roots_list(S_L3, R, inf=u, sup=s, fast=True, basis=True, strict=True)
    I_L4 = dup_isolate_real_roots_list(S_L4, R, inf=v, sup=t, fast=True, basis=True, strict=True)

    I_L3 = _reverse_intervals(I_L3)
    I_L4 = _reverse_intervals(I_L4)

    Q_L1 = _intervals_to_quadrants(I_L1, f1L1F, f2L1F, u, s, F)
    Q_L2 = _intervals_to_quadrants(I_L2, f1L2F, f2L2F, v, t, F)
    Q_L3 = _intervals_to_quadrants(I_L3, f1L3F, f2L3F, s, u, F)
    Q_L4 = _intervals_to_quadrants(I_L4, f1L4F, f2L4F, t, v, F)

    T = _traverse_quadrants(Q_L1, Q_L2, Q_L3, Q_L4, exclude=exclude)

    return _winding_number(T, F)
def dup_count_complex_roots ( f , K , inf = None , sup = None , exclude = None ) : if not K . is_ZZ and not K . is_QQ : raise DomainError ( "complex root counting is not supported over %s" % K ) if K . is_ZZ : R , F = K , K . get_field ( ) else : R , F = K . get_ring ( ) , K f = dup_convert ( f , K , F ) if inf is None or sup is None : n , lc = dup_degree ( f ) , abs ( dup_LC ( f , F ) ) B = 2 * max ( [ F . quo ( abs ( c ) , lc ) for c in f ] ) if inf is None : ( u , v ) = ( - B , - B ) else : ( u , v ) = inf if sup is None : ( s , t ) = ( + B , + B ) else : ( s , t ) = sup f1 , f2 = dup_real_imag ( f , F ) f1L1F = dmp_eval_in ( f1 , v , 1 , 1 , F ) f2L1F = dmp_eval_in ( f2 , v , 1 , 1 , F ) _ , f1L1R = dup_clear_denoms ( f1L1F , F , R , convert = True ) _ , f2L1R = dup_clear_denoms ( f2L1F , F , R , convert = True ) f1L2F = dmp_eval_in ( f1 , s , 0 , 1 , F ) f2L2F = dmp_eval_in ( f2 , s , 0 , 1 , F ) _ , f1L2R = dup_clear_denoms ( f1L2F , F , R , convert = True ) _ , f2L2R = dup_clear_denoms ( f2L2F , F , R , convert = True ) f1L3F = dmp_eval_in ( f1 , t , 1 , 1 , F ) f2L3F = dmp_eval_in ( f2 , t , 1 , 1 , F ) _ , f1L3R = dup_clear_denoms ( f1L3F , F , R , convert = True ) _ , f2L3R = dup_clear_denoms ( f2L3F , F , R , convert = True ) f1L4F = dmp_eval_in ( f1 , u , 0 , 1 , F ) f2L4F = dmp_eval_in ( f2 , u , 0 , 1 , F ) _ , f1L4R = dup_clear_denoms ( f1L4F , F , R , convert = True ) _ , f2L4R = dup_clear_denoms ( f2L4F , F , R , convert = True ) S_L1 = [ f1L1R , f2L1R ] S_L2 = [ f1L2R , f2L2R ] S_L3 = [ f1L3R , f2L3R ] S_L4 = [ f1L4R , f2L4R ] I_L1 = dup_isolate_real_roots_list ( S_L1 , R , inf = u , sup = s , fast = True , basis = True , strict = True ) I_L2 = dup_isolate_real_roots_list ( S_L2 , R , inf = v , sup = t , fast = True , basis = True , strict = True ) I_L3 = dup_isolate_real_roots_list ( S_L3 , R , inf = u , sup = s , fast = True , basis = True , strict = True ) I_L4 = dup_isolate_real_roots_list ( S_L4 , R , inf = v , sup = t , fast = True , basis = True , strict = True ) I_L3 = _reverse_intervals ( I_L3 ) I_L4 = _reverse_intervals ( I_L4 ) Q_L1 = _intervals_to_quadrants ( I_L1 , f1L1F , f2L1F , u , s , F ) Q_L2 = _intervals_to_quadrants ( I_L2 , f1L2F , f2L2F , v , t , F ) Q_L3 = _intervals_to_quadrants ( I_L3 , f1L3F , f2L3F , s , u , F ) Q_L4 = _intervals_to_quadrants ( I_L4 , f1L4F , f2L4F , t , v , F ) T = _traverse_quadrants ( Q_L1 , Q_L2 , Q_L3 , Q_L4 , exclude = exclude ) return _winding_number ( T , F )