#NEWLINE# def rem( self , G ) : #NEWLINE# #INDENT# f = self #NEWLINE# if isinstance ( G , PolyElement ) : #NEWLINE# #INDENT# G = [ G ] #NEWLINE# #UNINDENT# if any ( ( ( not g ) for g in G ) ) : #NEWLINE# #INDENT# raise ZeroDivisionError ( 'polynomial division' ) #NEWLINE# #UNINDENT# ring = f . ring #NEWLINE# domain = ring . domain #NEWLINE# order = ring . order #NEWLINE# zero = domain . zero #NEWLINE# monomial_mul = ring . monomial_mul #NEWLINE# r = ring . zero #NEWLINE# term_div = f . _term_div ( ) #NEWLINE# ltf = f . LT #NEWLINE# f = f . copy ( ) #NEWLINE# get = f . get #NEWLINE# while f : #NEWLINE# #INDENT# for g in G : #NEWLINE# #INDENT# tq = term_div ( ltf , g . LT ) #NEWLINE# if ( tq is not None ) : #NEWLINE# #INDENT# ( m , c ) = tq #NEWLINE# for ( mg , cg ) in g . iterterms ( ) : #NEWLINE# #INDENT# m1 = monomial_mul ( mg , m ) #NEWLINE# c1 = ( get ( m1 , zero ) - ( c * cg ) ) #NEWLINE# if ( not c1 ) : #NEWLINE# #INDENT# del f [ m1 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# f [ m1 ] = c1 #NEWLINE# #UNINDENT# #UNINDENT# ltm = f . leading_expv ( ) #NEWLINE# if ( ltm is not None ) : #NEWLINE# #INDENT# ltf = ( ltm , f [ ltm ] ) #NEWLINE# #UNINDENT# break #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# ( ltm , ltc ) = cg #NEWLINE# if ( ltm in r ) : #NEWLINE# #INDENT# r [ ltm ] += ltc #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# r [ ltm ] = ltc #NEWLINE# #UNINDENT# del f [ ltm ] #NEWLINE# ltm = f . leading_expv ( ) #NEWLINE# if ( ltm is not None ) : #NEWLINE# #INDENT# ltf = ( ltm , f [ ltm ] ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return r