ó
    Š*£hH  ã                   ó  • S r SSKJrJr  SSKJr  SSKJr  SSKJ	r	J
r
JrJr  SSKJr  SSKJrJr  SSKJr  SS	KJrJr  \SS j5       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 S5      r$\ " S S\5      5       r%g
)z@Tools and arithmetics for monomials of distributed polynomials. é    )Úcombinations_with_replacementÚproduct)Údedent)Úcacheit)ÚMulÚSÚTupleÚsympify)ÚExactQuotientFailed)ÚPicklableWithSlotsÚdict_from_expr)Úpublic)Úis_sequenceÚiterableNc              #   óX  ^^#   • [        T5      (       Ga  [        U 5      n[        T5      U:w  a  [        S5      eTc  S/U-  mOW[        T5      (       d  [        S5      e[        T5      U:w  a  [        S5      e[        S T 5       5      (       a  [        S5      e[        UU4S j[	        U5       5       5      (       a  [        S5      e/ n[        U TT5       H6  u  pVnUR                  [	        XgS	-   5       Vs/ s H  o…U-  PM	     sn5        M8     [        U6  H  n	[        U	6 v •  M     gTn
U
S:  a  [        S
5      eTc  SnOTS:  a  [        S5      eTnXº:”  a  gU (       a  U
S:X  a  [        R                  v •  g[        U 5      [        R                  /-   n [        S U  5       5      (       a  [        X
5      nO	[        X
S9n[        5       nX«-
  nU H;  nSnU H  nUS	:X  d  M  US	-  nUU:  d  M    M"     UR                  [        U6 5        M=     U Sh  v•N   gs  snf  N
7f)aª
  
``max_degrees`` and ``min_degrees`` are either both integers or both lists.
Unless otherwise specified, ``min_degrees`` is either ``0`` or
``[0, ..., 0]``.

A generator of all monomials ``monom`` is returned, such that
either
``min_degree <= total_degree(monom) <= max_degree``,
or
``min_degrees[i] <= degree_list(monom)[i] <= max_degrees[i]``,
for all ``i``.

Case I. ``max_degrees`` and ``min_degrees`` are both integers
=============================================================

Given a set of variables $V$ and a min_degree $N$ and a max_degree $M$
generate a set of monomials of degree less than or equal to $N$ and greater
than or equal to $M$. The total number of monomials in commutative
variables is huge and is given by the following formula if $M = 0$:

    .. math::
        \frac{(\#V + N)!}{\#V! N!}

For example if we would like to generate a dense polynomial of
a total degree $N = 50$ and $M = 0$, which is the worst case, in 5
variables, assuming that exponents and all of coefficients are 32-bit long
and stored in an array we would need almost 80 GiB of memory! Fortunately
most polynomials, that we will encounter, are sparse.

Consider monomials in commutative variables $x$ and $y$
and non-commutative variables $a$ and $b$::

    >>> from sympy import symbols
    >>> from sympy.polys.monomials import itermonomials
    >>> from sympy.polys.orderings import monomial_key
    >>> from sympy.abc import x, y

    >>> sorted(itermonomials([x, y], 2), key=monomial_key('grlex', [y, x]))
    [1, x, y, x**2, x*y, y**2]

    >>> sorted(itermonomials([x, y], 3), key=monomial_key('grlex', [y, x]))
    [1, x, y, x**2, x*y, y**2, x**3, x**2*y, x*y**2, y**3]

    >>> a, b = symbols('a, b', commutative=False)
    >>> set(itermonomials([a, b, x], 2))
    {1, a, a**2, b, b**2, x, x**2, a*b, b*a, x*a, x*b}

    >>> sorted(itermonomials([x, y], 2, 1), key=monomial_key('grlex', [y, x]))
    [x, y, x**2, x*y, y**2]

Case II. ``max_degrees`` and ``min_degrees`` are both lists
===========================================================

If ``max_degrees = [d_1, ..., d_n]`` and
``min_degrees = [e_1, ..., e_n]``, the number of monomials generated
is:

.. math::
    (d_1 - e_1 + 1) (d_2 - e_2 + 1) \cdots (d_n - e_n + 1)

Let us generate all monomials ``monom`` in variables $x$ and $y$
such that ``[1, 2][i] <= degree_list(monom)[i] <= [2, 4][i]``,
``i = 0, 1`` ::

    >>> from sympy import symbols
    >>> from sympy.polys.monomials import itermonomials
    >>> from sympy.polys.orderings import monomial_key
    >>> from sympy.abc import x, y

    >>> sorted(itermonomials([x, y], [2, 4], [1, 2]), reverse=True, key=monomial_key('lex', [x, y]))
    [x**2*y**4, x**2*y**3, x**2*y**2, x*y**4, x*y**3, x*y**2]
zArgument sizes do not matchNr   zmin_degrees is not a listc              3   ó*   #   • U  H	  oS :  v •  M     g7f©r   N© )Ú.0Úis     ÚR/home/mande/repo/quber/.venv/lib/python3.13/site-packages/sympy/polys/monomials.pyÚ	<genexpr>Ú itermonomials.<locals>.<genexpr>c   s   é € Ð.¢+˜Q�q–5¢+ùó   ‚z+min_degrees cannot contain negative numbersc              3   ó:   >#   • U  H  nTU   TU   :„  v •  M     g 7f©Nr   )r   r   Úmax_degreesÚmin_degreess     €€r   r   r   e   s   øé € ÐAº°1ˆ{˜1‰~ ¨A¡Ö.ºùs   ƒz2min_degrees[i] must be <= max_degrees[i] for all ié   zmax_degrees cannot be negativezmin_degrees cannot be negativec              3   ó8   #   • U  H  oR                   v •  M     g 7fr   )Úis_commutative)r   Úvariables     r   r   r   }   s   é € ÐA²y¨8×&Ö&²yùs   ‚)Úrepeat)r   ÚlenÚ
ValueErrorÚanyÚrangeÚzipÚappendr   r   r   ÚOneÚlistÚallr   ÚsetÚadd)Ú	variablesr   r   ÚnÚpower_listsÚvarÚmin_dÚmax_dr   ÚpowersÚ
max_degreeÚ
min_degreeÚitÚmonomials_setÚdÚitemÚcountr"   s    ``               r   Úitermonomialsr=      s  ùé € ôT �;×ÒÜ�	‹NˆÜˆ{Ó˜qÓ ÜÐ:Ó;Ð;ØÑØ˜#˜a™%‰KÜ˜[×)Ñ)ÜÐ8Ó9Ð9ä�;Ó 1Ó$Ü Ð!>Ó?Ð?ÜÑ.¡+Ó.×.Ñ.Ü Ð!NÓOÐOÜÕA¼¸a¼ÓA×AÑAÜÐQÓRÐRØˆÜ!$ Y°¸[Ö!IÑˆC˜Ø×Ñ´°eÀQ¹YÔ0GÓHÒ0G¨1 Q¤Ñ0GÑHÖIñ "Jä˜{Ó+ˆFÜ�v�,Ôò ,ð !ˆ
Ø˜‹>ÜÐ=Ó>Ð>ØÑØ‰Jà˜Q‹Ü Ð!AÓBÐBØ$ˆJØÓ"ØÞ˜J¨!›OÜ—%‘%ŠKØä˜“O¤q§u¡u gÑ-ˆ	ÜÑA±yÓA×AÑAÜ.¨yÓE‰Bä˜Ñ6ˆBÜ›ˆØÑ#ˆÛˆDØˆEÛ �Ø˜q•=Ø˜Q‘J�EØ˜5•yÚñ	 !ð ×!Ñ!¤# t *Ö-ñ ð !× Ñ ùòG  IñF 	!ùs+   „C7H*Ã;H#
Ä	CH*Ç+	H*Ç8%H*ÈH(ÈH*c                 óF   • SSK Jn  U" X-   5      U" U 5      -  U" U5      -  $ )a  
Computes the number of monomials.

The number of monomials is given by the following formula:

.. math::

    \frac{(\#V + N)!}{\#V! N!}

where `N` is a total degree and `V` is a set of variables.

Examples
========

>>> from sympy.polys.monomials import itermonomials, monomial_count
>>> from sympy.polys.orderings import monomial_key
>>> from sympy.abc import x, y

>>> monomial_count(2, 2)
6

>>> M = list(itermonomials([x, y], 2))

>>> sorted(M, key=monomial_key('grlex', [y, x]))
[1, x, y, x**2, x*y, y**2]
>>> len(M)
6

r   )Ú	factorial)Ú(sympy.functions.combinatorial.factorialsr?   )ÚVÚNr?   s      r   Úmonomial_countrC   Ž   s'   € õ< CÙ�Q‘UÓ™i¨›lÑ*©Y°q«\Ñ9Ð9ó    c                 ód   • [        [        X5       VVs/ s H	  u  p#X#-   PM     snn5      $ s  snnf )a  
Multiplication of tuples representing monomials.

Examples
========

Lets multiply `x**3*y**4*z` with `x*y**2`::

    >>> from sympy.polys.monomials import monomial_mul

    >>> monomial_mul((3, 4, 1), (1, 2, 0))
    (4, 6, 1)

which gives `x**4*y**5*z`.

©Útupler(   ©ÚAÚBÚaÚbs       r   Úmonomial_mulrM   ¯   s)   € ô" ¤S¨¤YÔ0¢Y™T˜Q�1”5¡YÒ0Ó1Ð1ùÓ0ó   ”,
c                 ó^   • [        X5      n[        S U 5       5      (       a  [        U5      $ g)al  
Division of tuples representing monomials.

Examples
========

Lets divide `x**3*y**4*z` by `x*y**2`::

    >>> from sympy.polys.monomials import monomial_div

    >>> monomial_div((3, 4, 1), (1, 2, 0))
    (2, 2, 1)

which gives `x**2*y**2*z`. However::

    >>> monomial_div((3, 4, 1), (1, 2, 2)) is None
    True

`x*y**2*z**2` does not divide `x**3*y**4*z`.

c              3   ó*   #   • U  H	  oS :¬  v •  M     g7fr   r   )r   Úcs     r   r   Úmonomial_div.<locals>.<genexpr>Ú   s   é € Ð
š1�a�Ž6š1ùr   N)Úmonomial_ldivr,   rG   )rI   rJ   ÚCs      r   Úmonomial_divrU   Â   s+   € ô, 	�aÓ€Aä
Ñ
™1Ó
×ÑÜ�Q‹xˆàrD   c                 ód   • [        [        X5       VVs/ s H	  u  p#X#-
  PM     snn5      $ s  snnf )aU  
Division of tuples representing monomials.

Examples
========

Lets divide `x**3*y**4*z` by `x*y**2`::

    >>> from sympy.polys.monomials import monomial_ldiv

    >>> monomial_ldiv((3, 4, 1), (1, 2, 0))
    (2, 2, 1)

which gives `x**2*y**2*z`.

    >>> monomial_ldiv((3, 4, 1), (1, 2, 2))
    (2, 2, -1)

which gives `x**2*y**2*z**-1`.

rF   rH   s       r   rS   rS   ß   s)   € ô, ¤S¨¤YÔ0¢Y™T˜Q�1”5¡YÒ0Ó1Ð1ùÓ0rN   c                 óH   • [        U  Vs/ s H  o"U-  PM	     sn5      $ s  snf )z%Return the n-th pow of the monomial. )rG   )rI   r0   rK   s      r   Úmonomial_powrX   ÷   s!   € ä¡Ó#¢˜1�Q”3¡Ñ#Ó$Ð$ùÒ#s   Šc           
      ór   • [        [        X5       VVs/ s H  u  p#[        X#5      PM     snn5      $ s  snnf )a
  
Greatest common divisor of tuples representing monomials.

Examples
========

Lets compute GCD of `x*y**4*z` and `x**3*y**2`::

    >>> from sympy.polys.monomials import monomial_gcd

    >>> monomial_gcd((1, 4, 1), (3, 2, 0))
    (1, 2, 0)

which gives `x*y**2`.

)rG   r(   ÚminrH   s       r   Úmonomial_gcdr[   û   ó+   € ô" ¬¨Q¬Ô4ª¡ ”3�q–9©Ò4Ó5Ð5ùÓ4ó   ”3
c           
      ór   • [        [        X5       VVs/ s H  u  p#[        X#5      PM     snn5      $ s  snnf )a  
Least common multiple of tuples representing monomials.

Examples
========

Lets compute LCM of `x*y**4*z` and `x**3*y**2`::

    >>> from sympy.polys.monomials import monomial_lcm

    >>> monomial_lcm((1, 4, 1), (3, 2, 0))
    (3, 4, 1)

which gives `x**3*y**4*z`.

)rG   r(   ÚmaxrH   s       r   Úmonomial_lcmr`     r\   r]   c                 ó8   • [        S [        X5       5       5      $ )zÒ
Does there exist a monomial X such that XA == B?

Examples
========

>>> from sympy.polys.monomials import monomial_divides
>>> monomial_divides((1, 2), (3, 4))
True
>>> monomial_divides((1, 2), (0, 2))
False
c              3   ó.   #   • U  H  u  pX:*  v •  M     g 7fr   r   )r   rK   rL   s      r   r   Ú#monomial_divides.<locals>.<genexpr>.  s   é € Ð,¢)™$˜!ˆqŽv¢)ùs   ‚)r,   r(   )rI   rJ   s     r   Úmonomial_dividesrd   !  s   € ô Ñ,¤# a¤)Ó,Ó,Ð,rD   c                  ó”   • [        U S   5      nU SS  H'  n[        U5       H  u  p4[        X   U5      X'   M     M)     [        U5      $ )ai  
Returns maximal degree for each variable in a set of monomials.

Examples
========

Consider monomials `x**3*y**4*z**5`, `y**5*z` and `x**6*y**3*z**9`.
We wish to find out what is the maximal degree for each of `x`, `y`
and `z` variables::

    >>> from sympy.polys.monomials import monomial_max

    >>> monomial_max((3,4,5), (0,5,1), (6,3,9))
    (6, 5, 9)

r   r   N)r+   Ú	enumerater_   rG   ©ÚmonomsÚMrB   r   r0   s        r   Úmonomial_maxrj   0  óK   € ô" 	ˆV�A‰Y‹€Aà�A�B‹ZˆÜ˜a–L‰DˆAÜ�q‘t˜Q“<ˆA‹Dó !ñ ô �‹8€OrD   c                  ó”   • [        U S   5      nU SS  H'  n[        U5       H  u  p4[        X   U5      X'   M     M)     [        U5      $ )ai  
Returns minimal degree for each variable in a set of monomials.

Examples
========

Consider monomials `x**3*y**4*z**5`, `y**5*z` and `x**6*y**3*z**9`.
We wish to find out what is the minimal degree for each of `x`, `y`
and `z` variables::

    >>> from sympy.polys.monomials import monomial_min

    >>> monomial_min((3,4,5), (0,5,1), (6,3,9))
    (0, 3, 1)

r   r   N)r+   rf   rZ   rG   rg   s        r   Úmonomial_minrm   I  rk   rD   c                 ó   • [        U 5      $ )z­
Returns the total degree of a monomial.

Examples
========

The total degree of `xy^2` is 3:

>>> from sympy.polys.monomials import monomial_deg
>>> monomial_deg((1, 2))
3
)Úsum)ri   s    r   Úmonomial_degrp   b  s   € ô ˆq‹6€MrD   c                 ó´   • U u  p4Uu  pV[        X55      nUR                  (       a  Ub  XrR                  XF5      4$ gUb  XF-  (       d  XrR                  XF5      4$ g)z,Division of two terms in over a ring/field. N)rU   Úis_FieldÚquo)rK   rL   ÚdomainÚa_lmÚa_lcÚb_lmÚb_lcÚmonoms           r   Úterm_divrz   q  sZ   € à�J€DØ�J€Dä˜Ó$€Eà‡‡ØÑØŸ*™* TÓ0Ð0Ð0àà‘ §ØŸ*™* TÓ0Ð0Ð0àrD   c                   ó¸   ^ • \ rS rSrSr\U 4S j5       rS rS rS r	\S 5       r
\S 5       r\S	 5       r\S
 5       r\S 5       r\S 5       r\S 5       rSrU =r$ )ÚMonomialOpsiƒ  z6Code generator of fast monomial arithmetic functions. c                 ó2   >• [         TU ]  U 5      nXl        U$ r   )ÚsuperÚ__new__Úngens)Úclsr€   ÚobjÚ	__class__s      €r   r   ÚMonomialOps.__new__†  s   ø€ ä‰g‰o˜cÓ"ˆØŒ	Øˆ
rD   c                 ó   • U R                   4$ r   )r€   ©Úselfs    r   Ú__getnewargs__ÚMonomialOps.__getnewargs__Œ  s   € Ø—
‘
ˆ}ÐrD   c                 ó$   • 0 n[        X5        X2   $ r   )Úexec)r‡   ÚcodeÚnameÚnss       r   Ú_buildÚMonomialOps._build�  s   € ØˆÜˆTŒØ‰xˆrD   c                 ób   • [        U R                  5       Vs/ s H
  o!< U< 3PM     sn$ s  snf r   )r'   r€   )r‡   r�   r   s      r   Ú_varsÚMonomialOps._vars”  s*   € Ü-2°4·:±:Ô->Ó@Ò->¨™4¢Ó#Ñ->Ñ@Ð@ùÒ@s   ˜,c                 óF  • Sn[        S5      nU R                  S5      nU R                  S5      n[        X45       VVs/ s H  u  pVU< SU< 3PM     nnnX!SR                  U5      SR                  U5      SR                  U5      S.-  nU R	                  X�5      $ s  snnf )NrM   ús        def %(name)s(A, B):
            (%(A)s,) = A
            (%(B)s,) = B
            return (%(AB)s,)
        rK   rL   ú + ú, ©r�   rI   rJ   ÚAB©r   r’   r(   Újoinr�   ©	r‡   r�   ÚtemplaterI   rJ   rK   rL   r™   rŒ   s	            r   ÚmulÚMonomialOps.mul—  s“   € àˆÜð ó ˆð �J‰J�s‹OˆØ�J‰J�s‹OˆÜ.1°!¬iÔ9ªi¡d a›AšqÓ!©iˆÑ9Ø¨d¯i©i¸«lÀÇÁÈ1ÃÐUY×U^ÑU^Ð_aÓUbÑcÑcˆØ�{‰{˜4Ó&Ð&ùó :ó   ¾Bc                 óà   • Sn[        S5      nU R                  S5      nU Vs/ s H  nSU-  PM
     nnX!SR                  U5      SR                  U5      S.-  nU R                  Xa5      $ s  snf )NrX   zZ        def %(name)s(A, k):
            (%(A)s,) = A
            return (%(Ak)s,)
        rK   z%s*kr—   )r�   rI   ÚAk)r   r’   r›   r�   )r‡   r�   r�   rI   rK   r¢   rŒ   s          r   ÚpowÚMonomialOps.pow¦  sp   € àˆÜð ó ˆð
 �J‰J�s‹OˆÙ#$Ó&¢1˜aˆv˜Œz¡1ˆÐ&Ø¨d¯i©i¸«lÀ$Ç)Á)ÈBÃ-ÑPÑPˆØ�{‰{˜4Ó&Ð&ùò 's   £A+c                 óH  • Sn[        S5      nU R                  S5      nU R                  S5      n[        X45       VVs/ s H  u  pVU< SU< S3PM     nnnX!SR                  U5      SR                  U5      SR                  U5      S.-  nU R	                  X�5      $ s  snnf )	NÚmonomial_mulpowzw        def %(name)s(A, B, k):
            (%(A)s,) = A
            (%(B)s,) = B
            return (%(ABk)s,)
        rK   rL   r–   z*kr—   )r�   rI   rJ   ÚABkrš   )	r‡   r�   r�   rI   rJ   rK   rL   r§   rŒ   s	            r   ÚmulpowÚMonomialOps.mulpow³  s“   € à ˆÜð ó ˆð �J‰J�s‹OˆØ�J‰J�s‹OˆÜ14°Q´Ô<²©¨›q£!Ó$±ˆÑ<Ø¨d¯i©i¸«lÀÇÁÈ1ÃÐVZ×V_ÑV_Ð`cÓVdÑeÑeˆØ�{‰{˜4Ó&Ð&ùó =s   ¾Bc                 óF  • Sn[        S5      nU R                  S5      nU R                  S5      n[        X45       VVs/ s H  u  pVU< SU< 3PM     nnnX!SR                  U5      SR                  U5      SR                  U5      S.-  nU R	                  X�5      $ s  snnf )NrS   r•   rK   rL   z - r—   r˜   rš   rœ   s	            r   ÚldivÚMonomialOps.ldivÂ  s“   € àˆÜð ó ˆð �J‰J�s‹OˆØ�J‰J�s‹OˆÜ.1°!¬iÔ9ªi¡d a›AšqÓ!©iˆÑ9Ø¨d¯i©i¸«lÀÇÁÈ1ÃÐUY×U^ÑU^Ð_aÓUbÑcÑcˆØ�{‰{˜4Ó&Ð&ùó :r    c                 óŽ  • Sn[        S5      nU R                  S5      nU R                  S5      n[        U R                  5       Vs/ s H
  nSSU0-  PM     nnU R                  S5      nX!SR	                  U5      SR	                  U5      S	R	                  U5      SR	                  U5      S
.-  nU R                  X�5      $ s  snf )NrU   z†        def %(name)s(A, B):
            (%(A)s,) = A
            (%(B)s,) = B
            %(RAB)s
            return (%(R)s,)
        rK   rL   z7r%(i)s = a%(i)s - b%(i)s
    if r%(i)s < 0: return Noner   Úrr—   z
    )r�   rI   rJ   ÚRABÚR)r   r’   r'   r€   r›   r�   )	r‡   r�   r�   rI   rJ   r   r¯   r°   rŒ   s	            r   ÚdivÚMonomialOps.divÑ  s¿   € àˆÜð ó ˆð �J‰J�s‹OˆØ�J‰J�s‹OˆÜ_dÐei×eoÑeoÔ_pÓrÒ_pÐZ[ÐJÈcÐSTÈXÔUÑ_pˆÐrØ�J‰J�s‹OˆØ¨d¯i©i¸«lÀÇÁÈ1ÃÐV^×VcÑVcÐdgÓVhÐos×oxÑoxÐyzÓo{Ñ|Ñ|ˆØ�{‰{˜4Ó&Ð&ùò ss   ÁCc                 óV  • Sn[        S5      nU R                  S5      nU R                  S5      n[        X45       VVs/ s H  u  pVU< SU< SU< SU< 3PM     nnnX!SR                  U5      SR                  U5      SR                  U5      S	.-  nU R	                  X�5      $ s  snnf )
Nr`   r•   rK   rL   ú if z >= ú else r—   r˜   rš   rœ   s	            r   ÚlcmÚMonomialOps.lcmâ  ó˜   € àˆÜð ó ˆð �J‰J�s‹OˆØ�J‰J�s‹OˆÜCFÀqÄ9ÔNÂ9¹4¸1«1«a³²AÓ6Á9ˆÑNØ¨d¯i©i¸«lÀÇÁÈ1ÃÐUY×U^ÑU^Ð_aÓUbÑcÑcˆØ�{‰{˜4Ó&Ð&ùó Oó   ¾B%c                 óV  • Sn[        S5      nU R                  S5      nU R                  S5      n[        X45       VVs/ s H  u  pVU< SU< SU< SU< 3PM     nnnX!SR                  U5      SR                  U5      SR                  U5      S	.-  nU R	                  X�5      $ s  snnf )
Nr[   r•   rK   rL   r´   z <= rµ   r—   r˜   rš   rœ   s	            r   ÚgcdÚMonomialOps.gcdñ  r¸   r¹   r   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   rˆ   r�   r’   rž   r£   r¨   r«   r±   r¶   r»   Ú__static_attributes__Ú__classcell__)rƒ   s   @r   r|   r|   ƒ  s´   ø† Ù@àôó ðò
òò
Að ñ'ó ð'ð ñ
'ó ð
'ð ñ'ó ð'ð ñ'ó ð'ð ñ'ó ð'ð  ñ'ó ð'ð ñ'ó ö'rD   r|   c                   ó‚   • \ rS rSrSrSrSS jrSS jrS rS r	S	 r
S
 rS rS rS rS rS rS r\rS rS rS rSrg)ÚMonomiali   z9Class representing a monomial, i.e. a product of powers. )Ú	exponentsÚgensNc                 ób  • [        U5      (       d{  [        [        U5      US9u  p2[        U5      S:X  a=  [	        UR                  5       5      S   S:X  a  [	        UR                  5       5      S   nO[        SR                  U5      5      e[        [        [        U5      5      U l        X l        g )N)rÇ   r   r   zExpected a monomial got {})r   r   r
   r$   r+   ÚvaluesÚkeysr%   ÚformatrG   ÚmapÚintrÆ   rÇ   )r‡   ry   rÇ   Úreps       r   Ú__init__ÚMonomial.__init__  s‚   € Ü˜�‰Ü&¤w¨u£~¸DÑA‰IˆCÜ�3‹x˜1‹}¤ c§j¡j£lÓ!3°AÑ!6¸!Ó!;Ü˜SŸX™X›ZÓ(¨Ñ+‘ä Ð!=×!DÑ!DÀUÓ!KÓLÐLäœs¤3¨›Ó/ˆŒØ�	rD   c                 óJ   • U R                  X=(       d    U R                  5      $ r   )rƒ   rÇ   )r‡   rÆ   rÇ   s      r   ÚrebuildÚMonomial.rebuild  s   € Ø�~‰~˜i×):°·±Ó;Ð;rD   c                 ó,   • [        U R                  5      $ r   )r$   rÆ   r†   s    r   Ú__len__ÚMonomial.__len__  s   € Ü�4—>‘>Ó"Ð"rD   c                 ó,   • [        U R                  5      $ r   )ÚiterrÆ   r†   s    r   Ú__iter__ÚMonomial.__iter__  s   € Ü�D—N‘NÓ#Ð#rD   c                 ó    • U R                   U   $ r   )rÆ   )r‡   r;   s     r   Ú__getitem__ÚMonomial.__getitem__  s   € Ø�~‰~˜dÑ#Ð#rD   c                 ón   • [        U R                  R                  U R                  U R                  45      $ r   )Úhashrƒ   r½   rÆ   rÇ   r†   s    r   Ú__hash__ÚMonomial.__hash__  s&   € Ü�T—^‘^×,Ñ,¨d¯n©n¸d¿i¹iÐHÓIÐIrD   c           	      ó  • U R                   (       aK  SR                  [        U R                   U R                  5       VVs/ s H  u  pU< SU< 3PM     snn5      $ U R                  R
                  < SU R                  < S3$ s  snnf )NÚ*z**Ú(Ú))rÇ   r›   r(   rÆ   rƒ   r½   )r‡   ÚgenÚexps      r   Ú__str__ÚMonomial.__str__   sa   € Ø�9�9Ø—8‘8ÄCÈÏ	É	ÐSW×SaÑSaÔDbÔdÒDb¹¸«#ªsÓ3ÑDbÒdÓeÐeà#Ÿ~™~×6Ô6¸¿¼ÐGÐGùó es   Á B
c                 óÆ   • U=(       d    U R                   nU(       d  [        SU -  5      e[        [        XR                  5       VVs/ s H	  u  p#X#-  PM     snn6 $ s  snnf )z3Convert a monomial instance to a SymPy expression. z5Cannot convert %s to an expression without generators)rÇ   r%   r   r(   rÆ   )r‡   rÇ   ræ   rç   s       r   Úas_exprÚMonomial.as_expr&  sX   € à× �t—y‘yˆæÜØGÈ$ÑNóPð Pô ¬s°4¿¹Ô/HÔJÒ/H¡8 3�c”hÑ/HÒJÐKÐKùÓJs   ÁA
c                 ó¢   • [        U[        5      (       a  UR                  nO[        U[        [        45      (       a  UnOgU R                  U:H  $ )NF)Ú
isinstancerÅ   rÆ   rG   r	   ©r‡   ÚotherrÆ   s      r   Ú__eq__ÚMonomial.__eq__0  s@   € Ü�eœX×&Ñ&ØŸ™‰IÜ˜¤¤u˜~×.Ñ.Ø‰Iàà�~‰~ Ñ*Ð*rD   c                 ó   • X:X  + $ r   r   )r‡   rð   s     r   Ú__ne__ÚMonomial.__ne__:  s   € ØÒ Ð rD   c                 óØ   • [        U[        5      (       a  UR                  nO$[        U[        [        45      (       a  UnO[
        eU R                  [        U R                  U5      5      $ r   )rî   rÅ   rÆ   rG   r	   ÚNotImplementedErrorrÒ   rM   rï   s      r   Ú__mul__ÚMonomial.__mul__=  sN   € Ü�eœX×&Ñ&ØŸ™‰IÜ˜¤¤u˜~×.Ñ.Ø‰Iä%Ð%à�|‰|œL¨¯©¸ÓCÓDÐDrD   c                 ó  • [        U[        5      (       a  UR                  nO$[        U[        [        45      (       a  UnO[
        e[        U R                  U5      nUb  U R                  U5      $ [        U [        U5      5      er   )	rî   rÅ   rÆ   rG   r	   r÷   rU   rÒ   r   )r‡   rð   rÆ   Úresults       r   Ú__truediv__ÚMonomial.__truediv__G  sj   € Ü�eœX×&Ñ&ØŸ™‰IÜ˜¤¤u˜~×.Ñ.Ø‰Iä%Ð%ä˜dŸn™n¨iÓ8ˆàÑØ—<‘< Ó'Ð'ä% d¬H°U«OÓ<Ð<rD   c                 óŠ   • [        U5      nUS:  a  [        SU-  5      eU R                  [        U R                  U5      5      $ )Nr   z'a non-negative integer expected, got %s)rÍ   r%   rÒ   rX   rÆ   )r‡   rð   r0   s      r   Ú__pow__ÚMonomial.__pow__X  s=   € Ü�‹JˆØˆq‹5ÜÐFÈÑNÓOÐOØ�|‰|œL¨¯©¸Ó;Ó<Ð<rD   c                 óè   • [        U[        5      (       a  UR                  nO,[        U[        [        45      (       a  UnO[        SU-  5      eU R                  [        U R                  U5      5      $ )z&Greatest common divisor of monomials. ú.an instance of Monomial class expected, got %s)rî   rÅ   rÆ   rG   r	   Ú	TypeErrorrÒ   r[   rï   s      r   r»   ÚMonomial.gcd^  óa   € ä�eœX×&Ñ&ØŸ™‰IÜ˜¤¤u˜~×.Ñ.Ø‰IäØ@À5ÑHóJð Jð �|‰|œL¨¯©¸ÓCÓDÐDrD   c                 óè   • [        U[        5      (       a  UR                  nO,[        U[        [        45      (       a  UnO[        SU-  5      eU R                  [        U R                  U5      5      $ )z$Least common multiple of monomials. r  )rî   rÅ   rÆ   rG   r	   r  rÒ   r`   rï   s      r   r¶   ÚMonomial.lcmj  r  rD   r   )r½   r¾   r¿   rÀ   rÁ   Ú	__slots__rÏ   rÒ   rÕ   rÙ   rÜ   rà   rè   rë   rñ   rô   rø   rü   Ú__floordiv__rÿ   r»   r¶   rÂ   r   rD   r   rÅ   rÅ      sb   † áCà%€Iô	ô<ò#ò$ò$òJòHòLò+ò!òEò=ð €Lò=ò
Eõ
ErD   rÅ   r   )&rÁ   Ú	itertoolsr   r   Útextwrapr   Úsympy.core.cacher   Ú
sympy.corer   r   r	   r
   Úsympy.polys.polyerrorsr   Úsympy.polys.polyutilsr   r   Úsympy.utilitiesr   Úsympy.utilities.iterablesr   r   r=   rC   rM   rU   rS   rX   r[   r`   rd   rj   rm   rp   rz   r|   rÅ   r   rD   r   Ú<module>r     s¦   ðÙ F÷ =Ý å $ß -Ó -Ý 6ß DÝ "ß ;àó}!ó ð}!ò~:òB2ò&ò:2ò0%ò6ò&6ò&-òò2ò2ò÷${'ñ {'ðz ôsEÐ!ó sEó ñsErD   