K ipdZddlmZddlmZddlmZmZddlm Z e GddZ Gdd eZ y ) z.Implementation of :class:`QuotientRing` class.FreeModuleQuotientRing)Ring) NotReversibleCoercionFailed)publiccjeZdZdZdZdZeZdZdZeZ dZ dZ dZ d Z e Zd Zd Zd Zd ZdZy)QuotientRingElementz Class representing elements of (commutative) quotient rings. Attributes: - ring - containing ring - data - element of ring.ring (i.e. base ring) representing self c ||_||_yN)ringdata)selfr rs f/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sympy/polys/domains/quotientring.py__init__zQuotientRingElement.__init__s  cddlm}|jjj|j}||dzt |jj zS)Nr)sstrz + )sympy.printing.strrr to_sympyrstr base_ideal)rrrs r__str__zQuotientRingElement.__str__sD+yy~~&&tyy1DzE!C (<(<$===rc:|jj| Sr )r is_zerors r__bool__zQuotientRingElement.__bool__$s99$$T***rct||jr|j|jk7r |jj|}|j|j|jzS#tt f$r t cYSwxYwr  isinstance __class__r convertNotImplementedErrorrNotImplementedrroms r__add__zQuotientRingElement.__add__'sr"dnn-DII1E &YY&&r*yyRWW,--(8 &%% &sA44B  B c|j|j|jjjdzS)N)r rr"rs r__neg__zQuotientRingElement.__neg__1s-yy499>>#9#9"#==>>rc&|j| Sr r'r%s r__sub__zQuotientRingElement.__sub__4s||RC  rc&| j|Sr r,r%s r__rsub__zQuotientRingElement.__rsub__7sr""rct||js |jj|}|j|j|jzS#tt f$r t cYSwxYwr rros r__mul__zQuotientRingElement.__mul__:sc!T^^, &II%%a(yy166)**(8 &%% &sAA32A3c>|jj||zSr )r revertr1s r __rtruediv__z QuotientRingElement.__rtruediv__Dsyy%a''rct||js |jj|}|jj||zS#tt f$r t cYSwxYwr )r r!r r"r#rr$r5r1s r __truediv__zQuotientRingElement.__truediv__Gsa!T^^, &II%%a(yy"4''(8 &%% &sAA)(A)c|dkr|jj|| zS|j|j|zS)Nr)r r5r)roths r__pow__zQuotientRingElement.__pow__Os= 799##D)cT1 1yyc)**rct||jr|j|jk7ry|jj||z S)NF)r r!r rr%s r__eq__zQuotientRingElement.__eq__Ts;"dnn-DII1Eyy  ++rc||k( Sr r%s r__ne__zQuotientRingElement.__ne__Ys2:~rN)__name__ __module__ __qualname____doc__rr__repr__rr'__radd__r*r-r/r3__rmul__r6r8r;r=r@r?rrr r s]> H+.H?!#+H((+ , rr ceZdZdZdZdZeZdZdZ dZ dZ dZ d Z e ZeZeZeZeZeZeZd Zd Zd Zd ZdZdZdZdZy) QuotientRingaa 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]/ Shorter versions are possible: >>> QQ.old_poly_ring(x)/I QQ[x]/ >>> QQ.old_poly_ring(x)/[x**3 + 1] QQ[x]/ Attributes: - ring - the base ring - base_ideal - the ideal used to form the quotient TFc|j|k(std|d|||_||_||jj|_||jj|_y)NzIdeal must belong to z, got )r ValueErrorrzeroone)rr ideals rrzQuotientRing.__init__|sTzzT!$NO O (  &rc^t|jdzt|jzS)N/)rr rrs rrzQuotientRing.__str__s#499~#c$//&:::rct|jj|j|j|j fSr )hashr!rAdtyper rrs r__hash__zQuotientRing.__hash__s,T^^,,djj$))T__UVVrct||jjs|j|}|j||jj |S)z4Construct an element of ``self`` domain from ``a``. )r r rSrreduce_elementras rnewzQuotientRing.newsA!TYY__- ! Azz$ > >q ABBrct|txr4|j|jk(xr|j|jk(S)z0Returns ``True`` if two domains are equivalent. )r rIr r)rothers rr=zQuotientRing.__eq__s@%.L II #L(,5;K;K(K LrcF||jj||S)z.Convert a Python ``int`` object to ``dtype``. )r r")K1rXK0s rfrom_ZZzQuotientRing.from_ZZs"''//!R())rcD||jj|Sr )r from_sympyrWs rrazQuotientRing.from_sympysDII((+,,rcL|jj|jSr )r rrrWs rrzQuotientRing.to_sympysyy!!!&&))rc||k(r|Syr r?)rrXr^s rfrom_QuotientRingzQuotientRing.from_QuotientRings :H rctd)z*Returns a polynomial ring, i.e. ``K[X]``. nested domains not allowedr#rgenss r poly_ringzQuotientRing.poly_ring!">??rctd)z)Returns a fraction field, i.e. ``K(X)``. rfrgrhs r frac_fieldzQuotientRing.frac_fieldrkrc|jj|j|jz} ||j ddS#t $rt |d|wxYw)z/ Compute a**(-1), if possible. rz not a unit in )r rNrrin_terms_of_generatorsrKr)rrXIs rr5zQuotientRing.revertse IIOOAFF #doo 5 C003A67 7 CD AB B Cs AA(cL|jj|jSr )rcontainsrrWs rrzQuotientRing.is_zeros''//rct||S)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]/)**2 r)rranks r free_modulezQuotientRing.free_modules&dD11rN)rArBrCrDhas_assoc_Ringhas_assoc_Fieldr rSrrrTrYr=r_from_ZZ_pythonfrom_QQ_python from_ZZ_gmpy from_QQ_gmpyfrom_RealFieldfrom_GlobalPolynomialRingfrom_FractionFieldrarrdrjrmr5rrvr?rrrIrI]s4NO E';WCL *N#N!L!L#N .'-*@@C0 2rrIN) rDsympy.polys.agca.modulesrsympy.polys.domains.ringrsympy.polys.polyerrorsrrsympy.utilitiesrr rIr?rrrsA4<)@"KKK\m24m2r