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 range(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 range ( 0 , ( n + 1 ) ) : h = dmp_to_dict ( f [ ( n - k ) ] , v ) for ( exp , coeff ) in h . items ( ) : result [ ( ( k , ) + exp ) ] = coeff return result
convert a k[x] polynomial to a dict .