#NEWLINE# def _gcd_monom( f , g ) : #NEWLINE# #INDENT# ring = f . ring #NEWLINE# ground_gcd = ring . domain . gcd #NEWLINE# ground_quo = ring . domain . quo #NEWLINE# monomial_gcd = ring . monomial_gcd #NEWLINE# monomial_ldiv = ring . monomial_ldiv #NEWLINE# ( mf , cf ) = list ( f . iterterms ( ) ) [ 0 ] #NEWLINE# ( _mgcd , _cgcd ) = ( mf , cf ) #NEWLINE# for ( mg , cg ) in g . iterterms ( ) : #NEWLINE# #INDENT# _mgcd = monomial_gcd ( _mgcd , mg ) #NEWLINE# _cgcd = ground_gcd ( _cgcd , cg ) #NEWLINE# #UNINDENT# h = f . new ( [ ( _mgcd , _cgcd ) ] ) #NEWLINE# cff = f . new ( [ ( monomial_ldiv ( mf , _mgcd ) , ground_quo ( cf , _cgcd ) ) ] ) #NEWLINE# cfg = f . new ( [ ( monomial_ldiv ( mg , _mgcd ) , ground_quo ( cg , _cgcd ) ) for ( mg , cg ) in g . iterterms ( ) ] ) #NEWLINE# return ( h , cff , cfg )