<s> """<STR_LIT>""" <EOL> from __future__ import print_function , division <EOL> from sympy . polys . domains . integerring import IntegerRing <EOL> from sympy . polys . domains . groundtypes import ( <EOL> GMPYInteger , SymPyInteger , <EOL> gmpy_factorial , <EOL> gmpy_gcdex , gmpy_gcd , gmpy_lcm , gmpy_sqrt , <EOL> ) <EOL> from sympy . polys . polyerrors import CoercionFailed <EOL> from sympy . utilities import public <EOL> @ public <EOL> class GMPYIntegerRing ( IntegerRing ) : <EOL> """<STR_LIT>""" <EOL> dtype = GMPYInteger <EOL> zero = dtype ( <NUM_LIT:0> ) <EOL> one = dtype ( <NUM_LIT:1> ) <EOL> tp = type ( one ) <EOL> alias = '<STR_LIT>' <EOL> def __init__ ( self ) : <EOL> """<STR_LIT>""" <EOL> def to_sympy ( self , a ) : <EOL> """<STR_LIT>""" <EOL> return SymPyInteger ( int ( a ) ) <EOL> def from_sympy ( self , a ) : <EOL> """<STR_LIT>""" <EOL> if a . is_Integer : <EOL> return GMPYInteger ( a . p ) <EOL> elif a . is_Float and int ( a ) == a : <EOL> return GMPYInteger ( int ( a ) ) <EOL> else : <EOL> raise CoercionFailed ( "<STR_LIT>" % a ) <EOL> def from_FF_python ( K1 , a , K0 ) : <EOL> """<STR_LIT>""" <EOL> return GMPYInteger ( a . to_int ( ) ) <EOL> def from_ZZ_python ( K1 , a , K0 ) : <EOL> """<STR_LIT>""" <EOL> return GMPYInteger ( a ) <EOL> def from_QQ_python ( K1 , a , K0 ) : <EOL> """<STR_LIT>""" <EOL> if a . denominator == <NUM_LIT:1> : <EOL> return GMPYInteger ( a . numerator ) <EOL> def from_FF_gmpy ( K1 , a , K0 ) : <EOL> """<STR_LIT>""" <EOL> return a . to_int ( ) <EOL> def from_ZZ_gmpy ( K1 , a , K0 ) : <EOL> """<STR_LIT>""" <EOL> return a <EOL> def from_QQ_gmpy ( K1 , a , K0 ) : <EOL> """<STR_LIT>""" <EOL> if a . denominator == <NUM_LIT:1> : <EOL> return a . numerator <EOL> def from_RealField ( K1 , a , K0 ) : <EOL> """<STR_LIT>""" <EOL> p , q = K0 . to_rational ( a ) <EOL> if q == <NUM_LIT:1> : <EOL> return GMPYInteger ( p ) <EOL> def gcdex ( self , a , b ) : <EOL> """<STR_LIT>""" <EOL> h , s , t = gmpy_gcdex ( a , b ) <EOL> return s , t , h <EOL> def gcd ( self , a , b ) : <EOL> """<STR_LIT>""" <EOL> return gmpy_gcd ( a , b ) <EOL> def lcm ( self , a , b ) : <EOL> """<STR_LIT>""" <EOL> return gmpy_lcm ( a , b ) <EOL> def sqrt ( self , a ) : <EOL> """<STR_LIT>""" <EOL> return gmpy_sqrt ( a ) <EOL> def factorial ( self , a ) : <EOL> """<STR_LIT>""" <EOL> return gmpy_factorial ( a ) </s>
