Ë
    O/æjI  ã                   ó  — d Z ddlmZmZ ddlmZ ddlmZmZm	Z	m
Z
 ddlmZ ddlmZmZ ddlmZ ddlmZmZ edd
„«       Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z d„ Z! G d„ d«      Z"e G d„ de«      «       Z#y	)z@Tools and arithmetics for monomials of distributed polynomials. é    )Úcombinations_with_replacementÚproduct)Údedent)ÚMulÚSÚTupleÚsympify)ÚExactQuotientFailed)ÚPicklableWithSlotsÚdict_from_expr)Úpublic)Úis_sequenceÚiterableNc              #   óh  ‡‡K  — t        | «      }t        ‰«      rqt        ‰«      |k7  rt        d«      ‚‰€dg|z  ŠnLt        ‰«      st        d«      ‚t        ‰«      |k7  rt        d«      ‚t        d„ ‰D «       «      rt        d«      ‚d}n+‰}|dk  rt        d«      ‚‰€d}n‰dk  rt        d	«      ‚‰}d
}|�rfkD  ry| r|dk(  rt        j
                  –— yt        | «      t        j
                  gz   } t        d„ | D «       «      r‹g }t        | |«      D ]f  }t        j                  | d«      }	|D ]  }
|
dk7  sŒ	|	|
xx   dz  cc<   Œ t        |	j                  «       «      |k\  sŒP|j                  t        |Ž «       Œh t        |«      E d{  –—†  yg }t!        | |¬«      D ]f  }t        j                  | d«      }	|D ]  }
|
dk7  sŒ	|	|
xx   dz  cc<   Œ t        |	j                  «       «      |k\  sŒP|j                  t        |Ž «       Œh t        |«      E d{  –—†  yt        ˆˆfd„t#        |«      D «       «      rt        d«      ‚g }t%        | ‰‰«      D ]5  \  }}}|j                  t#        ||dz   «      D �cg c]  }||z  ‘Œ	 c}«       Œ7 t!        |Ž D ]  }	t        |	Ž –— Œ y7 �Œ7 Œ�c c}w ­w)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   ó&   K  — | ]	  }|d k  –— Œ y­w©r   N© )Ú.0Úis     úX/root/repos/pocs/video-evals/.venv/lib/python3.12/site-packages/sympy/polys/monomials.pyú	<genexpr>z itermonomials.<locals>.<genexpr>b   s   è ø€ Ò.˜Q�1�q•5Ñ.ùó   ‚z+min_degrees cannot contain negative numbersFzmax_degrees cannot be negativezmin_degrees cannot be negativeTc              3   ó4   K  — | ]  }|j                   –— Œ y ­w©N)Úis_commutative)r   Úvariables     r   r   z itermonomials.<locals>.<genexpr>x   s   è ø€ ÒA¨8ˆx×&Õ&ÑAùs   ‚é   )Úrepeatc              3   ó4   •K  — | ]  }‰|   ‰|   kD  –— Œ y ­wr   r   )r   r   Úmax_degreesÚmin_degreess     €€r   r   z itermonomials.<locals>.<genexpr>�   s   øè ø€ ÒA°1ˆ{˜1‰~ ¨A¡Õ.ÑAùs   ƒz2min_degrees[i] must be <= max_degrees[i] for all i)Úlenr   Ú
ValueErrorÚanyr   ÚOneÚlistÚallr   ÚdictÚfromkeysÚsumÚvaluesÚappendr   Úsetr   ÚrangeÚzip)Ú	variablesr    r!   ÚnÚtotal_degreeÚ
max_degreeÚ
min_degreeÚmonomials_list_commÚitemÚpowersr   Úmonomials_list_non_commÚpower_listsÚvarÚmin_dÚmax_dr   s    ``              r   Úitermonomialsr=      sÅ  ùè ø€ ôT 	ˆI‹€AÜ�;ÔÜˆ{Ó˜qÒ ÜÐ:Ó;Ð;ØÐØ˜#˜a™%‰KÜ˜[Ô)ÜÐ8Ó9Ð9ä�;Ó 1Ò$Ü Ð!>Ó?Ð?ÜÑ. +Ô.Ô.Ü Ð!NÓOÐOØ‰à ˆ
Ø˜Š>ÜÐ=Ó>Ð>ØÐØ‰Jà˜QŠÜ Ð!AÓBÐBØ$ˆJØˆÚØ˜
Ò"ØÙ˜J¨!šOÜ—%‘%ŠKØä˜“O¤q§u¡u gÑ-ˆ	ÜÑA°yÔAÔAØ"$ÐÜ5°iÀÓLò ;�ÜŸ™ y°!Ó4�Ø $ò .�HØ 1“}Ø˜xÓ(¨AÑ-Ô(ð.ô �v—}‘}“Ó'¨:Ó5Ø'×.Ñ.¬s°D¨zÕ:ð;ô Ð.Ó/×/Ñ/à&(Ð#Ü 	°*Ô=ò ?�ÜŸ™ y°!Ó4�Ø $ò .�HØ 1“}Ø˜xÓ(¨AÑ-Ô(ð.ô �v—}‘}“Ó'¨:Ó5Ø+×2Ñ2´3¸°:Õ>ð?ô Ð2Ó3×3Ñ3äÔA¼¸a»ÔAÔAÜÐQÓRÐRØˆÜ!$ Y°¸[Ó!Iò 	JÑˆC�˜Ø×Ñ´°e¸UÀQ¹YÓ0GÖH¨1  Q£ÒHÕIð	Jä˜{Ð+ò 	ˆFÜ�v�,Óñ	ð# 0ùð 4úò  IùsO   „D6J2Ä;+J2Å''J2ÆJ(Æ7J2Ç+J2Ç3'J2ÈJ+ÈA J2É;J-
Ê"J2Ê+J2Ê-J2c                 óH   — ddl m}  || |z   «       || «      z   ||«      z  S )aW  
    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   — t        t        | |«      D ��cg c]
  \  }}||z   ‘Œ c}}«      S c c}}w )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¨¨A£Y×0™T˜Q �1�q“5Ó0Ó1Ð1ùÓ0ó   •,
c                 óV   — t        | |«      }t        d„ |D «       «      rt        |«      S y)aœ  
    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   ó&   K  — | ]	  }|d k\  –— Œ y­wr   r   )r   Úcs     r   r   zmonomial_div.<locals>.<genexpr>á   s   è ø€ Ò
�aˆ1��6Ñ
ùr   N)Úmonomial_ldivr'   rG   )rI   rJ   ÚCs      r   Úmonomial_divrT   É   s*   € ô, 	�a˜Ó€Aä
Ñ
˜1Ô
ÔÜ�Q‹xˆàrD   c                 ód   — t        t        | |«      D ��cg c]
  \  }}||z
  ‘Œ c}}«      S c c}}w )a…  
    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   rR   rR   æ   s+   € ô, ¤S¨¨A£Y×0™T˜Q �1�q“5Ó0Ó1Ð1ùÓ0rN   c                 óD   — t        | D �cg c]  }||z  ‘Œ	 c}«      S c c}w )z%Return the n-th pow of the monomial. )rG   )rI   r1   rK   s      r   Úmonomial_powrW   þ   s   € ä Ö#˜1�1�Q“3Ò#Ó$Ð$ùÒ#s   Šc           
      ór   — t        t        | |«      D ��cg c]  \  }}t        ||«      ‘Œ c}}«      S c c}}w )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_gcdrZ     ó-   € ô" ¬¨Q°«×4¡  A”3�q˜!•9Ó4Ó5Ð5ùÓ4ó   •3
c           
      ór   — t        t        | |«      D ��cg c]  \  }}t        ||«      ‘Œ c}}«      S c c}}w )a1  
    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                 ó:   — t        d„ t        | |«      D «       «      S )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   ó,   K  — | ]  \  }}||k  –— Œ y ­wr   r   )r   rK   rL   s      r   r   z#monomial_divides.<locals>.<genexpr>5  s   è ø€ Ò,™$˜!˜Qˆq�A�vÑ,ùs   ‚)r'   r/   )rI   rJ   s     r   Úmonomial_dividesrb   (  s   € ô Ñ,¤# a¨£)Ô,Ó,Ð,rD   c                  ó’   — t        | d   «      }| dd D ]'  }t        |«      D ]  \  }}t        ||   |«      ||<   Œ Œ) t        |«      S )a‘  
    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   r1   s        r   Úmonomial_maxrh   7  ó[   € ô" 	ˆV�A‰Y‹€Aà�A�BˆZò  ˆÜ˜a“Lò 	 ‰DˆAˆqÜ�q˜‘t˜Q“<ˆAˆaŠDñ	 ð ô �‹8€OrD   c                  ó’   — t        | d   «      }| dd D ]'  }t        |«      D ]  \  }}t        ||   |«      ||<   Œ Œ) t        |«      S )a‘  
    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&   rd   rY   rG   re   s        r   Úmonomial_minrk   P  ri   rD   c                 ó   — t        | «      S )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
    )r*   )rg   s    r   Úmonomial_degrm   i  s   € ô ˆq‹6€MrD   c                 ó¬   — | \  }}|\  }}t        ||«      }|j                  r|�||j                  ||«      fS y|�||z  s||j                  ||«      fS y)z,Division of two terms in over a ring/field. N)rT   Úis_FieldÚquo)rK   rL   ÚdomainÚa_lmÚa_lcÚb_lmÚb_lcÚmonoms           r   Úterm_divrw   x  sj   € à�J€Dˆ$Ø�J€Dˆ$ä˜˜tÓ$€Eà‡‚ØÐØ˜&Ÿ*™* T¨4Ó0Ð0Ð0àà� ¨¢Ø˜&Ÿ*™* T¨4Ó0Ð0Ð0àrD   c                   óL   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
„ Zd„ Zy)ÚMonomialOpsz6Code generator of fast monomial arithmetic functions. c                 ó   — || _         y r   )Úngens)Úselfr{   s     r   Ú__init__zMonomialOps.__init__�  s	   € Øˆ�
rD   c                 ó(   — i }t        ||«       ||   S r   )Úexec)r|   ÚcodeÚnameÚnss       r   Ú_buildzMonomialOps._build�  s   € ØˆÜˆT�2ŒØ�$‰xˆrD   c                 óZ   — t        | j                  «      D �cg c]  }|›|›�‘Œ
 c}S c c}w r   )r.   r{   )r|   r�   r   s      r   Ú_varszMonomialOps._vars•  s$   € Ü-2°4·:±:Ó->Ö@¨™4¡Ò#Ò@Ð@ùÒ@s   ˜(c                 óD  — d}t        d«      }| j                  d«      }| j                  d«      }t        ||«      D ��cg c]  \  }}|›d|›�‘Œ }}}||dj                  |«      dj                  |«      dj                  |«      dœz  }| j	                  ||«      S c c}}w )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   ÚmulzMonomialOps.mul˜  sš   € ØˆÜð ó ˆð �J‰J�s‹OˆØ�J‰J�s‹OˆÜ.1°!°Q«i×9¡d a¨šA™qÒ!Ð9ˆÑ9Ø 4¨d¯i©i¸«lÀÇÁÈ1ÃÐUY×U^ÑU^Ð_aÓUbÑcÑcˆØ�{‰{˜4 Ó&Ð&ùó :ó   ¿Bc                 óÞ   — d}t        d«      }| j                  d«      }|D �cg c]  }d|z  ‘Œ	 }}||dj                  |«      dj                  |«      dœz  }| j                  ||«      S c c}w )NrW   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   ÚpowzMonomialOps.pow¦  ss   € ØˆÜð ó ˆð
 �J‰J�s‹OˆØ#$Ö&˜aˆv˜‹zÐ&ˆÐ&Ø 4¨d¯i©i¸«lÀ$Ç)Á)ÈBÃ-ÑPÑPˆØ�{‰{˜4 Ó&Ð&ùò 's   £A*c                 óF  — d}t        d«      }| j                  d«      }| j                  d«      }t        ||«      D ��cg c]  \  }}|›d|›d�‘Œ }}}||dj                  |«      dj                  |«      dj                  |«      dœz  }| j	                  ||«      S c c}}w )	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   ÚmulpowzMonomialOps.mulpow²  sš   € Ø ˆÜð ó ˆð �J‰J�s‹OˆØ�J‰J�s‹OˆÜ14°Q¸³×<©¨¨Ašq¢!Ò$Ð<ˆÑ<Ø 4¨d¯i©i¸«lÀÇÁÈ1ÃÐVZ×V_ÑV_Ð`cÓVdÑeÑeˆØ�{‰{˜4 Ó&Ð&ùó =s   ¿Bc                 óD  — d}t        d«      }| j                  d«      }| j                  d«      }t        ||«      D ��cg c]  \  }}|›d|›�‘Œ }}}||dj                  |«      dj                  |«      dj                  |«      dœz  }| j	                  ||«      S c c}}w )NrR   r‡   rK   rL   z - r‰   rŠ   rŒ   rŽ   s	            r   ÚldivzMonomialOps.ldivÀ  sš   € ØˆÜð ó ˆð �J‰J�s‹OˆØ�J‰J�s‹OˆÜ.1°!°Q«i×9¡d a¨šA™qÒ!Ð9ˆÑ9Ø 4¨d¯i©i¸«lÀÇÁÈ1ÃÐUY×U^ÑU^Ð_aÓUbÑcÑcˆØ�{‰{˜4 Ó&Ð&ùó :r‘   c                 óŒ  — d}t        d«      }| j                  d«      }| j                  d«      }t        | j                  «      D �cg c]	  }dd|iz  ‘Œ }}| j                  d«      }||dj	                  |«      dj	                  |«      d	j	                  |«      dj	                  |«      d
œz  }| j                  ||«      S c c}w )NrT   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   ÚdivzMonomialOps.divÎ  sÀ   € ØˆÜð ó ˆð �J‰J�s‹OˆØ�J‰J�s‹OˆÜ_dÐei×eoÑeoÓ_pÖrÐZ[ÐJÈcÐSTÈXÓUÐrˆÐrØ�J‰J�s‹OˆØ 4¨d¯i©i¸«lÀÇÁÈ1ÃÐV^×VcÑVcÐdgÓVhÐos×oxÑoxÐyzÓo{Ñ|Ñ|ˆØ�{‰{˜4 Ó&Ð&ùò ss   ÁCc                 óP  — d}t        d«      }| j                  d«      }| j                  d«      }t        ||«      D ��cg c]  \  }}|›d|›d|›d|›�‘Œ }}}||dj                  |«      dj                  |«      dj                  |«      d	œz  }| j	                  ||«      S c c}}w )
Nr_   r‡   rK   rL   ú if z >= ú else r‰   rŠ   rŒ   rŽ   s	            r   ÚlcmzMonomialOps.lcmÞ  óŸ   € ØˆÜð ó ˆð �J‰J�s‹OˆØ�J‰J�s‹OˆÜCFÀqÈ!Ã9×N¹4¸1¸aª1ªa²±AÒ6ÐNˆÑNØ 4¨d¯i©i¸«lÀÇÁÈ1ÃÐUY×U^ÑU^Ð_aÓUbÑcÑcˆØ�{‰{˜4 Ó&Ð&ùó Oó   ¿B"c                 óP  — d}t        d«      }| j                  d«      }| j                  d«      }t        ||«      D ��cg c]  \  }}|›d|›d|›d|›�‘Œ }}}||dj                  |«      dj                  |«      dj                  |«      d	œz  }| j	                  ||«      S c c}}w )
NrZ   r‡   rK   rL   r¡   z <= r¢   r‰   rŠ   rŒ   rŽ   s	            r   ÚgcdzMonomialOps.gcdì  r¤   r¥   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r}   rƒ   r…   r�   r”   r˜   rš   rŸ   r£   r§   r   rD   r   ry   ry   Š  s8   „ Ù@òòò
Aò'ò
'ò'ò'ò'ò 'ó'rD   ry   c                   óv   — e Zd ZdZdZdd„Zdd„Zd„ Zd„ Zd„ Z	d	„ Z
d
„ Zd„ Zd„ Zd„ Zd„ Zd„ ZeZd„ Zd„ Zd„ Zy)ÚMonomialz9Class representing a monomial, i.e. a product of powers. )Ú	exponentsÚgensNc                 ó^  — t        |«      s}t        t        |«      |¬«      \  }}t        |«      dk(  r<t	        |j                  «       «      d   dk(  rt	        |j                  «       «      d   }nt        dj                  |«      «      ‚t        t        t        |«      «      | _        || _        y )N)r¯   r   r   zExpected a monomial got {})r   r   r	   r"   r&   r+   Úkeysr#   ÚformatrG   ÚmapÚintr®   r¯   )r|   rv   r¯   Úreps       r   r}   z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                 óB   — | j                  ||xs | j                  «      S r   )Ú	__class__r¯   )r|   r®   r¯   s      r   ÚrebuildzMonomial.rebuild  s   € Ø�~‰~˜i¨Ò):°·±Ó;Ð;rD   c                 ó,   — t        | j                  «      S r   )r"   r®   ©r|   s    r   Ú__len__zMonomial.__len__  s   € Ü�4—>‘>Ó"Ð"rD   c                 ó,   — t        | j                  «      S r   )Úiterr®   rº   s    r   Ú__iter__zMonomial.__iter__  s   € Ü�D—N‘NÓ#Ð#rD   c                 ó    — | j                   |   S r   )r®   )r|   r6   s     r   Ú__getitem__zMonomial.__getitem__  s   € Ø�~‰~˜dÑ#Ð#rD   c                 ón   — t        | j                  j                  | j                  | j                  f«      S r   )Úhashr·   r¨   r®   r¯   rº   s    r   Ú__hash__zMonomial.__hash__  s&   € Ü�T—^‘^×,Ñ,¨d¯n©n¸d¿i¹iÐHÓIÐIrD   c           	      ó   — | j                   rGdj                  t        | j                   | j                  «      D ��cg c]  \  }}|›d|›�‘Œ c}}«      S | j                  j
                  ›d| j                  ›d�S c c}}w )NÚ*z**ú(ú))r¯   r�   r/   r®   r·   r¨   )r|   ÚgenÚexps      r   Ú__str__zMonomial.__str__  s]   € Ø�9Š9Ø—8‘8ÄCÈÏ	É	ÐSW×SaÑSaÓDb×d¹¸¸Sª#©sÒ3ÓdÓeÐeà#Ÿ~™~×6Ó6¸¿»ÐGÐGùó es   »A:
c                 ó²   — |xs | j                   }|st        d| z  «      ‚t        t        || j                  «      D ��cg c]
  \  }}||z  ‘Œ c}}Ž S c c}}w )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_exprzMonomial.as_expr   sX   € àÒ �t—y‘yˆáÜØGÈ$ÑNóPð Pô ¬s°4¸¿¹Ó/H×J¡8 3¨�c˜3“hÓJÐKÐKùÓJs   ¿A
c                 óŽ   — t        |t        «      r|j                  }nt        |t        t        f«      r|}ny| j                  |k(  S )NF)Ú
isinstancer­   r®   rG   r   ©r|   Úotherr®   s      r   Ú__eq__zMonomial.__eq__*  s:   € Ü�eœXÔ&ØŸ™‰IÜ˜¤¤u˜~Ô.Ø‰Iàà�~‰~ Ñ*Ð*rD   c                 ó   — | |k(   S r   r   )r|   rÐ   s     r   Ú__ne__zMonomial.__ne__4  s   € Ø˜5‘=Ð Ð rD   c                 óÄ   — t        |t        «      r|j                  }nt        |t        t        f«      r|}nt
        ‚| j                  t        | j                  |«      «      S r   )rÎ   r­   r®   rG   r   ÚNotImplementedErrorr¸   rM   rÏ   s      r   Ú__mul__zMonomial.__mul__7  sH   € Ü�eœXÔ&ØŸ™‰IÜ˜¤¤u˜~Ô.Ø‰Iä%Ð%à�|‰|œL¨¯©¸ÓCÓDÐDrD   c                 óö   — t        |t        «      r|j                  }nt        |t        t        f«      r|}nt
        ‚t        | j                  |«      }|�| j                  |«      S t        | t        |«      «      ‚r   )	rÎ   r­   r®   rG   r   rÕ   rT   r¸   r
   )r|   rÐ   r®   Úresults       r   Ú__truediv__zMonomial.__truediv__A  sd   € Ü�eœXÔ&ØŸ™‰IÜ˜¤¤u˜~Ô.Ø‰Iä%Ð%ä˜dŸn™n¨iÓ8ˆàÐØ—<‘< Ó'Ð'ä% d¬H°U«OÓ<Ð<rD   c                 óˆ   — t        |«      }|dk  rt        d|z  «      ‚| j                  t        | j                  |«      «      S )Nr   z'a non-negative integer expected, got %s)r´   r#   r¸   rW   r®   )r|   rÐ   r1   s      r   Ú__pow__zMonomial.__pow__R  s=   € Ü�‹JˆØˆqŠ5ÜÐFÈÑNÓOÐOØ�|‰|œL¨¯©¸Ó;Ó<Ð<rD   c                 óÔ   — t        |t        «      r|j                  }n't        |t        t        f«      r|}nt        d|z  «      ‚| j                  t        | j                  |«      «      S )z&Greatest common divisor of monomials. ú.an instance of Monomial class expected, got %s)rÎ   r­   r®   rG   r   Ú	TypeErrorr¸   rZ   rÏ   s      r   r§   zMonomial.gcdX  ó[   € ä�eœXÔ&ØŸ™‰IÜ˜¤¤u˜~Ô.Ø‰IäØ@À5ÑHóJð Jð �|‰|œL¨¯©¸ÓCÓDÐDrD   c                 óÔ   — t        |t        «      r|j                  }n't        |t        t        f«      r|}nt        d|z  «      ‚| j                  t        | j                  |«      «      S )z$Least common multiple of monomials. rÝ   )rÎ   r­   r®   rG   r   rÞ   r¸   r_   rÏ   s      r   r£   zMonomial.lcmd  rß   rD   r   )r¨   r©   rª   r«   Ú	__slots__r}   r¸   r»   r¾   rÀ   rÃ   rÊ   rÌ   rÑ   rÓ   rÖ   rÙ   Ú__floordiv__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.corer   r   r   r	   Úsympy.polys.polyerrorsr
   Úsympy.polys.polyutilsr   r   Úsympy.utilitiesr   Úsympy.utilities.iterablesr   r   r=   rC   rM   rT   rR   rW   rZ   r_   rb   rh   rk   rm   rw   ry   r­   r   rD   r   ú<module>rê      s£   ðÙ F÷ =Ý ç -Ó -Ý 6ß DÝ "ß ;àòEó ðEòN:òB2ò&ò:2ò0%ò6ò&6ò&-òò2ò2ò÷$n'ñ n'ð` ôsEÐ!ó sEó ñsErD   