K iO^dZddlmZddlmZddlmZmZddlm Z e GddeeZ y) z1Implementation of :class:`PolynomialRing` class. )Ring)CompositeDomain)CoercionFailedGeneratorsError)publicceZdZdZdxZZdZdZd(dZdZ dZ e dZ e dZ e d Zd Zd Zd Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"dZ#dZ$d Z%d!Z&d"Z'd#Z(d$Z)d%Z*d&Z+d'Z,y))PolynomialRingz8A class for representing multivariate polynomial rings. TNcddlm}t||r|||}n ||||}||_|j|_|j |_|j |_|j|_|j|_|rA|jjr+|jjrt|dk(rd|_ |j|_ y)Nr)PolyRingT)sympy.polys.ringsr isinstanceringdtypegensngenssymbolsdomainis_Fieldis_Exactlenis_PIDdom)selfdomain_or_ringrorderr rs h/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sympy/polys/domains/polynomialring.py__init__zPolynomialRing.__init__s. nh /GO !DG^U;D ZZ II ZZ || kk  {{## (<(<Wq" ;;c8|jj|SN)rring_newrelements rnewzPolynomialRing.new+syy!!'**rc8|jj|S)z%Check if ``a`` is of type ``dtype``. )r is_elementr#s rof_typezPolynomialRing.of_type.syy##G,,rc.|jjSr!)rzerors rr*zPolynomialRing.zero2syy~~rc.|jjSr!)roner+s rr-zPolynomialRing.one6syy}}rc.|jjSr!)rrr+s rrzPolynomialRing.order:syyrct|jdzdjtt|jzdzS)N[,])strrjoinmaprr+s r__str__zPolynomialRing.__str__>s44;;#%S$,,1G(HH3NNrct|jj|j|j|j fSr!)hash __class____name__rrrr+s r__hash__zPolynomialRing.__hash__As,T^^,,diidllSTTrc`t|tstS|j|jk(S)z.Returns `True` if two domains are equivalent. )rr NotImplementedr)rothers r__eq__zPolynomialRing.__eq__Ds%%0! !yyEJJ&&rcv|jsy|j}|j|j||S)z/Returns ``True`` if ``a`` is a unit of ``self``F) is_groundris_unit convert_from)raKs rrBzPolynomialRing.is_unitJs/{{ KKyy4011rc|jj|j}|jj |Sr!)rcanonical_unitLCr ground_new)rrDus rrGzPolynomialRing.canonical_unitQs/ KK & &qtt ,yy##A&&rc"|jS)zConvert `a` to a SymPy object. )as_exprrrDs rto_sympyzPolynomialRing.to_sympyUsyy{rc8|jj|S)z'Convert SymPy's expression to `dtype`. )r from_exprrMs r from_sympyzPolynomialRing.from_sympyYsyy""1%%rcF||jj||Sz*Convert a Python `int` object to `dtype`. rconvertK1rDK0s rfrom_ZZzPolynomialRing.from_ZZ]"))##Ar*++rcF||jj||SrSrTrVs rfrom_ZZ_pythonzPolynomialRing.from_ZZ_pythonarZrcF||jj||Sz/Convert a Python `Fraction` object to `dtype`. rTrVs rfrom_QQzPolynomialRing.from_QQerZrcF||jj||Sr^rTrVs rfrom_QQ_pythonzPolynomialRing.from_QQ_pythonirZrcF||jj||S)z(Convert a GMPY `mpz` object to `dtype`. rTrVs r from_ZZ_gmpyzPolynomialRing.from_ZZ_gmpymrZrcF||jj||S)z(Convert a GMPY `mpq` object to `dtype`. rTrVs r from_QQ_gmpyzPolynomialRing.from_QQ_gmpyqrZrcF||jj||S)z/Convert a `GaussianInteger` object to `dtype`. rTrVs rfrom_GaussianIntegerRingz'PolynomialRing.from_GaussianIntegerRingurZrcF||jj||S)z0Convert a `GaussianRational` object to `dtype`. rTrVs rfrom_GaussianRationalFieldz)PolynomialRing.from_GaussianRationalFieldyrZrcF||jj||Sz*Convert a mpmath `mpf` object to `dtype`. rTrVs rfrom_RealFieldzPolynomialRing.from_RealField}rZrcF||jj||SrkrTrVs rfrom_ComplexFieldz PolynomialRing.from_ComplexFieldrZrc|j|k7r|jj||}||j|Sy)z*Convert an algebraic number to ``dtype``. N)rrCr%rVs rfrom_AlgebraicFieldz"PolynomialRing.from_AlgebraicFields; 99? &&q"-A =66!9  rcd |j|jS#ttf$rYywxYw)z#Convert a polynomial to ``dtype``. N)set_ringrrrrVs rfrom_PolynomialRingz"PolynomialRing.from_PolynomialRings1 ::bgg& &0  s //c>|j|k(r|jj|gS|j|j |j |\}}|j r4|j||jjjSy)z*Convert a rational function to ``dtype``. N) rr from_listnumerdivdenomis_zerorsfield to_domain)rWrDrXqrs rfrom_FractionFieldz!PolynomialRing.from_FractionFieldst 99?77$$aS) )xx{rxx{+1 99))!RXX]]-D-D-FG Grc|j|jk(rm|j}|j|jk7r<|j Dcic]!\}}||jj |#}}}||S|j r=|j|k(r-|j|jd|jSyycc}}w)z)Convert from old poly ring to ``dtype``. rN) rrto_dictritemsrUrArCto_list)rWrDrXadmcs rfrom_GlobalPolynomialRingz(PolynomialRing.from_GlobalPolynomialRings :: ByyBII%:<((*E$!Qa**1--EEb6M [[RYY"_??199;q>299= =-[Fs&CcR|jjjS)z(Returns a field associated with `self`. )rto_fieldr{r+s r get_fieldzPolynomialRing.get_fieldsyy!!#--//rcL|jj|jS)z%Returns True if `LC(a)` is positive. )r is_positiverHrMs rrzPolynomialRing.is_positive{{&&qtt,,rcL|jj|jS)z%Returns True if `LC(a)` is negative. )r is_negativerHrMs rrzPolynomialRing.is_negativerrcL|jj|jS)z)Returns True if `LC(a)` is non-positive. )ris_nonpositiverHrMs rrzPolynomialRing.is_nonpositive{{))!$$//rcL|jj|jS)z)Returns True if `LC(a)` is non-negative. )ris_nonnegativerHrMs rrzPolynomialRing.is_nonnegativerrc$|j|S)zExtended GCD of `a` and `b`. )gcdexrrDbs rrzPolynomialRing.gcdexswwqzrc$|j|S)zReturns GCD of `a` and `b`. )gcdrs rrzPolynomialRing.gcduuQxrc$|j|S)zReturns LCM of `a` and `b`. )lcmrs rrzPolynomialRing.lcmrrcV|j|jj|S)zReturns factorial of `a`. )rr factorialrMs rrzPolynomialRing.factorials zz$++//233r)NN)-r: __module__ __qualname____doc__is_PolynomialRingis_Polyhas_assoc_Ringhas_assoc_Fieldrr%r(propertyr*r-rr6r;r?rBrGrNrQrYr\r_rarcrergrirlrnrprsr~rrrrrrrrrrrrr r sB"&&NO0+-OU' 2'&,,,,,,,,,, >0--004rr N) rsympy.polys.domains.ringr#sympy.polys.domains.compositedomainrsympy.polys.polyerrorsrrsympy.utilitiesrr rrrrs47*?B"@4T?@4@4r