
    \h                     p    S r SSKJr  SSKJr  SSKJrJr  SSKJ	r	  \	 " S S5      5       r
 " S S	\5      rg
)z.Implementation of :class:`QuotientRing` class.    FreeModuleQuotientRing)Ring)NotReversibleCoercionFailed)publicc                   r    \ rS rSrSrS rS r\rS rS r	\	r
S rS rS	 rS
 r\rS rS rS rS rS rSrg)QuotientRingElement   z
Class representing elements of (commutative) quotient rings.

Attributes:

- ring - containing ring
- data - element of ring.ring (i.e. base ring) representing self
c                     Xl         X l        g N)ringdata)selfr   r   s      X/var/www/auris/envauris/lib/python3.13/site-packages/sympy/polys/domains/quotientring.py__init__QuotientRingElement.__init__   s    		    c                     SSK Jn  U R                  R                  R                  U R                  5      nU" U5      S-   [        U R                  R                  5      -   $ )Nr   )sstrz + )sympy.printing.strr   r   to_sympyr   str
base_ideal)r   r   r   s      r   __str__QuotientRingElement.__str__   sD    +yy~~&&tyy1DzE!C		(<(<$===r   c                 B    U R                   R                  U 5      (       + $ r   )r   is_zeror   s    r   __bool__QuotientRingElement.__bool__$   s    99$$T***r   c                 *   [        XR                  5      (       a  UR                  U R                  :w  a   U R                  R                  U5      nU R                  U R                  UR                  -   5      $ ! [        [
        4 a	    [        s $ f = fr   
isinstance	__class__r   convertNotImplementedErrorr   NotImplementedr   r   oms     r   __add__QuotientRingElement.__add__'   ss    "nn--DII1E&YY&&r* yyRWW,-- (8 &%%&s   A9 9BBc                     U R                  U R                  U R                   R                   R                  S5      -  5      $ )N)r   r   r&   r   s    r   __neg__QuotientRingElement.__neg__1   s-    yy499>>#9#9"#==>>r   c                 &    U R                  U* 5      $ r   r+   r)   s     r   __sub__QuotientRingElement.__sub__4   s    ||RC  r   c                 &    U * R                  U5      $ r   r2   r)   s     r   __rsub__QuotientRingElement.__rsub__7   s    r""r   c                     [        XR                  5      (       d   U R                  R                  U5      nU R                  U R                  UR                  -  5      $ ! [        [
        4 a	    [        s $ f = fr   r#   r   os     r   __mul__QuotientRingElement.__mul__:   sd    !^^,,&II%%a( yy166)** (8 &%%&s   A A87A8c                 >    U R                   R                  U 5      U-  $ r   )r   revertr9   s     r   __rtruediv__ QuotientRingElement.__rtruediv__D   s    yy%a''r   c                     [        XR                  5      (       d   U R                  R                  U5      nU R                  R                  U5      U -  $ ! [        [
        4 a	    [        s $ f = fr   )r$   r%   r   r&   r'   r   r(   r>   r9   s     r   __truediv__QuotientRingElement.__truediv__G   sb    !^^,,&II%%a( yy"4'' (8 &%%&s   A A.-A.c                     US:  a  U R                   R                  U 5      U* -  $ U R                  U R                  U-  5      $ )Nr   )r   r>   r   )r   oths     r   __pow__QuotientRingElement.__pow__O   s=    799##D)cT11yyc)**r   c                     [        XR                  5      (       a  UR                  U R                  :w  a  gU R                  R                  X-
  5      $ )NF)r$   r%   r   r   r)   s     r   __eq__QuotientRingElement.__eq__T   s:    "nn--DII1Eyy  ++r   c                     X:X  + $ r    r)   s     r   __ne__QuotientRingElement.__ne__Y   s
    ~r   )r   r   N)__name__
__module____qualname____firstlineno____doc__r   r   __repr__r    r+   __radd__r/   r3   r6   r;   __rmul__r?   rB   rF   rI   rM   __static_attributes__rL   r   r   r
   r
      s]    >
 H+. H?!#+ H((+
,
r   r
   c                       \ rS rSrSrSrSr\rS r	S r
S rS rS	 rS
 r\r\r\r\r\r\r\rS rS rS rS rS rS rS rS rSrg)QuotientRing]   a  
Class representing (commutative) quotient rings.

You should not usually instantiate this by hand, instead use the constructor
from the base ring in the construction.

>>> from sympy.abc import x
>>> from sympy import QQ
>>> I = QQ.old_poly_ring(x).ideal(x**3 + 1)
>>> QQ.old_poly_ring(x).quotient_ring(I)
QQ[x]/<x**3 + 1>

Shorter versions are possible:

>>> QQ.old_poly_ring(x)/I
QQ[x]/<x**3 + 1>

>>> QQ.old_poly_ring(x)/[x**3 + 1]
QQ[x]/<x**3 + 1>

Attributes:

- ring - the base ring
- base_ideal - the ideal used to form the quotient
TFc                     UR                   U:X  d  [        SU< SU< 35      eXl         X l        U " U R                   R                  5      U l        U " U R                   R                  5      U l        g )NzIdeal must belong to z, got )r   
ValueErrorr   zeroone)r   r   ideals      r   r   QuotientRing.__init__|   sP    zzT!$NOO	(			&r   c                 ^    [        U R                  5      S-   [        U R                  5      -   $ )N/)r   r   r   r   s    r   r   QuotientRing.__str__   s#    499~#c$//&:::r   c                     [        U R                  R                  U R                  U R                  U R
                  45      $ r   )hashr%   rO   dtyper   r   r   s    r   __hash__QuotientRing.__hash__   s,    T^^,,djj$))T__UVVr   c                     [        XR                  R                  5      (       d  U R                  U5      nU R                  X R                  R	                  U5      5      $ )z4Construct an element of ``self`` domain from ``a``. )r$   r   rf   r   reduce_elementr   as     r   newQuotientRing.new   s@    !YY__--		!Azz$ > >q ABBr   c                     [        U[        5      =(       a9    U R                  UR                  :H  =(       a    U R                  UR                  :H  $ )z0Returns ``True`` if two domains are equivalent. )r$   rY   r   r   )r   others     r   rI   QuotientRing.__eq__   s@    %. LII#L(,5;K;K(K	Lr   c                 D    U " U R                   R                  X5      5      $ )z.Convert a Python ``int`` object to ``dtype``. )r   r&   )K1rl   K0s      r   from_ZZQuotientRing.from_ZZ   s    "''//!())r   c                 D    U " U R                   R                  U5      5      $ r   )r   
from_sympyrk   s     r   rx   QuotientRing.from_sympy   s    DII((+,,r   c                 L    U R                   R                  UR                  5      $ r   )r   r   r   rk   s     r   r   QuotientRing.to_sympy   s    yy!!!&&))r   c                     X :X  a  U$ g r   rL   )r   rl   rt   s      r   from_QuotientRingQuotientRing.from_QuotientRing   s    :H r   c                     [        S5      e)z*Returns a polynomial ring, i.e. ``K[X]``. nested domains not allowedr'   r   genss     r   	poly_ringQuotientRing.poly_ring       !">??r   c                     [        S5      e)z)Returns a fraction field, i.e. ``K(X)``. r   r   r   s     r   
frac_fieldQuotientRing.frac_field   r   r   c                     U R                   R                  UR                  5      U R                  -   n U " UR	                  S5      S   5      $ ! [
         a    [        U< SU < 35      ef = f)z
Compute a**(-1), if possible.
   r   z not a unit in )r   r_   r   r   in_terms_of_generatorsr\   r   )r   rl   Is      r   r>   QuotientRing.revert   se     IIOOAFF#doo5	C003A677 	CD ABB	Cs   A A+c                 L    U R                   R                  UR                  5      $ r   )r   containsr   rk   s     r   r   QuotientRing.is_zero   s    ''//r   c                     [        X5      $ )z
Generate a free module of rank ``rank`` over ``self``.

>>> from sympy.abc import x
>>> from sympy import QQ
>>> (QQ.old_poly_ring(x)/[x**2 + 1]).free_module(2)
(QQ[x]/<x**2 + 1>)**2
r   )r   ranks     r   free_moduleQuotientRing.free_module   s     &d11r   )r   r^   r   r]   N)rO   rP   rQ   rR   rS   has_assoc_Ringhas_assoc_Fieldr
   rf   r   r   rg   rm   rI   ru   from_ZZ_pythonfrom_QQ_pythonfrom_ZZ_gmpyfrom_QQ_gmpyfrom_RealFieldfrom_GlobalPolynomialRingfrom_FractionFieldrx   r   r}   r   r   r>   r   r   rW   rL   r   r   rY   rY   ]   s    4 NOE';WCL
* N#N!L!L#N .'-*@@C0	2r   rY   N)rS   sympy.polys.agca.modulesr   sympy.polys.domains.ringr   sympy.polys.polyerrorsr   r   sympy.utilitiesr   r
   rY   rL   r   r   <module>r      sA    4 < ) @ " K K K\m24 m2r   