(f, u, K=None, zero=False)
return result
Convert a ``K[X]`` polynomial to a ``dict````.

    Examples
    ========

    >>> from sympy.polys.densebasic import dmp_to_dict

    >>> dmp_to_dict([[1, 0], [], [2, 3]], 1)
    {(0, 0): 3, (0, 1): 2, (2, 1): 1}
    >>> dmp_to_dict([], 0)
    {}
Convert a ``K[X]`` polynomial to a ``dict````.
Convert a K [ X ] polynomial to a dict .
def dmp_to_dict(f, u, K=None, zero=False):
    """
    Convert a ``K[X]`` polynomial to a ``dict````.

    Examples
    ========

    >>> from sympy.polys.densebasic import dmp_to_dict

    >>> dmp_to_dict([[1, 0], [], [2, 3]], 1)
    {(0, 0): 3, (0, 1): 2, (2, 1): 1}
    >>> dmp_to_dict([], 0)
    {}

    """
    if not u:
        return dup_to_dict(f, K, zero=zero)

    if dmp_zero_p(f, u) and zero:
        return {(0,)*(u + 1): K.zero}

    n, v, result = dmp_degree(f, u), u - 1, {}

    if n == -oo:
        n = -1

    for k in xrange(0, n + 1):
        h = dmp_to_dict(f[n - k], v)

        for exp, coeff in h.items():
            result[(k,) + exp] = coeff

    return result
def dmp_to_dict ( f , u , K = None , zero = False ) : if not u : return dup_to_dict ( f , K , zero = zero ) if dmp_zero_p ( f , u ) and zero : return { ( 0 , ) * ( u + 1 ) : K . zero } n , v , result = dmp_degree ( f , u ) , u - 1 , { } if n == - oo : n = - 1 for k in xrange ( 0 , n + 1 ) : h = dmp_to_dict ( f [ n - k ] , v ) for exp , coeff in h . items ( ) : result [ ( k , ) + exp ] = coeff return result