#NEWLINE# def deflate( f , * G ) : #NEWLINE# #INDENT# ring = f . ring #NEWLINE# polys = ( [ f ] + list ( G ) ) #NEWLINE# J = ( [ 0 ] * ring . ngens ) #NEWLINE# for p in polys : #NEWLINE# #INDENT# for monom in p . itermonoms ( ) : #NEWLINE# #INDENT# for ( i , m ) in enumerate ( monom ) : #NEWLINE# #INDENT# J [ i ] = igcd ( J [ i ] , m ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# for ( i , b ) in enumerate ( i ) : #NEWLINE# #INDENT# if ( not b ) : #NEWLINE# #INDENT# J [ i ] = 1 #NEWLINE# #UNINDENT# #UNINDENT# J = tuple ( J ) #NEWLINE# if all ( ( ( b == 1 ) for b in J ) ) : #NEWLINE# #INDENT# return ( J , polys ) #NEWLINE# #UNINDENT# H = [ ] #NEWLINE# for p in polys : #NEWLINE# #INDENT# h = ring . zero #NEWLINE# for ( I , coeff ) in p . iterterms ( ) : #NEWLINE# #INDENT# N = [ ( i // j ) for ( i , j ) in zip ( I , J ) ] #NEWLINE# h [ tuple ( N ) ] = coeff #NEWLINE# #UNINDENT# H . append ( h ) #NEWLINE# #UNINDENT# return ( J , H )