K i |dZddlmZmZmZmZmZmZm Z ddl m Z ddl mZddlmZddlmZeGddeZy ) z2Implementation of :class:`GMPYIntegerRing` class. ) GMPYInteger SymPyInteger factorial gmpy_gcdexgmpy_gcdgmpy_lcmsqrt) int_valued) IntegerRing)CoercionFailed)publicceZdZdZeZedZedZeeZ dZ dZ dZ dZ dZd Zd Zd Zd Zd ZdZdZdZdZdZdZdZdZy)GMPYIntegerRingzInteger ring based on GMPY's ``mpz`` type. This will be the implementation of :ref:`ZZ` if ``gmpy`` or ``gmpy2`` is installed. Elements will be of type ``gmpy.mpz``. rZZ_gmpycy)z$Allow instantiation of this domain. N)selfs i/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sympy/polys/domains/gmpyintegerring.py__init__zGMPYIntegerRing.__init__sc*tt|S)z!Convert ``a`` to a SymPy object. )rintras rto_sympyzGMPYIntegerRing.to_sympysCF##rc|jrt|jSt|rtt |St d|z)z&Convert SymPy's Integer to ``dtype``. zexpected an integer, got %s) is_Integerrpr rr rs r from_sympyzGMPYIntegerRing.from_sympy#s? <<qss# # ]s1v& & !>!BC Crc$|j|S)z3Convert ``ModularInteger(int)`` to GMPY's ``mpz``. to_intK1rK0s rfrom_FF_pythonzGMPYIntegerRing.from_FF_python,yy|rct|S)z,Convert Python's ``int`` to GMPY's ``mpz``. )rr$s rfrom_ZZ_pythonzGMPYIntegerRing.from_ZZ_python0s 1~rcL|jdk(rt|jSyz1Convert Python's ``Fraction`` to GMPY's ``mpz``. rN denominatorr numeratorr$s rfrom_QQzGMPYIntegerRing.from_QQ4" ==A q{{+ + rcL|jdk(rt|jSyr,r-r$s rfrom_QQ_pythonzGMPYIntegerRing.from_QQ_python9r1rc$|j|S)z3Convert ``ModularInteger(mpz)`` to GMPY's ``mpz``. r"r$s r from_FF_gmpyzGMPYIntegerRing.from_FF_gmpy>r(rc|S)z*Convert GMPY's ``mpz`` to GMPY's ``mpz``. rr$s r from_ZZ_gmpyzGMPYIntegerRing.from_ZZ_gmpyBsrc:|jdk(r |jSy)z(Convert GMPY ``mpq`` to GMPY's ``mpz``. rN)r.r/r$s r from_QQ_gmpyzGMPYIntegerRing.from_QQ_gmpyFs ==A ;;  rcL|j|\}}|dk(r t|Sy)z,Convert mpmath's ``mpf`` to GMPY's ``mpz``. rN) to_rationalr)r%rr&rqs rfrom_RealFieldzGMPYIntegerRing.from_RealFieldKs*~~a 1 6q> ! rc:|jdk(r |jSy)Nr)yxr$s rfrom_GaussianIntegerRingz(GMPYIntegerRing.from_GaussianIntegerRingRs 33!833J rc,t||\}}}|||fS)z)Compute extended GCD of ``a`` and ``b``. )r)rrbhsts rgcdexzGMPYIntegerRing.gcdexVsQ"1a!Qwrct||S)z Compute GCD of ``a`` and ``b``. )rrrrCs rgcdzGMPYIntegerRing.gcd[1~rct||S)z Compute LCM of ``a`` and ``b``. )rrIs rlcmzGMPYIntegerRing.lcm_rKrct|S)zCompute square root of ``a``. ) gmpy_sqrtrs rr zGMPYIntegerRing.sqrtcs |rct|S)zCompute factorial of ``a``. )gmpy_factorialrs rrzGMPYIntegerRing.factorialgs a  rN)__name__ __module__ __qualname____doc__rdtypezeroonetypetpaliasrrr r'r*r0r3r5r7r9r=rArGrJrMr rrrrrrs E 8D (C cB E3$D, ,  " !rrN)rUsympy.polys.domains.groundtypesrrrrQrrrr rOsympy.core.numbersr sympy.polys.domains.integerringr sympy.polys.polyerrorsr sympy.utilitiesr rrrrrasA8 *71"Z!kZ!Z!r