
    \h                     |    S r SSKJr  SSKJrJrJrJr	J
r
JrJr  SSKJr  SSKJr  SSKJr  \ " S S\5      5       rg	)
z4Implementation of :class:`PythonIntegerRing` class.     )
int_valued)PythonIntegerSymPyIntegersqrt	factorialpython_gcdex
python_gcd
python_lcm)IntegerRing)CoercionFailed)publicc                       \ rS rSrSr\r\" S5      r\" S5      rSr	S r
S rS rS	 rS
 rS rS rS rS rS rS rS rS rS rS rS rSrg)PythonIntegerRing   zInteger ring based on Python's ``int`` type.

This will be used as :ref:`ZZ` if ``gmpy`` and ``gmpy2`` are not
installed. Elements are instances of the standard Python ``int`` type.
r      	ZZ_pythonc                     g)z$Allow instantiation of this domain. N )selfs    ]/var/www/auris/envauris/lib/python3.13/site-packages/sympy/polys/domains/pythonintegerring.py__init__PythonIntegerRing.__init__   s        c                     [        U5      $ )z!Convert ``a`` to a SymPy object. )r   r   as     r   to_sympyPythonIntegerRing.to_sympy   s    Ar   c                     UR                   (       a  [        UR                  5      $ [        U5      (       a  [        [	        U5      5      $ [        SU-  5      e)z&Convert SymPy's Integer to ``dtype``. zexpected an integer, got %s)
is_Integerr   pr   intr   r   s     r   
from_sympyPythonIntegerRing.from_sympy!   sA    << %%]] Q(( !>!BCCr   c                 $    UR                  U5      $ )z5Convert ``ModularInteger(int)`` to Python's ``int``. )to_intK1r   K0s      r   from_FF_python PythonIntegerRing.from_FF_python*   s    yy|r   c                     U$ )z.Convert Python's ``int`` to Python's ``int``. r   r'   s      r   from_ZZ_python PythonIntegerRing.from_ZZ_python.   s    r   c                 <    UR                   S:X  a  UR                  $ gz3Convert Python's ``Fraction`` to Python's ``int``. r   Ndenominator	numeratorr'   s      r   from_QQPythonIntegerRing.from_QQ2       ==A;; r   c                 <    UR                   S:X  a  UR                  $ gr0   r1   r'   s      r   from_QQ_python PythonIntegerRing.from_QQ_python7   r6   r   c                 6    [        UR                  U5      5      $ )z5Convert ``ModularInteger(mpz)`` to Python's ``int``. )r   r&   r'   s      r   from_FF_gmpyPythonIntegerRing.from_FF_gmpy<   s    RYYq\**r   c                     [        U5      $ )z,Convert GMPY's ``mpz`` to Python's ``int``. )r   r'   s      r   from_ZZ_gmpyPythonIntegerRing.from_ZZ_gmpy@   s    Qr   c                 ^    UR                  5       S:X  a  [        UR                  5       5      $ g)z,Convert GMPY's ``mpq`` to Python's ``int``. r   N)denomr   numerr'   s      r   from_QQ_gmpyPythonIntegerRing.from_QQ_gmpyD   s%    779> ++ r   c                 L    UR                  U5      u  p4US:X  a  [        U5      $ g)z.Convert mpmath's ``mpf`` to Python's ``int``. r   N)to_rationalr   )r(   r   r)   r!   qs        r   from_RealField PythonIntegerRing.from_RealFieldI   s)    ~~a 6 ## r   c                     [        X5      $ )z)Compute extended GCD of ``a`` and ``b``. )r   r   r   bs      r   gcdexPythonIntegerRing.gcdexP   s    A!!r   c                     [        X5      $ )z Compute GCD of ``a`` and ``b``. )r	   rK   s      r   gcdPythonIntegerRing.gcdT       !r   c                     [        X5      $ )z Compute LCM of ``a`` and ``b``. )r
   rK   s      r   lcmPythonIntegerRing.lcmX   rR   r   c                     [        U5      $ )zCompute square root of ``a``. )python_sqrtr   s     r   r   PythonIntegerRing.sqrt\   s    1~r   c                     [        U5      $ )zCompute factorial of ``a``. )python_factorialr   s     r   r   PythonIntegerRing.factorial`   s    ""r   r   N)__name__
__module____qualname____firstlineno____doc__r   dtypezeroonealiasr   r   r#   r*   r-   r4   r8   r;   r>   rC   rH   rM   rP   rT   r   r   __static_attributes__r   r   r   r   r      sv     E8D
(CE3D

+ ,
$"  #r   r   N)r`   sympy.core.numbersr   sympy.polys.domains.groundtypesr   r   r   rW   r   rZ   r   r	   r
   sympy.polys.domains.integerringr   sympy.polys.polyerrorsr   sympy.utilitiesr   r   r   r   r   <module>rk      sC    : *   8 1 "T# T# T#r   