+
    i                         R t ^ RIHtHt ^ RIHt ^ RIHtHtH	t	H
t
HtHtHtHt ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ R	It] ! R
 R]]]4      4       t]! 4       tR	# )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                   (  a  ] tR t^t o RtRtRt]t]! ^ 4      t	]! ^4      t
]! ]
4      tR;ttRtRtRtRtR tR tR tR tR tR	 tR
R/R ltR tR tR tR tR tR tR t R t!R t"R t#R t$R t%R t&R t'R t(R t)R t*R t+R t,R  t-R! t.R"t/V t0R# )#IntegerRinga  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
ZZTc                    R# )z$Allow instantiation of this domain. N selfs   &/Users/tonyclaw/.openclaw/workspace/skills/math-calculator/venv/lib/python3.14/site-packages/sympy/polys/domains/integerring.py__init__IntegerRing.__init__3   s        c                >    \        V\        4      '       d   R# \        # )z0Returns ``True`` if two domains are equivalent. T)
isinstancer   NotImplemented)r   others   &&r   __eq__IntegerRing.__eq__6   s    e[))!!r   c                    \        R4      # )z&Compute a hash value for this domain. r   )hashr   s   &r   __hash__IntegerRing.__hash__=   s    Dzr   c                *    \        \        V4      4      # )z!Convert ``a`` to a SymPy object. )r   intr   as   &&r   to_sympyIntegerRing.to_sympyA   s    CF##r   c                    VP                   '       d   \        VP                  4      # \        V4      '       d   \        \	        V4      4      # \        RV,          4      h)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                    ^ RI Hp V# )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
)QQ)sympy.polys.domainsr3   )r   r3   s   & r   	get_fieldIntegerRing.get_fieldN   s    $ 	+	r   aliasNc               B    V P                  4       P                  ! VRV/ # )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)>
r7   )r5   algebraic_field)r   r7   	extensions   &$*r   r9   IntegerRing.algebraic_fieldc   s!    6 ~~//H%HHr   c                ~    VP                   '       d+   V P                  VP                  4       VP                  4      # R# )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    V P                  \        \        P                  ! \        V4      V4      4      4      # )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   rI   IntegerRing.log   s'    < zz#dhhs1vq1233r   c                6    \        VP                  V4      4      # z3Convert ``ModularInteger(int)`` to GMPY's ``mpz``. r   to_intrA   s   &&&r   from_FFIntegerRing.from_FF       299Q<  r   c                6    \        VP                  V4      4      # rN   rO   rA   s   &&&r   from_FF_pythonIntegerRing.from_FF_python   rS   r   c                    \        V4      # z,Convert Python's ``int`` to GMPY's ``mpz``. r   rA   s   &&&r   from_ZZIntegerRing.from_ZZ       1vr   c                    \        V4      # rX   rY   rA   s   &&&r   from_ZZ_pythonIntegerRing.from_ZZ_python   r\   r   c                R    VP                   ^8X  d   \        VP                  4      # R# z1Convert Python's ``Fraction`` to GMPY's ``mpz``. Ndenominatorr   	numeratorrA   s   &&&r   from_QQIntegerRing.from_QQ   "    ==Aq{{## r   c                R    VP                   ^8X  d   \        VP                  4      # R# ra   rb   rA   s   &&&r   from_QQ_pythonIntegerRing.from_QQ_python   rg   r   c                6    \        VP                  V4      4      # )z3Convert ``ModularInteger(mpz)`` to GMPY's ``mpz``. rO   rA   s   &&&r   from_FF_gmpyIntegerRing.from_FF_gmpy   rS   r   c                    V# )z*Convert GMPY's ``mpz`` to GMPY's ``mpz``. r   rA   s   &&&r   from_ZZ_gmpyIntegerRing.from_ZZ_gmpy   s    r   c                @    VP                   ^8X  d   VP                  # R# )z(Convert GMPY ``mpq`` to GMPY's ``mpz``. N)rc   rd   rA   s   &&&r   from_QQ_gmpyIntegerRing.from_QQ_gmpy   s    ==A;; r   c                b    VP                  V4      w  r4V^8X  d   \        \        V4      4      # R# )z,Convert mpmath's ``mpf`` to GMPY's ``mpz``. N)to_rationalr   r(   )rB   r*   rC   r/   qs   &&&  r   from_RealFieldIntegerRing.from_RealField   s.    ~~a 6 s1v;	 r   c                @    VP                   ^ 8X  d   VP                  # R# )    N)yxrA   s   &&&r   from_GaussianIntegerRing$IntegerRing.from_GaussianIntegerRing   s    33!833J r   c                L    VP                   '       d   V P                  V4      # R# )z*Convert ``Expression`` to GMPY's ``mpz``. N)r.   r0   rA   s   &&&r   from_EXIntegerRing.from_EX   s    <<<==## r   c                D    \        W4      w  r4p\        R8X  d   WEV3# W4V3# )z)Compute extended GCD of ``a`` and ``b``. gmpy)r   r   )r   r*   rK   hsts   &&&   r   r   IntegerRing.gcdex   s)    +a6!7N7Nr   c                    \        W4      # )z Compute GCD of ``a`` and ``b``. )r   rJ   s   &&&r   r   IntegerRing.gcd       1yr   c                    \        W4      # )z Compute LCM of ``a`` and ``b``. )r	   rJ   s   &&&r   r	   IntegerRing.lcm   r   r   c                    \        V4      # )zCompute square root of ``a``. )r
   r)   s   &&r   r
   IntegerRing.sqrt   s    Awr   c                    \        V4      # )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                D    V^ 8  d   R# \        V4      w  r#V^ 8w  d   R# V# )zUNon-negative square root of ``a`` if ``a`` is a square.

See also
========
is_square
N)r   )r   r*   rootrems   &&  r   exsqrtIntegerRing.exsqrt  s(     q5AJ	!8r   c                    \        V4      # )zCompute factorial of ``a``. )r   r)   s   &&r   r   IntegerRing.factorial  s    |r   r   )1__name__
__module____qualname____firstlineno____doc__repr7   r   rG   zeroonetypetpis_IntegerRingis_ZZis_Numericalis_PIDhas_assoc_Ringhas_assoc_Fieldr   r!   r%   r+   r0   r5   r9   rD   rI   rQ   rU   rZ   r^   re   ri   rl   ro   rr   rw   r}   r   r   r   r	   r
   r   r   r   __static_attributes____classdictcell__)__classdict__s   @r   r   r      s      CEE8D
(C	cB "!NULFNO3"$D*I 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   rH   r   r   r   r   r   <module>r      s]    4 1 )   F ) 9 1 " |$*L | |~ ]r   