§
    OŠtj�;  ã                   óâ   — d Z ddlmZ ddlmZ ddlmZmZ ddlm	Z	m
Z
mZ ddl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 ddlmZ ddlmZ ddlmZ  G d„ d¦  «        Z G d„ d¦  «        ZdS )a  
This module contains functions for two multivariate resultants. These
are:

- Dixon's resultant.
- Macaulay's resultant.

Multivariate resultants are used to identify whether a multivariate
system has common roots. That is when the resultant is equal to zero.
é    )Úprod©ÚMul)ÚMatrixÚdiag)ÚPolyÚdegree_listÚrem)Úsimplify)ÚIndexedBase)ÚitermonomialsÚmonomial_deg)Úmonomial_key)Úpoly_from_exprÚtotal_degree)Úbinomial)Úcombinations_with_replacement)Úsympy_deprecation_warningc                   ó^   — e Zd ZdZd„ Zed„ ¦   «         Zd„ Zd„ Zd„ Z	d„ Z
d„ Zd	„ Zd
„ Zd„ ZdS )ÚDixonResultantaG  
    A class for retrieving the Dixon's resultant of a multivariate
    system.

    Examples
    ========

    >>> from sympy import symbols

    >>> from sympy.polys.multivariate_resultants import DixonResultant
    >>> x, y = symbols('x, y')

    >>> p = x + y
    >>> q = x ** 2 + y ** 3
    >>> h = x ** 2 + y

    >>> dixon = DixonResultant(variables=[x, y], polynomials=[p, q, h])
    >>> poly = dixon.get_dixon_polynomial()
    >>> matrix = dixon.get_dixon_matrix(polynomial=poly)
    >>> matrix
    Matrix([
    [ 0,  0, -1,  0, -1],
    [ 0, -1,  0, -1,  0],
    [-1,  0,  1,  0,  0],
    [ 0, -1,  0,  0,  1],
    [-1,  0,  0,  1,  0]])
    >>> matrix.det()
    0

    See Also
    ========

    Notebook in examples: sympy/example/notebooks.

    References
    ==========

    .. [1] [Kapur1994]_
    .. [2] [Palancz08]_

    c                 ó<  ‡ ‡— |‰ _         |‰ _        t          ‰ j        ¦  «        ‰ _        t          ‰ j         ¦  «        ‰ _        t          d¦  «        Šˆfd„t          ‰ j        ¦  «        D ¦   «         ‰ _        ˆ fd„t          ‰ j        ¦  «        D ¦   «         ‰ _        dS )aV  
        A class that takes two lists, a list of polynomials and list of
        variables. Returns the Dixon matrix of the multivariate system.

        Parameters
        ----------
        polynomials : list of polynomials
            A  list of m n-degree polynomials
        variables: list
            A list of all n variables
        Úalphac                 ó    •— g | ]
}‰|         ‘ŒS © r   )Ú.0ÚiÚas     €úa/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/sympy/polys/multivariate_resultants.pyú
<listcomp>z+DixonResultant.__init__.<locals>.<listcomp>X   s   ø€ Ð<Ð<Ð<¨  !¤Ð<Ð<Ð<ó    c                 óR   •‡— g | ]"Št          ˆfd „‰j        D ¦   «         ¦  «        ‘Œ#S )c              3   óB   •K  — | ]}t          |¦  «        ‰         V — Œd S ©N)r	   )r   Úpolyr   s     €r   ú	<genexpr>z5DixonResultant.__init__.<locals>.<listcomp>.<genexpr>[   s0   øè è € Ð SÐ S¸$¥¨TÑ!2Ô!2°1Ô!5Ð SÐ SÐ SÐ SÐ SÐ Sr    )ÚmaxÚpolynomials©r   r   Úselfs    @€r   r   z+DixonResultant.__init__.<locals>.<listcomp>[   sJ   øø€ ð $ð $ð $Øõ !Ð SÐ SÐ SÐ SÀ$ÔBRÐ SÑ SÔ SÑSÔSð $ð $ð $r    N)	r'   Ú	variablesÚlenÚnÚmr   ÚrangeÚdummy_variablesÚ_max_degrees)r)   r'   r*   r   s   `  @r   Ú__init__zDixonResultant.__init__D   s¢   øø€ ð 'ˆÔØ"ˆŒå�T”^Ñ$Ô$ˆŒÝ�TÔ%Ñ&Ô&ˆŒå˜Ñ Ô ˆà<Ð<Ð<Ð<­e°D´F©m¬mÐ<Ñ<Ô<ˆÔð$ð $ð $ð $Ý˜4œ6‘]”]ð$ñ $ô $ˆÔÐÐr    c                 ó4   — t          ddd¬¦  «         | j        S )NzS
            The max_degrees property of DixonResultant is deprecated.
            ú1.5ú$deprecated-dixonresultant-properties©Údeprecated_since_versionÚactive_deprecations_target)r   r0   ©r)   s    r   Úmax_degreeszDixonResultant.max_degrees^   s1   € å!ðð &+Ø'Mð	
ñ 	
ô 	
ð 	
ð Ô Ð r    c                 ó^  ‡— | j         | j        dz   k    rt          d¦  «        ‚| j        g}t	          | j        ¦  «        }t          | j        ¦  «        D ]Z}| j        |         ||<   t          t          | j        |¦  «        ¦  «        Š| 
                    ˆfd„| j        D ¦   «         ¦  «         Œ[t          |¦  «        }t          | j        | j        ¦  «        }t          d„ |D ¦   «         Ž }|                     ¦   «         |z                       ¦   «         }t          || j        ¦  «        d         S )a²  
        Returns
        =======

        dixon_polynomial: polynomial
            Dixon's polynomial is calculated as:

            delta = Delta(A) / ((x_1 - a_1) ... (x_n - a_n)) where,

            A =  |p_1(x_1,... x_n), ..., p_n(x_1,... x_n)|
                 |p_1(a_1,... x_n), ..., p_n(a_1,... x_n)|
                 |...             , ...,              ...|
                 |p_1(a_1,... a_n), ..., p_n(a_1,... a_n)|
        é   z%Method invalid for given combination.c                 ó:   •— g | ]}|                      ‰¦  «        ‘ŒS r   )Úsubs)r   ÚfÚsubstitutions     €r   r   z7DixonResultant.get_dixon_polynomial.<locals>.<listcomp>ƒ   s%   ø€ ÐHÐHÐH°!˜Ÿš Ñ-Ô-ÐHÐHÐHr    c                 ó   — g | ]
\  }}||z
  ‘ŒS r   r   )r   r   Úbs      r   r   z7DixonResultant.get_dixon_polynomial.<locals>.<listcomp>ˆ   s    € Ð&?Ð&?Ð&?±°°A q¨1¡uÐ&?Ð&?Ð&?r    r   )r-   r,   Ú
ValueErrorr'   Úlistr*   r.   r/   ÚdictÚzipÚappendr   r   ÚdetÚfactorr   )	r)   ÚrowsÚtempÚidxÚAÚtermsÚproduct_of_differencesÚdixon_polynomialr?   s	           @r   Úget_dixon_polynomialz#DixonResultant.get_dixon_polynomiali   s%  ø€ ð Œ6�d”f˜q‘jÒ!Ð!ÝÐDÑEÔEÐEð Ô Ð!ˆå�D”NÑ#Ô#ˆå˜œ‘=”=ð 	Jð 	JˆCØÔ,¨SÔ1ˆD�‰IÝ¥ D¤N°DÑ 9Ô 9Ñ:Ô:ˆLØ�KŠKÐHÐHÐHÐH°tÔ7GÐHÑHÔHÑIÔIÐIÐIå�4‰LŒLˆå�D”N DÔ$8Ñ9Ô9ˆÝ!$Ð&?Ð&?¸Ð&?Ñ&?Ô&?Ð!@ÐØŸEšE™GœGÐ&<Ñ<×DÒDÑFÔFÐåÐ.°Ô0DÑEÔEÀaÔHÐHr    c                 óÚ   ‡ — t          ddd¬¦  «         ˆ fd„t          ‰ j        ¦  «        D ¦   «         }t          |¦  «        }t	          |¦  «                             ¦   «         }t          |Ž S )Nzƒ
            The get_upper_degree() method of DixonResultant is deprecated. Use
            get_max_degrees() instead.
            r3   r4   r5   c                 óF   •— g | ]}‰j         |         ‰j        |         z  ‘ŒS r   )r*   r0   r(   s     €r   r   z3DixonResultant.get_upper_degree.<locals>.<listcomp>–   s=   ø€ ð 4ð 4ð 4Ø !ð !œN¨1Ô-°Ô1BÀ1Ô1EÑEð 4ð 4ð 4r    )r   r.   r,   r   r   Úmonomsr   )r)   Úlist_of_productsÚproducts   `  r   Úget_upper_degreezDixonResultant.get_upper_degree�   sˆ   ø€ Ý!ðð &+Ø'Mð	
ñ 	
ô 	
ð 	
ð4ð 4ð 4ð 4Ý%*¨4¬6¡]¤]ð4ñ 4ô 4ÐåÐ'Ñ(Ô(ˆÝ�w‘-”-×&Ò&Ñ(Ô(ˆå˜WÐ%Ð%r    c                 ón   ‡ — ˆ fd„|                      ¦   «         D ¦   «         }d„ t          |Ž D ¦   «         }|S )zÎ
        Returns a list of the maximum degree of each variable appearing
        in the coefficients of the Dixon polynomial. The coefficients are
        viewed as polys in $x_1, x_2, \dots, x_n$.
        c                 óT   •— g | ]$}t          t          |‰j        ¦  «        ¦  «        ‘Œ%S r   )r	   r   r*   ©r   r$   r)   s     €r   r   z2DixonResultant.get_max_degrees.<locals>.<listcomp>£   s=   ø€ ð 6ð 6ð 6Øõ !¥ d¨D¬NÑ!;Ô!;Ñ<Ô<ð 6ð 6ð 6r    c                 ó,   — g | ]}t          |¦  «        ‘ŒS r   )r&   )r   Údegss     r   r   z2DixonResultant.get_max_degrees.<locals>.<listcomp>¦   s   € Ð=Ð=Ð= T•s˜4‘y”yÐ=Ð=Ð=r    )ÚcoeffsrE   )r)   Ú
polynomialÚ	deg_listsr9   s   `   r   Úget_max_degreeszDixonResultant.get_max_degrees�   sV   ø€ ð6ð 6ð 6ð 6Ø!+×!2Ò!2Ñ!4Ô!4ð6ñ 6ô 6ˆ	ð >Ð=­S°)¨_Ð=Ñ=Ô=ˆàÐr    c                 ó¢  ‡ ‡‡— ‰                       |¦  «        }t          ‰ j        |¦  «        Št          ‰dt	          d‰ j        ¦  «        ¬¦  «        Št          ˆˆ fd„|                     ¦   «         D ¦   «         ¦  «        Š‰j        d         ‰j        d         k    r2ˆfd„t          ‰j        d         ¦  «        D ¦   «         }‰d	d	…|f         Š‰S )
z¥
        Construct the Dixon matrix from the coefficients of polynomial
        \alpha. Each coefficient is viewed as a polynomial of x_1, ...,
        x_n.
        TÚlex©ÚreverseÚkeyc                 ó0   •‡— g | ]Šˆˆfd „‰D ¦   «         ‘ŒS )c                 óZ   •— g | ]'}t          ‰g‰j        ¢R Ž                      |¦  «        ‘Œ(S r   )r   r*   Úcoeff_monomial)r   r-   Úcr)   s     €€r   r   z>DixonResultant.get_dixon_matrix.<locals>.<listcomp>.<listcomp>¸   sI   ø€ ð  4ð  4ð  4Ø$%õ !% QÐ 8¨¬Ð 8Ð 8Ð 8× GÒ GÈÑ JÔ Jð  4ð  4ð  4r    r   )r   rh   Ú	monomialsr)   s    @€€r   r   z3DixonResultant.get_dixon_matrix.<locals>.<listcomp>¸   sP   øø€ ð >ð >ð >à$%ð 4ð  4ð  4ð  4ð  4Ø)2ð 4ñ  4ô  4ð >ð >ð >r    r   r;   c                 óZ   •— g | ]'}t          d „ ‰dd…|f         D ¦   «         ¦  «        ¯%|‘Œ(S )c              3   ó"   K  — | ]
}|d k    V — ŒdS ©r   Nr   )r   Úelements     r   r%   z=DixonResultant.get_dixon_matrix.<locals>.<listcomp>.<genexpr>¿   s6   è è € ð 4ð 4¨G˜7 aš<ð 4ð 4ð 4ð 4ð 4ð 4r    N)Úany)r   ÚcolumnÚdixon_matrixs     €r   r   z3DixonResultant.get_dixon_matrix.<locals>.<listcomp>¾   s`   ø€ ð 5ð 5ð 5˜vÝð 4ð 4Ø'¨¨¨¨6¨	Ô2ð4ñ 4ô 4ñ 4ô 4ð5�Fð 5ð 5ð 5r    éÿÿÿÿN)	r_   r   r*   Úsortedr   r   r\   Úshaper.   )r)   r]   r9   Úkeeprp   ri   s   `   @@r   Úget_dixon_matrixzDixonResultant.get_dixon_matrixª   s  øøø€ ð ×*Ò*¨:Ñ6Ô6ˆõ " $¤.°+Ñ>Ô>ˆ	Ý˜9¨dÝ+¨E°4´>ÑBÔBðDñ Dô Dˆ	õ ð >ð >ð >ð >ð >à)3×):Ò):Ñ)<Ô)<ð>ñ >ô >ñ ?ô ?ˆð
 Ô˜aÔ  LÔ$6°qÔ$9Ò9Ð9ð5ð 5ð 5ð 5­¨|Ô/AÀ"Ô/EÑ)FÔ)Fð 5ñ 5ô 5ˆDð (¨¨¨¨4¨Ô0ˆLàÐr    c                 ó(  ‡‡— ‰j         rdS ‰j        \  }Št          ‰                     ¦   «         d         ¦  «        Šˆˆfd„t	          |¦  «        D ¦   «         }‰|dd…f         Št          dg‰dz
  z  dgz   g¦  «        }‰ddd…f         |k    rdS dS )a¯  
        Test for the validity of the Kapur-Saxena-Yang precondition.

        The precondition requires that the column corresponding to the
        monomial 1 = x_1 ^ 0 * x_2 ^ 0 * ... * x_n ^ 0 is not a linear
        combination of the remaining ones. In SymPy notation this is
        the last column. For the precondition to hold the last non-zero
        row of the rref matrix should be of the form [0, 0, ..., 1].
        Fr   c                 óh   •‡— g | ]-Št          ˆˆfd „t          ‰¦  «        D ¦   «         ¦  «        ¯+‰‘Œ.S )c              3   ó4   •K  — | ]}‰‰|f         d k    V — ŒdS rl   r   )r   Újr   Úmatrixs     €€r   r%   z=DixonResultant.KSY_precondition.<locals>.<listcomp>.<genexpr>×   s0   øè è € Ð*OÐ*OÀ¨6°!°Q°$¬<¸1Ò+<Ð*OÐ*OÐ*OÐ*OÐ*OÐ*Or    )rn   r.   )r   r   rz   r,   s    @€€r   r   z3DixonResultant.KSY_precondition.<locals>.<listcomp>×   sE   øø€ ÐPÐPÐP�a¥sÐ*OÐ*OÐ*OÐ*OÐ*OÅeÈAÁhÄhÐ*OÑ*OÔ*OÑ'OÔ'OÐP�ÐPÐPÐPr    Nr;   rq   T)Úis_zero_matrixrs   r   Úrrefr.   r   )r)   rz   r-   rI   Ú	conditionr,   s    `   @r   ÚKSY_preconditionzDixonResultant.KSY_preconditionÆ   s±   øø€ ð Ô ð 	Ø�5àŒ|‰ˆˆ1õ ˜&Ÿ+š+™-œ-¨Ô*Ñ+Ô+ˆØPÐPÐPÐPÐP�5 ™8œ8ÐPÑPÔPˆØ˜˜Q˜Q˜Q˜”ˆå˜Q˜C  1¡™I¨¨™OÐ,Ñ-Ô-ˆ	à�"�Q�Q�Q�$Œ<˜9Ò$Ð$Ø�4à�5r    c                 ó˜   ‡— ˆfd„t          ‰j        ¦  «        D ¦   «         }ˆfd„t          ‰j        ¦  «        D ¦   «         }‰||f         S )z/Remove the zero rows and columns of the matrix.c                 óH   •— g | ]}‰                      |¦  «        j        °|‘ŒS r   )Úrowr{   )r   r   rz   s     €r   r   z?DixonResultant.delete_zero_rows_and_columns.<locals>.<listcomp>ã   óB   ø€ ð Oð Oð OØ°·²¸A±´Ô1MðOØðOð Oð Or    c                 óH   •— g | ]}‰                      |¦  «        j        °|‘ŒS r   )Úcolr{   )r   ry   rz   s     €r   r   z?DixonResultant.delete_zero_rows_and_columns.<locals>.<listcomp>å   r‚   r    )r.   rI   Úcols)r)   rz   rI   r…   s    `  r   Údelete_zero_rows_and_columnsz+DixonResultant.delete_zero_rows_and_columnsá   s†   ø€ ðOð Oð Oð OÝ˜Vœ[Ñ)Ô)ðOñ Oô OˆðOð Oð Oð OÝ˜Vœ[Ñ)Ô)ðOñ Oô Oˆð �d˜D�jÔ!Ð!r    c                 ó‚   — d}t          |j        ¦  «        D ]'}|                     |¦  «        D ]}|dk    r||z  } nŒŒ(|S )z;Calculate the product of the leading entries of the matrix.r;   r   )r.   rI   r�   )r)   rz   Úresr�   Úels        r   Úproduct_leading_entriesz&DixonResultant.product_leading_entriesê   s]   € àˆÝ˜œÑ%Ô%ð 	ð 	ˆCØ—j’j ‘o”oð ð �Ø˜’7�7Ø ™(�CØ�Eð øð ˆ
r    c                 óÊ   — |                       |¦  «        }|                     ¦   «         \  }}}|                       t          |¦  «        ¦  «        }|                      |¦  «        S )z@Calculate the Kapur-Saxena-Yang approach to the Dixon Resultant.)r†   ÚLUdecompositionr   rŠ   )r)   rz   Ú_ÚUs       r   Úget_KSY_Dixon_resultantz&DixonResultant.get_KSY_Dixon_resultantô   sY   € à×2Ò2°6Ñ:Ô:ˆØ×(Ò(Ñ*Ô*‰ˆˆ1ˆaØ×2Ò2µ8¸A±;´;Ñ?Ô?ˆà×+Ò+¨FÑ3Ô3Ð3r    N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r1   Úpropertyr9   rP   rV   r_   ru   r~   r†   rŠ   r�   r   r    r   r   r      sÅ   € € € € € ð(ð (ðT$ð $ð $ð4 ð!ð !ñ „Xð!ð"Ið "Ið "IðH&ð &ð &ð ð ð ðð ð ð8ð ð ð6"ð "ð "ðð ð ð4ð 4ð 4ð 4ð 4r    r   c                   óB   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
S )ÚMacaulayResultanta-  
    A class for calculating the Macaulay resultant. Note that the
    polynomials must be homogenized and their coefficients must be
    given as symbols.

    Examples
    ========

    >>> from sympy import symbols

    >>> from sympy.polys.multivariate_resultants import MacaulayResultant
    >>> x, y, z = symbols('x, y, z')

    >>> a_0, a_1, a_2 = symbols('a_0, a_1, a_2')
    >>> b_0, b_1, b_2 = symbols('b_0, b_1, b_2')
    >>> c_0, c_1, c_2,c_3, c_4 = symbols('c_0, c_1, c_2, c_3, c_4')

    >>> f = a_0 * y -  a_1 * x + a_2 * z
    >>> g = b_1 * x ** 2 + b_0 * y ** 2 - b_2 * z ** 2
    >>> h = c_0 * y * z ** 2 - c_1 * x ** 3 + c_2 * x ** 2 * z - c_3 * x * z ** 2 + c_4 * z ** 3

    >>> mac = MacaulayResultant(polynomials=[f, g, h], variables=[x, y, z])
    >>> mac.monomial_set
    [x**4, x**3*y, x**3*z, x**2*y**2, x**2*y*z, x**2*z**2, x*y**3,
    x*y**2*z, x*y*z**2, x*z**3, y**4, y**3*z, y**2*z**2, y*z**3, z**4]
    >>> matrix = mac.get_matrix()
    >>> submatrix = mac.get_submatrix(matrix)
    >>> submatrix
    Matrix([
    [-a_1,  a_0,  a_2,    0],
    [   0, -a_1,    0,    0],
    [   0,    0, -a_1,    0],
    [   0,    0,    0, -a_1]])

    See Also
    ========

    Notebook in examples: sympy/example/notebooks.

    References
    ==========

    .. [1] [Bruce97]_
    .. [2] [Stiller96]_

    c                 ó  ‡ — |‰ _         |‰ _        t          |¦  «        ‰ _        ˆ fd„‰ j         D ¦   «         ‰ _        ‰                      ¦   «         ‰ _        ‰                      ¦   «         ‰ _        ‰  	                    ‰ j        ¦  «        ‰ _
        dS )zÌ
        Parameters
        ==========

        variables: list
            A list of all n variables
        polynomials : list of SymPy polynomials
            A  list of m n-degree polynomials
        c                 ó4   •— g | ]}t          |g‰j        ¢R Ž ‘ŒS r   )r   r*   rY   s     €r   r   z.MacaulayResultant.__init__.<locals>.<listcomp>:  s7   ø€ ð -ð -ð -À� TÐ;¨D¬NÐ;Ð;Ð;ð -ð -ð -r    N)r'   r*   r+   r,   ÚdegreesÚ_get_degree_mÚdegree_mÚget_sizeÚmonomials_sizeÚget_monomials_of_certain_degreeÚmonomial_set)r)   r'   r*   s   `  r   r1   zMacaulayResultant.__init__+  s“   ø€ ð 'ˆÔØ"ˆŒÝ�Y‘”ˆŒð-ð -ð -ð -ØÔ+ð-ñ -ô -ˆŒð ×*Ò*Ñ,Ô,ˆŒØ"Ÿmšm™oœoˆÔð !×@Ò@ÀÄÑOÔOˆÔÐÐr    c                 óD   — dt          d„ | j        D ¦   «         ¦  «        z   S )z½
        Returns
        =======

        degree_m: int
            The degree_m is calculated as  1 + \sum_1 ^ n (d_i - 1),
            where d_i is the degree of the i polynomial
        r;   c              3   ó    K  — | ]	}|d z
  V — Œ
dS )r;   Nr   )r   Úds     r   r%   z2MacaulayResultant._get_degree_m.<locals>.<genexpr>L  s&   è è € Ð3Ð3 �q˜1‘uÐ3Ð3Ð3Ð3Ð3Ð3r    )Úsumr™   r8   s    r   rš   zMacaulayResultant._get_degree_mC  s(   € ð •3Ð3Ð3 d¤lÐ3Ñ3Ô3Ñ3Ô3Ñ3Ð3r    c                 óR   — t          | j        | j        z   dz
  | j        dz
  ¦  «        S )zÒ
        Returns
        =======

        size: int
            The size of set T. Set T is the set of all possible
            monomials of the n variables for degree equal to the
            degree_m
        r;   )r   r›   r,   r8   s    r   rœ   zMacaulayResultant.get_sizeN  s(   € õ ˜œ¨¬Ñ.°Ñ2°D´F¸Q±JÑ?Ô?Ð?r    c                 óŠ   — d„ t          | j        |¦  «        D ¦   «         }t          |dt          d| j        ¦  «        ¬¦  «        S )zw
        Returns
        =======

        monomials: list
            A list of monomials of a certain degree.
        c                 ó    — g | ]}t          |Ž ‘ŒS r   r   )r   Úmonomials     r   r   zEMacaulayResultant.get_monomials_of_certain_degree.<locals>.<listcomp>b  s(   € ð ?ð ?ð ?¨•S˜(�^ð ?ð ?ð ?r    Tra   rb   )r   r*   rr   r   )r)   Údegreeri   s      r   rž   z1MacaulayResultant.get_monomials_of_certain_degreeZ  s]   € ð?ð ?Ý5°d´nØ6<ñ>ô >ð?ñ ?ô ?ˆ	õ �i¨Ý& u¨d¬nÑ=Ô=ð?ñ ?ô ?ð 	?r    c                 ó  ‡— g }g }t          | j        ¦  «        D ]ç}|dk    r@| j        | j        |         z
  }|                      |¦  «        }|                     |¦  «         ŒH|                     | j        |dz
           | j        |dz
           z  ¦  «         | j        | j        |         z
  }|                      |¦  «        }|D ])}|D ]$Št          ‰|¦  «        dk    rˆfd„|D ¦   «         }Œ%Œ*|                     |¦  «         Œè|S )z
        Returns
        =======

        row_coefficients: list
            The row coefficients of Macaulay's matrix
        r   r;   c                 ó    •— g | ]
}|‰k    ¯|‘ŒS r   r   )r   ÚitemÚps     €r   r   z:MacaulayResultant.get_row_coefficients.<locals>.<listcomp>€  s)   ø€ ð )7ð )7ð )7°$Ø,0°AªI¨Ið *.Ø,5¨I¨Ir    )r.   r,   r›   r™   rž   rF   r*   r
   )	r)   Úrow_coefficientsÚ	divisibler   r¨   r§   Ú	poss_rowsÚdivr¬   s	           @r   Úget_row_coefficientsz&MacaulayResultant.get_row_coefficientsi  sF  ø€ ð ÐØˆ	Ý�t”v‘”ð 	3ð 	3ˆAØ�AŠvˆvØœ¨¬°a¬Ñ8�Ø×?Ò?ÀÑGÔG�Ø ×'Ò'¨Ñ1Ô1Ð1Ð1à× Ò  ¤°°A±Ô!6Ø!%¤¨a°!©eÔ!4ñ"5ñ 6ô 6ð 6àœ¨¬°a¬Ñ8�Ø ×@Ò@ÀÑHÔH�	Ø$ð 7ð 7�CØ&ð 7ð 7˜Ý˜q #™;œ;¨!Ò+Ð+ð)7ð )7ð )7ð )7¸)ð )7ñ )7ô )7˜Iøð7ð !×'Ò'¨	Ñ2Ô2Ð2Ð2ØÐr    c                 óf  — g }|                       ¦   «         }t          | j        ¦  «        D ]v}||         D ]k}g }t          | j        |         |z  g| j        ¢R Ž }| j        D ]*}|                     |                     |¦  «        ¦  «         Œ+|                     |¦  «         ŒlŒwt          |¦  «        }|S )zt
        Returns
        =======

        macaulay_matrix: Matrix
            The Macaulay numerator matrix
        )
r±   r.   r,   r   r'   r*   rŸ   rF   rg   r   )	r)   rI   r­   r   Ú
multiplierÚcoefficientsr$   ÚmonoÚmacaulay_matrixs	            r   Ú
get_matrixzMacaulayResultant.get_matrix…  sà   € ð ˆØ×4Ò4Ñ6Ô6ÐÝ�t”v‘”ð 	*ð 	*ˆAØ.¨qÔ1ð *ð *�
Ø!�Ý˜DÔ,¨QÔ/°*Ñ<ð -Ø!œ^ð-ð -ð -�ð !Ô-ð Cð C�DØ ×'Ò'¨×(;Ò(;¸DÑ(AÔ(AÑBÔBÐBÐBØ—’˜LÑ)Ô)Ð)Ð)ð*õ ! ™,œ,ˆØÐr    c           
      óp  ‡ — g }‰ j         D ]r}g }t          ‰ j        ¦  «        D ]D\  }}|                     t	          t          ||¦  «        ‰ j        |         k    ¦  «        ¦  «         ŒE|                     |¦  «         Œsˆ fd„t          |¦  «        D ¦   «         }ˆ fd„t          |¦  «        D ¦   «         }||fS )aÓ  
        Returns
        =======

        reduced: list
            A list of the reduced monomials
        non_reduced: list
            A list of the monomials that are not reduced

        Definition
        ==========

        A polynomial is said to be reduced in x_i, if its degree (the
        maximum degree of its monomials) in x_i is less than d_i. A
        polynomial that is reduced in all variables but one is said
        simply to be reduced.
        c                 óP   •— g | ]"\  }}t          |¦  «        ‰j        d z
  k     ¯ |‘Œ#S ©r;   ©r£   r,   ©r   r   Úrr)   s      €r   r   z<MacaulayResultant.get_reduced_nonreduced.<locals>.<listcomp>´  s=   ø€ ð +ð +ð +™˜˜AÝ˜!‘f”f˜tœv¨™zÒ)Ð)ð Ø)Ð)Ð)r    c                 óP   •— g | ]"\  }}t          |¦  «        ‰j        d z
  k    ¯ |‘Œ#S rº   r»   r¼   s      €r   r   z<MacaulayResultant.get_reduced_nonreduced.<locals>.<listcomp>¶  s=   ø€ ð /ð /ð /™T˜Q Ý˜a™&œ& D¤F¨A¡IÒ-Ð-ð Ø-Ð-Ð-r    )rŸ   Ú	enumerater*   rF   Úboolr   r™   )r)   r®   r-   rJ   r   ÚvÚreducedÚnon_reduceds   `       r   Úget_reduced_nonreducedz(MacaulayResultant.get_reduced_nonreducedœ  sô   ø€ ð$ ˆ	ØÔ"ð 	#ð 	#ˆAØˆDÝ! $¤.Ñ1Ô1ð Ið I‘��1Ø—’�D¥¨a°Ñ!3Ô!3°t´|ÀA´Ò!FÑGÔGÑHÔHÐHÐHØ×Ò˜TÑ"Ô"Ð"Ð"ð+ð +ð +ð +¥¨9Ñ!5Ô!5ð +ñ +ô +ˆð/ð /ð /ð /¥Y¨yÑ%9Ô%9ð /ñ /ô /ˆð ˜Ð#Ð#r    c                 ó”  ‡ ‡‡‡	— ‰                       ¦   «         \  }}|g k    rt          dg¦  «        S ˆ fd„t          ‰ j        ¦  «        D ¦   «         Šˆˆ fd„t	          ‰ j        ¦  «        D ¦   «         }|dd…|f         Šg }t	          ‰j        ¦  «        D ]*Š	ˆˆ	fd„|D ¦   «         }d|vr|                     ‰	¦  «         Œ+|||f         S )a  
        Returns
        =======

        macaulay_submatrix: Matrix
            The Macaulay denominator matrix. Columns that are non reduced are kept.
            The row which contains one of the a_{i}s is dropped. a_{i}s
            are the coefficients of x_i ^ {d_i}.
        r;   c                 ó6   •— g | ]\  }}|‰j         |         z  ‘ŒS r   )r™   )r   r   rÁ   r)   s      €r   r   z3MacaulayResultant.get_submatrix.<locals>.<listcomp>Ì  s4   ø€ ð 7ð 7ð 7±$°!°Q˜˜dœl¨1œoÑ-ð 7ð 7ð 7r    c                 ó\   •— g | ](}‰j         |                              ‰|         ¦  «        ‘Œ)S r   )r'   Úcoeff)r   r   Úreduction_setr)   s     €€r   r   z3MacaulayResultant.get_submatrix.<locals>.<listcomp>Ï  sD   ø€ ð 'ð 'ð 'Øð Ô Ô"×(Ò(¨°qÔ)9Ñ:Ô:ð 'ð 'ð 'r    Nc                 ó,   •— g | ]}|‰‰d d …f         v ‘ŒS r#   r   )r   ÚaiÚreduced_matrixr�   s     €€r   r   z3MacaulayResultant.get_submatrix.<locals>.<listcomp>Õ  s+   ø€ Ð@Ð@Ð@°b�R˜>¨#¨q¨q¨q¨&Ô1Ð1Ð@Ð@Ð@r    T)rÄ   r   r¿   r*   r.   r,   rI   rF   )
r)   rz   rÂ   rÃ   Úaisrt   ÚcheckrÌ   rÉ   r�   s
   `      @@@r   Úget_submatrixzMacaulayResultant.get_submatrix»  s  øøøø€ ð  $×:Ò:Ñ<Ô<Ñˆ�ð �bŠ=ˆ=Ý˜˜‘9”9Ðð7ð 7ð 7ð 7Ý% d¤nÑ5Ô5ð7ñ 7ô 7ˆð'ð 'ð 'ð 'ð 'Ý˜dœf™œð'ñ 'ô 'ˆð      7 
Ô+ˆØˆÝ˜Ô,Ñ-Ô-ð 	!ð 	!ˆCØ@Ð@Ð@Ð@Ð@¸CÐ@Ñ@Ô@ˆEØ˜5Ð Ð Ø—’˜CÑ Ô Ð øà�d˜KÐ'Ô(Ð(r    N)r�   r‘   r’   r“   r1   rš   rœ   rž   r±   r·   rÄ   rÏ   r   r    r   r–   r–   ü   s�   € € € € € ð-ð -ð\Pð Pð Pð0	4ð 	4ð 	4ð
@ð 
@ð 
@ð?ð ?ð ?ð ð  ð  ð8ð ð ð.$ð $ð $ð>)ð )ð )ð )ð )r    r–   N)r“   Úmathr   Úsympy.core.mulr   Úsympy.matrices.denser   r   Úsympy.polys.polytoolsr   r	   r
   Úsympy.simplify.simplifyr   Úsympy.tensor.indexedr   Úsympy.polys.monomialsr   r   Úsympy.polys.orderingsr   r   r   Ú(sympy.functions.combinatorial.factorialsr   Ú	itertoolsr   Úsympy.utilities.exceptionsr   r   r–   r   r    r   ú<module>rÛ      st  ðð	ð 	ð Ð Ð Ð Ð Ð à Ð Ð Ð Ð Ð Ø /Ð /Ð /Ð /Ð /Ð /Ð /Ð /Ø :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,Ø =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ø .Ð .Ð .Ð .Ð .Ð .Ø >Ð >Ð >Ð >Ð >Ð >Ð >Ð >Ø =Ð =Ð =Ð =Ð =Ð =Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3Ø @Ð @Ð @Ð @Ð @Ð @ða4ð a4ð a4ð a4ð a4ñ a4ô a4ð a4ðF])ð ])ð ])ð ])ð ])ñ ])ô ])ð ])ð ])ð ])r    