
    \h                         S r SSKJrJr  SSKJr  SSKJr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KJr  SS	KJr  SS
Kr\ " S S\\\5      5       r\" 5       rg
)z.Implementation of :class:`IntegerRing` class.     )MPZGROUND_TYPES)
int_valued)SymPyInteger	factorialgcdexgcdlcmsqrt	is_squaresqrtrem)CharacteristicZero)Ring)SimpleDomain)CoercionFailed)publicNc                      \ rS rSrSrSrSr\r\" S5      r	\" S5      r
\" \
5      rS=rrSrSrSrSrS rS rS	 rS
 rS rS rSS.S j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+S" r,S# r-S$ r.S%r/g)&IntegerRing   a  The domain ``ZZ`` representing the integers `\mathbb{Z}`.

The :py:class:`IntegerRing` class represents the ring of integers as a
:py:class:`~.Domain` in the domain system. :py:class:`IntegerRing` is a
super class of :py:class:`PythonIntegerRing` and
:py:class:`GMPYIntegerRing` one of which will be the implementation for
:ref:`ZZ` depending on whether or not ``gmpy`` or ``gmpy2`` is installed.

See also
========

Domain
ZZr      Tc                     g)z$Allow instantiation of this domain. N selfs    W/var/www/auris/envauris/lib/python3.13/site-packages/sympy/polys/domains/integerring.py__init__IntegerRing.__init__3   s        c                 :    [        U[        5      (       a  g[        $ )z0Returns ``True`` if two domains are equivalent. T)
isinstancer   NotImplemented)r   others     r   __eq__IntegerRing.__eq__6   s    e[))!!r   c                     [        S5      $ )z&Compute a hash value for this domain. r   )hashr   s    r   __hash__IntegerRing.__hash__=   s    Dzr   c                 *    [        [        U5      5      $ )z!Convert ``a`` to a SymPy object. )r   intr   as     r   to_sympyIntegerRing.to_sympyA   s    CF##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   r+   r   r,   s     r   
from_sympyIntegerRing.from_sympyE   s>    <<qss8O]]s1v; !>!BCCr   c                     SSK Jn  U$ )a  Return the associated field of fractions :ref:`QQ`

Returns
=======

:ref:`QQ`:
    The associated field of fractions :ref:`QQ`, a
    :py:class:`~.Domain` representing the rational numbers
    `\mathbb{Q}`.

Examples
========

>>> from sympy import ZZ
>>> ZZ.get_field()
QQ
r   )QQ)sympy.polys.domainsr6   )r   r6   s     r   	get_fieldIntegerRing.get_fieldN   s    $ 	+	r   N)aliasc                B    U R                  5       R                  " USU06$ )a  Returns an algebraic field, i.e. `\mathbb{Q}(\alpha, \ldots)`.

Parameters
==========

*extension : One or more :py:class:`~.Expr`.
    Generators of the extension. These should be expressions that are
    algebraic over `\mathbb{Q}`.

alias : str, :py:class:`~.Symbol`, None, optional (default=None)
    If provided, this will be used as the alias symbol for the
    primitive element of the returned :py:class:`~.AlgebraicField`.

Returns
=======

:py:class:`~.AlgebraicField`
    A :py:class:`~.Domain` representing the algebraic field extension.

Examples
========

>>> from sympy import ZZ, sqrt
>>> ZZ.algebraic_field(sqrt(2))
QQ<sqrt(2)>
r:   )r8   algebraic_field)r   r:   	extensions      r   r<   IntegerRing.algebraic_fieldc   s!    6 ~~//H%HHr   c                 z    UR                   (       a*  U R                  UR                  5       UR                  5      $ g)zSConvert a :py:class:`~.ANP` object to :ref:`ZZ`.

See :py:meth:`~.Domain.convert`.
N)	is_groundconvertLCdomK1r-   K0s      r   from_AlgebraicFieldIntegerRing.from_AlgebraicField   s+    
 ;;::addfbff-- r   c           	      r    U R                  [        [        R                  " [        U5      U5      5      5      $ )a  Logarithm of *a* to the base *b*.

Parameters
==========

a: number
b: number

Returns
=======

$\\lfloor\log(a, b)\\rfloor$:
    Floor of the logarithm of *a* to the base *b*

Examples
========

>>> from sympy import ZZ
>>> ZZ.log(ZZ(8), ZZ(2))
3
>>> ZZ.log(ZZ(9), ZZ(2))
3

Notes
=====

This function uses ``math.log`` which is based on ``float`` so it will
fail for large integer arguments.
)dtyper+   mathlogr   r-   bs      r   rL   IntegerRing.log   s'    < zz#dhhs1vq1233r   c                 6    [        UR                  U5      5      $ z3Convert ``ModularInteger(int)`` to GMPY's ``mpz``. r   to_intrD   s      r   from_FFIntegerRing.from_FF       299Q<  r   c                 6    [        UR                  U5      5      $ rQ   rR   rD   s      r   from_FF_pythonIntegerRing.from_FF_python   rV   r   c                     [        U5      $ z,Convert Python's ``int`` to GMPY's ``mpz``. r   rD   s      r   from_ZZIntegerRing.from_ZZ       1vr   c                     [        U5      $ r[   r\   rD   s      r   from_ZZ_pythonIntegerRing.from_ZZ_python   r_   r   c                 N    UR                   S:X  a  [        UR                  5      $ gz1Convert Python's ``Fraction`` to GMPY's ``mpz``. r   Ndenominatorr   	numeratorrD   s      r   from_QQIntegerRing.from_QQ   "    ==Aq{{## r   c                 N    UR                   S:X  a  [        UR                  5      $ grd   re   rD   s      r   from_QQ_pythonIntegerRing.from_QQ_python   rj   r   c                 6    [        UR                  U5      5      $ )z3Convert ``ModularInteger(mpz)`` to GMPY's ``mpz``. rR   rD   s      r   from_FF_gmpyIntegerRing.from_FF_gmpy   rV   r   c                     U$ )z*Convert GMPY's ``mpz`` to GMPY's ``mpz``. r   rD   s      r   from_ZZ_gmpyIntegerRing.from_ZZ_gmpy   s    r   c                 <    UR                   S:X  a  UR                  $ g)z(Convert GMPY ``mpq`` to GMPY's ``mpz``. r   N)rf   rg   rD   s      r   from_QQ_gmpyIntegerRing.from_QQ_gmpy   s    ==A;; r   c                 ^    UR                  U5      u  p4US:X  a  [        [        U5      5      $ g)z,Convert mpmath's ``mpf`` to GMPY's ``mpz``. r   N)to_rationalr   r+   )rE   r-   rF   r2   qs        r   from_RealFieldIntegerRing.from_RealField   s.    ~~a 6 s1v;	 r   c                 <    UR                   S:X  a  UR                  $ g )Nr   )yxrD   s      r   from_GaussianIntegerRing$IntegerRing.from_GaussianIntegerRing   s    33!833J r   c                 H    UR                   (       a  U R                  U5      $ g)z*Convert ``Expression`` to GMPY's ``mpz``. N)r1   r3   rD   s      r   from_EXIntegerRing.from_EX   s    <<==## r   c                 B    [        X5      u  p4n[        S:X  a  XEU4$ X4U4$ )z)Compute extended GCD of ``a`` and ``b``. gmpy)r   r   )r   r-   rN   hsts         r   r   IntegerRing.gcdex   s)    +a6!7N7Nr   c                     [        X5      $ )z Compute GCD of ``a`` and ``b``. )r	   rM   s      r   r	   IntegerRing.gcd       1yr   c                     [        X5      $ )z Compute LCM of ``a`` and ``b``. )r
   rM   s      r   r
   IntegerRing.lcm   r   r   c                     [        U5      $ )zCompute square root of ``a``. )r   r,   s     r   r   IntegerRing.sqrt   s    Awr   c                     [        U5      $ )zReturn ``True`` if ``a`` is a square.

Explanation
===========
An integer is a square if and only if there exists an integer
``b`` such that ``b * b == a``.
)r   r,   s     r   r   IntegerRing.is_square   s     |r   c                 <    US:  a  g[        U5      u  p#US:w  a  gU$ )zUNon-negative square root of ``a`` if ``a`` is a square.

See also
========
is_square
r   N)r   )r   r-   rootrems       r   exsqrtIntegerRing.exsqrt  s(     q5AJ	!8r   c                     [        U5      $ )zCompute factorial of ``a``. )r   r,   s     r   r   IntegerRing.factorial  s    |r   r   )0__name__
__module____qualname____firstlineno____doc__repr:   r   rJ   zeroonetypetpis_IntegerRingis_ZZis_Numericalis_PIDhas_assoc_Ringhas_assoc_Fieldr   r$   r(   r.   r3   r8   r<   rG   rL   rT   rX   r]   ra   rh   rl   ro   rr   ru   rz   r   r   r   r	   r
   r   r   r   r   __static_attributes__r   r   r   r   r      s     CEE8D
(C	cB "!NULFNO3"$D* 15 I:.4@!!$
$
!
$
r   r   )r   sympy.external.gmpyr   r   sympy.core.numbersr   sympy.polys.domains.groundtypesr   r   r   r	   r
   r   r   r   &sympy.polys.domains.characteristiczeror   sympy.polys.domains.ringr    sympy.polys.domains.simpledomainr   sympy.polys.polyerrorsr   sympy.utilitiesr   rK   r   r   r   r   r   <module>r      s]    4 1 )   F ) 9 1 " |$*L | |~ ]r   