def sdm_to_vector(f, gens, K, n=None):
 dic = sdm_to_dict(f)
 dics = {}
 for (k, v) in dic.items():
  dics.setdefault(k[0], []).append((k[1:], v))
 n = (n or len(dics))
 res = []
 for k in range(n):
  if (k in dics):
   res.append(Poly(dict(dics[k]), gens=gens, domain=K).as_expr())
  else:
   res.append(S.Zero)
 return res

def sdm_to_vector ( f , gens , K , n = None ) : dic = sdm_to_dict ( f ) dics = { } for ( k , v ) in dic . items ( ) : dics . setdefault ( k [ 0 ] , [ ] ) . append ( ( k [ 1 : ] , v ) ) n = ( n or len ( dics ) ) res = [ ] for k in range ( n ) : if ( k in dics ) : res . append ( Poly ( dict ( dics [ k ] ) , gens = gens , domain = K ) . as_expr ( ) ) else : res . append ( S . Zero ) return res
convert sdm f into a list of polynomial expressions .