Ë
    7^(hH  ã                   ó  — d Z ddlmZmZ ddl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)Úcacheit)ÚMulÚSÚTupleÚsympify)ÚExactQuotientFailed)ÚPicklableWithSlotsÚdict_from_expr)Úpublic)Úis_sequenceÚiterableNc              #   ó   ‡‡K  — t        ‰«      �rt        | «      }t        ‰«      |k7  rt        d«      ‚‰€dg|z  ŠnLt        ‰«      st        d«      ‚t        ‰«      |k7  rt        d«      ‚t        d„ ‰D «       «      rt        d«      ‚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‰}
|
dk  rt        d
«      ‚‰€d}n‰dk  rt        d«      ‚‰}||
kD  ry| r|
dk(  rt        j                  –— yt        | «      t        j                  gz   } t        d„ | D «       «      rt        | |
«      }nt        | |
¬«      }t        «       }|
|z
  }|D ]4  }d}|D ]  }|d	k(  sŒ	|d	z  }||k  sŒ Œ |j                  t        |Ž «       Œ6 |E d{  –—†  yc c}w 7 Œ
­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     úS/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/sympy/polys/monomials.pyú	<genexpr>z itermonomials.<locals>.<genexpr>c   s   è ø€ Ò.˜Q�1�q•5Ñ.ùó   ‚z+min_degrees cannot contain negative numbersc              3   ó4   •K  — | ]  }‰|   ‰|   kD  –— Œ y ­w©Nr   )r   r   Úmax_degreesÚmin_degreess     €€r   r   z itermonomials.<locals>.<genexpr>e   s   øè ø€ ÒA°1ˆ{˜1‰~ ¨A¡Õ.Ñ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   ó4   K  — | ]  }|j                   –— Œ y ­wr   )Úis_commutative)r   Úvariables     r   r   z itermonomials.<locals>.<genexpr>}   s   è ø€ ÒA¨8ˆx×&Õ&ÑAù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ÜÐQÓRÐRØˆÜ!$ Y°¸[Ó!Iò 	JÑˆC�˜Ø×Ñ´°e¸UÀQ¹YÓ0GÖH¨1  Q£ÒHÕIð	Jä˜{Ð+ò 	ˆFÜ�v�,Óñ	ð !ˆ
Ø˜Š>ÜÐ=Ó>Ð>ØÐØ‰Jà˜QŠÜ Ð!AÓBÐBØ$ˆJØ˜
Ò"ØÙ˜J¨!šOÜ—%‘%ŠKØä˜“O¤q§u¡u gÑ-ˆ	ÜÑA°yÔAÔAÜ.¨y¸*ÓE‰Bä˜¨:Ô6ˆBÜ›ˆØ˜Ñ#ˆØò 	.ˆDØˆEØ ò .�Ø˜q“=Ø˜Q‘J�EØ˜5“yÙð	.ð ×!Ñ!¤# t *Õ-ð	.ð !× Ñ ùòG  IðF 	!ús+   „C!G>Ã%G7
Ã1CG>Ç
G>Ç!G>Ç1G<Ç2G>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_countrB   Ž   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_mulrL   ¯   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+   rF   )rH   rI   ÚCs      r   Úmonomial_divrS   Â   s*   € ô, 	�a˜Ó€Aä
Ñ
˜1Ô
ÔÜ�Q‹xˆàrC   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`.

    rE   rG   s       r   rQ   rQ   ß   s+   € ô, ¤S¨¨A£Y×0™T˜Q �1�q“5Ó0Ó1Ð1ùÓ0rM   c                 óD   — t        | D �cg c]  }||z  ‘Œ	 c}«      S c c}w )z%Return the n-th pow of the monomial. )rF   )rH   r/   rJ   s      r   Úmonomial_powrV   ÷   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`.

    )rF   r'   ÚminrG   s       r   Úmonomial_gcdrY   û   ó-   € ô" ¬¨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`.

    )rF   r'   ÚmaxrG   s       r   Úmonomial_lcmr^     rZ   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   rJ   rK   s      r   r   z#monomial_divides.<locals>.<genexpr>.  s   è ø€ Ò,™$˜!˜Qˆq�A�vÑ,ùs   ‚)r+   r'   )rH   rI   s     r   Úmonomial_dividesra   !  s   € ô Ñ,¤# a¨£)Ô,Ó,Ð,rC   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]   rF   ©ÚmonomsÚMrA   r   r/   s        r   Úmonomial_maxrg   0  ó[   € ô" 	ˆV�A‰Y‹€Aà�A�BˆZò  ˆÜ˜a“Lò 	 ‰DˆAˆqÜ�q˜‘t˜Q“<ˆAˆaŠDñ	 ð ô �‹8€OrC   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*   rc   rX   rF   rd   s        r   Úmonomial_minrj   I  rh   rC   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
    )Úsum)rf   s    r   Úmonomial_degrm   b  s   € ô ˆq‹6€MrC   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)rS   Úis_FieldÚquo)rJ   rK   ÚdomainÚa_lmÚa_lcÚb_lmÚb_lcÚmonoms           r   Úterm_divrw   q  sj   € à�J€Dˆ$Ø�J€Dˆ$ä˜˜tÓ$€Eà‡‚ØÐØ˜&Ÿ*™* T¨4Ó0Ð0Ð0àà� ¨¢Ø˜&Ÿ*™* T¨4Ó0Ð0Ð0àrC   c                   ó®   ‡ — e Zd ZdZeˆ fd„«       Zd„ Zd„ Zd„ Zed„ «       Z	ed„ «       Z
ed„ «       Zed	„ «       Zed
„ «       Zed„ «       Zed„ «       Zˆ xZS )ÚMonomialOpsz6Code generator of fast monomial arithmetic functions. c                 ó4   •— t         ‰| �  | «      }||_        |S r   )ÚsuperÚ__new__Úngens)Úclsr}   ÚobjÚ	__class__s      €r   r|   zMonomialOps.__new__†  s   ø€ ä‰g‰o˜cÓ"ˆØˆŒ	Øˆ
rC   c                 ó   — | j                   fS r   )r}   ©Úselfs    r   Ú__getnewargs__zMonomialOps.__getnewargs__Œ  s   € Ø—
‘
ˆ}ÐrC   c                 ó(   — i }t        ||«       ||   S r   )Úexec)rƒ   ÚcodeÚnameÚnss       r   Ú_buildzMonomialOps._build�  s   € ØˆÜˆT�2ŒØ�$‰xˆrC   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 )NrL   ús        def %(name)s(A, B):
            (%(A)s,) = A
            (%(B)s,) = B
            return (%(AB)s,)
        rJ   rK   ú + ú, ©rˆ   rH   rI   ÚAB©r   rŒ   r'   ÚjoinrŠ   ©	rƒ   rˆ   ÚtemplaterH   rI   rJ   rK   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 )NrV   zZ        def %(name)s(A, k):
            (%(A)s,) = A
            return (%(Ak)s,)
        rJ   z%s*kr�   )rˆ   rH   ÚAk)r   rŒ   r”   rŠ   )rƒ   rˆ   r–   rH   rJ   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,)
        rJ   rK   r�   z*kr�   )rˆ   rH   rI   ÚABkr“   )	rƒ   rˆ   r–   rH   rI   rJ   rK   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 )NrQ   rŽ   rJ   rK   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 )NrS   z†        def %(name)s(A, B):
            (%(A)s,) = A
            (%(B)s,) = B
            %(RAB)s
            return (%(R)s,)
        rJ   rK   z7r%(i)s = a%(i)s - b%(i)s
    if r%(i)s < 0: return Noner   Úrr�   z
    )rˆ   rH   rI   ÚRABÚR)r   rŒ   r&   r}   r”   rŠ   )	rƒ   rˆ   r–   rH   rI   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Ž   rJ   rK   ú 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 )
NrY   rŽ   rJ   rK   r¨   z <= r©   r�   r‘   r“   r•   s	            r   ÚgcdzMonomialOps.gcdñ  r«   r¬   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r|   r„   rŠ   rŒ   r—   r›   rŸ   r¡   r¦   rª   r®   Ú__classcell__)r€   s   @r   ry   ry   ƒ  s´   ø„ Ù@àóó ðò
òò
Að ñ'ó ð'ð ñ
'ó ð
'ð ñ'ó ð'ð ñ'ó ð'ð ñ'ó ð'ð  ñ'ó ð'ð ñ'ó ô'rC   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*   ÚvaluesÚkeysr$   ÚformatrF   ÚmapÚintr¶   r·   )rƒ   rv   r·   Úreps       r   Ú__init__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¨›Ó/ˆŒØˆ�	rC   c                 óB   — | j                  ||xs | j                  «      S r   )r€   r·   )rƒ   r¶   r·   s      r   ÚrebuildzMonomial.rebuild  s   € Ø�~‰~˜i¨Ò):°·±Ó;Ð;rC   c                 ó,   — t        | j                  «      S r   )r#   r¶   r‚   s    r   Ú__len__zMonomial.__len__  s   € Ü�4—>‘>Ó"Ð"rC   c                 ó,   — t        | j                  «      S r   )Úiterr¶   r‚   s    r   Ú__iter__zMonomial.__iter__  s   € Ü�D—N‘NÓ#Ð#rC   c                 ó    — | j                   |   S r   )r¶   )rƒ   r:   s     r   Ú__getitem__zMonomial.__getitem__  s   € Ø�~‰~˜dÑ#Ð#rC   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ÐIrC   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¶   rF   r	   ©rƒ   Úotherr¶   s      r   Ú__eq__zMonomial.__eq__0  s:   € Ü�eœXÔ&ØŸ™‰IÜ˜¤¤u˜~Ô.Ø‰Iàà�~‰~ Ñ*Ð*rC   c                 ó   — | |k(   S r   r   )rƒ   rØ   s     r   Ú__ne__zMonomial.__ne__:  s   € Ø˜5‘=Ð Ð rC   c                 óÄ   — t        |t        «      r|j                  }nt        |t        t        f«      r|}nt
        ‚| j                  t        | j                  |«      «      S r   )rÖ   rµ   r¶   rF   r	   ÚNotImplementedErrorrÁ   rL   r×   s      r   Ú__mul__zMonomial.__mul__=  sH   € Ü�eœXÔ&ØŸ™‰IÜ˜¤¤u˜~Ô.Ø‰Iä%Ð%à�|‰|œL¨¯©¸ÓCÓDÐDrC   c                 óö   — t        |t        «      r|j                  }nt        |t        t        f«      r|}nt
        ‚t        | j                  |«      }|�| j                  |«      S t        | t        |«      «      ‚r   )	rÖ   rµ   r¶   rF   r	   rÝ   rS   rÁ   r   )rƒ   rØ   r¶   Úresults       r   Ú__truediv__zMonomial.__truediv__G  sd   € Ü�eœXÔ&ØŸ™‰IÜ˜¤¤u˜~Ô.Ø‰Iä%Ð%ä˜dŸn™n¨iÓ8ˆàÐØ—<‘< Ó'Ð'ä% d¬H°U«OÓ<Ð<rC   c                 óˆ   — t        |«      }|dk  rt        d|z  «      ‚| j                  t        | j                  |«      «      S )Nr   z'a non-negative integer expected, got %s)r½   r$   rÁ   rV   r¶   )rƒ   rØ   r/   s      r   Ú__pow__zMonomial.__pow__X  s=   € Ü�‹JˆØˆqŠ5ÜÐFÈÑNÓOÐOØ�|‰|œL¨¯©¸Ó;Ó<Ð<rC   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¶   rF   r	   Ú	TypeErrorrÁ   rY   r×   s      r   r®   zMonomial.gcd^  ó[   € ä�eœXÔ&ØŸ™‰IÜ˜¤¤u˜~Ô.Ø‰IäØ@À5ÑHóJð Jð �|‰|œL¨¯©¸ÓCÓDÐDrC   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¶   rF   r	   ræ   rÁ   r^   r×   s      r   rª   zMonomial.lcmj  rç   rC   r   )r¯   r°   r±   r²   Ú	__slots__r¿   rÁ   rÃ   rÆ   rÈ   rË   rÒ   rÔ   rÙ   rÛ   rÞ   rá   Ú__floordiv__rã   r®   rª   r   rC   r   rµ   rµ      sb   „ áCà%€Ió	ó<ò#ò$ò$òJòHòLò+ò!òEò=ð €Lò=ò
Eó
ErC   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<   rB   rL   rS   rQ   rV   rY   r^   ra   rg   rj   rm   rw   ry   rµ   r   rC   r   ú<module>ró      s¦   ðÙ F÷ =Ý å $ß -Ó -Ý 6ß DÝ "ß ;àò}!ó ð}!ò~:òB2ò&ò:2ò0%ò6ò&6ò&-òò2ò2ò÷${'ñ {'ðz ôsEÐ!ó sEó ñsErC   