#NEWLINE# def dup_clear_denoms( f , K0 , K1 = None , convert = False ) : #NEWLINE# #INDENT# '\n    Clear denominators, i.e. transform ``K_0`` to ``K_1``.\n\n    Examples\n    ========\n\n    >>> from sympy.polys import ring, QQ\n    >>> R, x = ring("x", QQ)\n\n    >>> f = QQ(1,2)*x + QQ(1,3)\n\n    >>> R.dup_clear_denoms(f, convert=False)\n    (6, 3*x + 2)\n    >>> R.dup_clear_denoms(f, convert=True)\n    (6, 3*x + 2)\n\n    ' #NEWLINE# if ( K1 is None ) : #NEWLINE# #INDENT# if K0 . has_assoc_Ring : #NEWLINE# #INDENT# K1 = K0 . get_ring ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# K1 = common #NEWLINE# #UNINDENT# #UNINDENT# common = K1 . one #NEWLINE# for c in f : #NEWLINE# #INDENT# common = K1 . lcm ( common , K0 . denom ( c ) ) #NEWLINE# #UNINDENT# if ( not K1 . is_one ( common ) ) : #NEWLINE# #INDENT# f = dup_mul_ground ( f , common , K0 ) #NEWLINE# #UNINDENT# if ( not convert ) : #NEWLINE# #INDENT# return ( common , f ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return ( common , dup_convert ( f , K0 , K1 ) )