§
    «³Ùgâv  ã                   óÔ  — d dl Z d dlmZ d dl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 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mZ ddgiZd„ Z  G d„ de¦  «        Z!d„ Z" G d„ de!e¦  «        Z#e#xZ$Z%e&fd„Z'e&fd„Z(d7d„Z)d„ Z*d„ Z+d„ Z,d„ Z-d „ Z.d!„ Z/ ed"¬#¦  «        d$„ ¦   «         Z0d8d&„Z1d'„ Z2d%d(d)œd*„Z3d9d+„Z4d:d-„Z5d.„ Z6d/„ Z7d0„ Z8	 	 d;d3„Z9d<d5„Z:d6„ Z;dS )=é    N)ÚBasic)ÚS)ÚSymbol©Úsympify)ÚcosÚsin)Údoctest_depends_on)Úsympy_deprecation_warning)Úis_sequenceé   )Ú
ShapeError)Ú	_choleskyÚ_LDLdecomposition)Ú
MatrixBase)ÚMutableRepMatrixÚ	RepMatrix)Ú_lower_triangular_solveÚ_upper_triangular_solve)ÚsymarrayÚnumpyc                 ó   — | j         S )zReturns True if x is zero.)Úis_zero)Úxs    úJ/granary/edev/quantum/lib/python3.11/site-packages/sympy/matrices/dense.pyÚ_iszeror      s
   € àŒ9Ðó    c                   óÂ   — e Zd ZdZdZdZdZed„ ¦   «         Zd„ Z	d„ Z
d„ Zdd
„Zdd„Zd„ Zd„ Zej        e_        ej        e_        ej        e_        ej        e_        dS )ÚDenseMatrixzJMatrix implementation based on DomainMatrix as the internal representationFg…ëQ¸$@é   c                 óN   — t          ddd¬¦  «         |                      ¦   «         S )Nzy
            The private _mat attribute of Matrix is deprecated. Use the
            .flat() method instead.
            z1.9z$deprecated-private-matrix-attributes)Údeprecated_since_versionÚactive_deprecations_target)r   Úflat©Úselfs    r   Ú_matzDenseMatrix._mat)   s6   € å!ðð &+Ø'Mð	
ñ 	
ô 	
ð 	
ð �yŠy‰{Œ{Ðr   c                 ó´   — |                       |                     dd¦  «        |                     dt          ¦  «        |                     dd¦  «        ¬¦  «        S )NÚmethodÚGEÚ
iszerofuncÚtry_block_diagF)r)   r+   r,   )ÚinvÚgetr   )r&   Úkwargss     r   Ú_eval_inversezDenseMatrix._eval_inverse6   sS   € Ø�xŠx˜vŸzšz¨(°DÑ9Ô9Ø#)§:¢:¨l½GÑ#DÔ#DØ'-§z¢zÐ2BÀEÑ'JÔ'Jð ñ Lô Lð 	Lr   c                 óf   — ddl m} |                     | j                             ¦   «         ¦  «        S )z4Returns an Immutable version of this Matrix
        r   )ÚImmutableDenseMatrix)Ú	immutabler2   Ú_fromrepÚ_repÚcopy)r&   Úclss     r   Úas_immutablezDenseMatrix.as_immutable;   s4   € ð 	;Ð:Ð:Ð:Ð:Ð:Ø�|Š|˜DœIŸNšNÑ,Ô,Ñ-Ô-Ð-r   c                 ó    — t          | ¦  «        S )aB  Returns a mutable version of this matrix

        Examples
        ========

        >>> from sympy import ImmutableMatrix
        >>> X = ImmutableMatrix([[1, 2], [3, 4]])
        >>> Y = X.as_mutable()
        >>> Y[1, 1] = 5 # Can set values in Y
        >>> Y
        Matrix([
        [1, 2],
        [3, 5]])
        )ÚMatrixr%   s    r   Ú
as_mutablezDenseMatrix.as_mutableA   s   € õ �d‰|Œ|Ðr   Tc                 ó$   — t          | |¬¦  «        S ©N)Ú	hermitian)r   ©r&   r>   s     r   ÚcholeskyzDenseMatrix.choleskyR   s   € Ý˜¨Ð3Ñ3Ô3Ð3r   c                 ó$   — t          | |¬¦  «        S r=   )r   r?   s     r   ÚLDLdecompositionzDenseMatrix.LDLdecompositionU   s   € Ý  °Ð;Ñ;Ô;Ð;r   c                 ó"   — t          | |¦  «        S ©N)r   ©r&   Úrhss     r   Úlower_triangular_solvez"DenseMatrix.lower_triangular_solveX   ó   € Ý& t¨SÑ1Ô1Ð1r   c                 ó"   — t          | |¦  «        S rD   )r   rE   s     r   Úupper_triangular_solvez"DenseMatrix.upper_triangular_solve[   rH   r   N©T)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úis_MatrixExprÚ_op_priorityÚ_class_priorityÚpropertyr'   r0   r8   r;   r@   rB   rG   rJ   r   r   r   r   © r   r   r   r      sç   € € € € € ØTÐTð €Mà€LØ€Oàð
ð 
ñ „Xð
ðLð Lð Lð
.ð .ð .ðð ð ð"4ð 4ð 4ð 4ð<ð <ð <ð <ð2ð 2ð 2ð2ð 2ð 2ð &/Ô%6€HÔØ%6Ô%>ÐÔØ%<Ô%DÐÔ"Ø%<Ô%DÐÔ"Ð"Ð"r   r   c                 ó2  — t          | dd¦  «        r|                      ¦   «         S t          | t          ¦  «        r| S t	          | d¦  «        rJ|                      ¦   «         }t          |j        ¦  «        dk    rt          |¦  «        S t          | ¦  «        S | S )z0Return a matrix as a Matrix, otherwise return x.Ú	is_MatrixFÚ	__array__r   )
Úgetattrr;   Ú
isinstancer   ÚhasattrrW   ÚlenÚshaper   r:   )r   Úas     r   Ú_force_mutabler^   d   sŠ   € åˆq�+˜uÑ%Ô%ð Ø�|Š|‰~Œ~ÐÝ	�A•uÑ	Ô	ð ØˆÝ	��KÑ	 Ô	 ð Ø�KŠK‰MŒMˆÝˆqŒw‰<Œ<˜1ÒÐÝ˜1‘:”:ÐÝ�a‰yŒyÐØ€Hr   c                   ó   — e Zd Zd„ ZdS )ÚMutableDenseMatrixc                 óŒ   — ddl m} |                      ¦   «                              ¦   «         D ]\  \  }}} ||fi |¤Ž| ||f<   ŒdS )zßApplies simplify to the elements of a matrix in place.

        This is a shortcut for M.applyfunc(lambda x: simplify(x, ratio, measure))

        See Also
        ========

        sympy.simplify.simplify.simplify
        r   )ÚsimplifyN)Úsympy.simplify.simplifyrb   ÚtodokÚitems)r&   r/   Ú	_simplifyÚiÚjÚelements         r   rb   zMutableDenseMatrix.simplifyt   sm   € ð 	BÐAÐAÐAÐAÐAØ#Ÿzšz™|œ|×1Ò1Ñ3Ô3ð 	6ð 	6‰O‰FˆQ��GØ"˜ 7Ð5Ð5¨fÐ5Ð5ˆD��A�‰JˆJð	6ð 	6r   N)rL   rM   rN   rb   rT   r   r   r`   r`   r   s#   € € € € € ð6ð 6ð 6ð 6ð 6r   r`   c                 óx   — ddl m}  |t          | ¦  «        |¦  «        }t          | ¦  «        D ]
\  }}|||<   Œ|S )zmConverts Python list of SymPy expressions to a NumPy array.

    See Also
    ========

    matrix2numpy
    r   ©Úempty)r   rl   r[   Ú	enumerate)ÚlÚdtyperl   r]   rg   Úss         r   Ú
list2numpyrq   ‹   sV   € ð ÐÐÐÐÐØˆ�c�!‰fŒf�eÑÔ€AÝ˜!‘”ð ð ‰ˆˆ1Øˆˆ!‰ˆØ€Hr   c                 ó®   — ddl m}  || j        |¦  «        }t          | j        ¦  «        D ](}t          | j        ¦  «        D ]}| ||f         |||f<   ŒŒ)|S )zYConverts SymPy's matrix to a NumPy array.

    See Also
    ========

    list2numpy
    r   rk   )r   rl   r\   ÚrangeÚrowsÚcols)Úmro   rl   r]   rg   rh   s         r   Úmatrix2numpyrw   š   sx   € ð ÐÐÐÐÐØˆˆaŒg�uÑÔ€AÝ�1”6‰]Œ]ð ð ˆÝ�q”v‘”ð 	ð 	ˆAØ˜˜1˜”gˆAˆa�ˆd‰GˆGð	à€Hr   é   c                 ó(  — t          |t          ¦  «        r|dk     r"t          d                     |¦  «        ¦  «        ‚| |k    r#t          d                     | |¦  «        ¦  «        ‚| |fD ]M}t          |t          ¦  «        r|dk     s	||dz
  k    r't          d                     |dz
  | |¦  «        ¦  «        ‚ŒNt	          |¦  «        }t          |¦  «        }t          |¦  «        }t          |¦  «        }||| | f<   ||||f<   ||| |f<   | ||| f<   |S )aÙ  Returns a a Givens rotation matrix, a a rotation in the
    plane spanned by two coordinates axes.

    Explanation
    ===========

    The Givens rotation corresponds to a generalization of rotation
    matrices to any number of dimensions, given by:

    .. math::
        G(i, j, \theta) =
            \begin{bmatrix}
                1   & \cdots &    0   & \cdots &    0   & \cdots &    0   \\
                \vdots & \ddots & \vdots &        & \vdots &        & \vdots \\
                0   & \cdots &    c   & \cdots &   -s   & \cdots &    0   \\
                \vdots &        & \vdots & \ddots & \vdots &        & \vdots \\
                0   & \cdots &    s   & \cdots &    c   & \cdots &    0   \\
                \vdots &        & \vdots &        & \vdots & \ddots & \vdots \\
                0   & \cdots &    0   & \cdots &    0   & \cdots &    1
            \end{bmatrix}

    Where $c = \cos(\theta)$ and $s = \sin(\theta)$ appear at the intersections
    ``i``\th and ``j``\th rows and columns.

    For fixed ``i > j``\, the non-zero elements of a Givens matrix are
    given by:

    - $g_{kk} = 1$ for $k \ne i,\,j$
    - $g_{kk} = c$ for $k = i,\,j$
    - $g_{ji} = -g_{ij} = -s$

    Parameters
    ==========

    i : int between ``0`` and ``dim - 1``
        Represents first axis
    j : int between ``0`` and ``dim - 1``
        Represents second axis
    dim : int bigger than 1
        Number of dimentions. Defaults to 3.

    Examples
    ========

    >>> from sympy import pi, rot_givens

    A counterclockwise rotation of pi/3 (60 degrees) around
    the third axis (z-axis):

    >>> rot_givens(1, 0, pi/3)
    Matrix([
    [      1/2, -sqrt(3)/2, 0],
    [sqrt(3)/2,        1/2, 0],
    [        0,          0, 1]])

    If we rotate by pi/2 (90 degrees):

    >>> rot_givens(1, 0, pi/2)
    Matrix([
    [0, -1, 0],
    [1,  0, 0],
    [0,  0, 1]])

    This can be generalized to any number
    of dimensions:

    >>> rot_givens(1, 0, pi/2, dim=4)
    Matrix([
    [0, -1, 0, 0],
    [1,  0, 0, 0],
    [0,  0, 1, 0],
    [0,  0, 0, 1]])

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Givens_rotation

    See Also
    ========

    rot_axis1: Returns a rotation matrix for a rotation of theta (in radians)
        about the 1-axis (clockwise around the x axis)
    rot_axis2: Returns a rotation matrix for a rotation of theta (in radians)
        about the 2-axis (clockwise around the y axis)
    rot_axis3: Returns a rotation matrix for a rotation of theta (in radians)
        about the 3-axis (clockwise around the z axis)
    rot_ccw_axis1: Returns a rotation matrix for a rotation of theta (in radians)
        about the 1-axis (counterclockwise around the x axis)
    rot_ccw_axis2: Returns a rotation matrix for a rotation of theta (in radians)
        about the 2-axis (counterclockwise around the y axis)
    rot_ccw_axis3: Returns a rotation matrix for a rotation of theta (in radians)
        about the 3-axis (counterclockwise around the z axis)
    é   z/dim must be an integer biggen than one, got {}.z'i and j must be different, got ({}, {})r   r   z=i and j must be integers between 0 and {}, got i={} and j={}.)rY   ÚintÚ
ValueErrorÚformatr   r   r	   Úeye)rg   rh   ÚthetaÚdimÚijÚcrp   ÚMs           r   Ú
rot_givensr„   °   sK  € õ~ �c�3ÑÔð 0 3¨¢7 7Ýð #ß#)¢6¨#¡;¤;ñ0ô 0ð 	0ð 	ˆA‚v€vÝð (ß(.ª¨q°!©¬ñ6ô 6ð 	6ð �!ˆfð Kð KˆÝ˜"�cÑ"Ô"ð 	K b¨1¢f f°°S¸1±W²°Ýð 6ß6<²f¸SÀ¹UÀAÀqÑ6IÔ6IñKô Kð Kð 1=õ �E‰NŒN€EÝˆE‰
Œ
€AÝˆE‰
Œ
€AÝˆC‰Œ€AØ€A€aˆ€d�GØ€A€aˆ€d�GØ€A€aˆ€d�GØˆb€A€aˆ€d�GØ€Hr   c                 ó(   — t          dd| d¬¦  «        S )az  Returns a rotation matrix for a rotation of theta (in radians)
    about the 3-axis.

    Explanation
    ===========

    For a right-handed coordinate system, this corresponds to a
    clockwise rotation around the `z`-axis, given by:

    .. math::

        R  = \begin{bmatrix}
                 \cos(\theta) & \sin(\theta) & 0 \\
                -\sin(\theta) & \cos(\theta) & 0 \\
                            0 &            0 & 1
            \end{bmatrix}

    Examples
    ========

    >>> from sympy import pi, rot_axis3

    A rotation of pi/3 (60 degrees):

    >>> theta = pi/3
    >>> rot_axis3(theta)
    Matrix([
    [       1/2, sqrt(3)/2, 0],
    [-sqrt(3)/2,       1/2, 0],
    [         0,         0, 1]])

    If we rotate by pi/2 (90 degrees):

    >>> rot_axis3(pi/2)
    Matrix([
    [ 0, 1, 0],
    [-1, 0, 0],
    [ 0, 0, 1]])

    See Also
    ========

    rot_givens: Returns a Givens rotation matrix (generalized rotation for
        any number of dimensions)
    rot_ccw_axis3: Returns a rotation matrix for a rotation of theta (in radians)
        about the 3-axis (counterclockwise around the z axis)
    rot_axis1: Returns a rotation matrix for a rotation of theta (in radians)
        about the 1-axis (clockwise around the x axis)
    rot_axis2: Returns a rotation matrix for a rotation of theta (in radians)
        about the 2-axis (clockwise around the y axis)
    r   r   rx   ©r€   ©r„   ©r   s    r   Ú	rot_axis3r‰   '  ó   € õh �a˜˜E qÐ)Ñ)Ô)Ð)r   c                 ó(   — t          dd| d¬¦  «        S )a�  Returns a rotation matrix for a rotation of theta (in radians)
    about the 2-axis.

    Explanation
    ===========

    For a right-handed coordinate system, this corresponds to a
    clockwise rotation around the `y`-axis, given by:

    .. math::

        R  = \begin{bmatrix}
                \cos(\theta) & 0 & -\sin(\theta) \\
                           0 & 1 &             0 \\
                \sin(\theta) & 0 &  \cos(\theta)
            \end{bmatrix}

    Examples
    ========

    >>> from sympy import pi, rot_axis2

    A rotation of pi/3 (60 degrees):

    >>> theta = pi/3
    >>> rot_axis2(theta)
    Matrix([
    [      1/2, 0, -sqrt(3)/2],
    [        0, 1,          0],
    [sqrt(3)/2, 0,        1/2]])

    If we rotate by pi/2 (90 degrees):

    >>> rot_axis2(pi/2)
    Matrix([
    [0, 0, -1],
    [0, 1,  0],
    [1, 0,  0]])

    See Also
    ========

    rot_givens: Returns a Givens rotation matrix (generalized rotation for
        any number of dimensions)
    rot_ccw_axis2: Returns a rotation matrix for a rotation of theta (in radians)
        about the 2-axis (clockwise around the y axis)
    rot_axis1: Returns a rotation matrix for a rotation of theta (in radians)
        about the 1-axis (counterclockwise around the x axis)
    rot_axis3: Returns a rotation matrix for a rotation of theta (in radians)
        about the 3-axis (counterclockwise around the z axis)
    rz   r   rx   r†   r‡   rˆ   s    r   Ú	rot_axis2rŒ   ^  rŠ   r   c                 ó(   — t          dd| d¬¦  «        S )az  Returns a rotation matrix for a rotation of theta (in radians)
    about the 1-axis.

    Explanation
    ===========

    For a right-handed coordinate system, this corresponds to a
    clockwise rotation around the `x`-axis, given by:

    .. math::

        R  = \begin{bmatrix}
                1 &             0 &            0 \\
                0 &  \cos(\theta) & \sin(\theta) \\
                0 & -\sin(\theta) & \cos(\theta)
            \end{bmatrix}

    Examples
    ========

    >>> from sympy import pi, rot_axis1

    A rotation of pi/3 (60 degrees):

    >>> theta = pi/3
    >>> rot_axis1(theta)
    Matrix([
    [1,          0,         0],
    [0,        1/2, sqrt(3)/2],
    [0, -sqrt(3)/2,       1/2]])

    If we rotate by pi/2 (90 degrees):

    >>> rot_axis1(pi/2)
    Matrix([
    [1,  0, 0],
    [0,  0, 1],
    [0, -1, 0]])

    See Also
    ========

    rot_givens: Returns a Givens rotation matrix (generalized rotation for
        any number of dimensions)
    rot_ccw_axis1: Returns a rotation matrix for a rotation of theta (in radians)
        about the 1-axis (counterclockwise around the x axis)
    rot_axis2: Returns a rotation matrix for a rotation of theta (in radians)
        about the 2-axis (clockwise around the y axis)
    rot_axis3: Returns a rotation matrix for a rotation of theta (in radians)
        about the 3-axis (clockwise around the z axis)
    r   rz   rx   r†   r‡   rˆ   s    r   Ú	rot_axis1rŽ   •  rŠ   r   c                 ó(   — t          dd| d¬¦  «        S )a˜  Returns a rotation matrix for a rotation of theta (in radians)
    about the 3-axis.

    Explanation
    ===========

    For a right-handed coordinate system, this corresponds to a
    counterclockwise rotation around the `z`-axis, given by:

    .. math::

        R  = \begin{bmatrix}
                \cos(\theta) & -\sin(\theta) & 0 \\
                \sin(\theta) &  \cos(\theta) & 0 \\
                           0 &             0 & 1
            \end{bmatrix}

    Examples
    ========

    >>> from sympy import pi, rot_ccw_axis3

    A rotation of pi/3 (60 degrees):

    >>> theta = pi/3
    >>> rot_ccw_axis3(theta)
    Matrix([
    [      1/2, -sqrt(3)/2, 0],
    [sqrt(3)/2,        1/2, 0],
    [        0,          0, 1]])

    If we rotate by pi/2 (90 degrees):

    >>> rot_ccw_axis3(pi/2)
    Matrix([
    [0, -1, 0],
    [1,  0, 0],
    [0,  0, 1]])

    See Also
    ========

    rot_givens: Returns a Givens rotation matrix (generalized rotation for
        any number of dimensions)
    rot_axis3: Returns a rotation matrix for a rotation of theta (in radians)
        about the 3-axis (clockwise around the z axis)
    rot_ccw_axis1: Returns a rotation matrix for a rotation of theta (in radians)
        about the 1-axis (counterclockwise around the x axis)
    rot_ccw_axis2: Returns a rotation matrix for a rotation of theta (in radians)
        about the 2-axis (counterclockwise around the y axis)
    r   r   rx   r†   r‡   rˆ   s    r   Úrot_ccw_axis3r�   Ì  rŠ   r   c                 ó(   — t          dd| d¬¦  «        S )až  Returns a rotation matrix for a rotation of theta (in radians)
    about the 2-axis.

    Explanation
    ===========

    For a right-handed coordinate system, this corresponds to a
    counterclockwise rotation around the `y`-axis, given by:

    .. math::

        R  = \begin{bmatrix}
                 \cos(\theta) & 0 & \sin(\theta) \\
                            0 & 1 &            0 \\
                -\sin(\theta) & 0 & \cos(\theta)
            \end{bmatrix}

    Examples
    ========

    >>> from sympy import pi, rot_ccw_axis2

    A rotation of pi/3 (60 degrees):

    >>> theta = pi/3
    >>> rot_ccw_axis2(theta)
    Matrix([
    [       1/2, 0, sqrt(3)/2],
    [         0, 1,         0],
    [-sqrt(3)/2, 0,       1/2]])

    If we rotate by pi/2 (90 degrees):

    >>> rot_ccw_axis2(pi/2)
    Matrix([
    [ 0,  0,  1],
    [ 0,  1,  0],
    [-1,  0,  0]])

    See Also
    ========

    rot_givens: Returns a Givens rotation matrix (generalized rotation for
        any number of dimensions)
    rot_axis2: Returns a rotation matrix for a rotation of theta (in radians)
        about the 2-axis (clockwise around the y axis)
    rot_ccw_axis1: Returns a rotation matrix for a rotation of theta (in radians)
        about the 1-axis (counterclockwise around the x axis)
    rot_ccw_axis3: Returns a rotation matrix for a rotation of theta (in radians)
        about the 3-axis (counterclockwise around the z axis)
    r   rz   rx   r†   r‡   rˆ   s    r   Úrot_ccw_axis2r’     rŠ   r   c                 ó(   — t          dd| d¬¦  «        S )a˜  Returns a rotation matrix for a rotation of theta (in radians)
    about the 1-axis.

    Explanation
    ===========

    For a right-handed coordinate system, this corresponds to a
    counterclockwise rotation around the `x`-axis, given by:

    .. math::

        R  = \begin{bmatrix}
                1 &            0 &             0 \\
                0 & \cos(\theta) & -\sin(\theta) \\
                0 & \sin(\theta) &  \cos(\theta)
            \end{bmatrix}

    Examples
    ========

    >>> from sympy import pi, rot_ccw_axis1

    A rotation of pi/3 (60 degrees):

    >>> theta = pi/3
    >>> rot_ccw_axis1(theta)
    Matrix([
    [1,         0,          0],
    [0,       1/2, -sqrt(3)/2],
    [0, sqrt(3)/2,        1/2]])

    If we rotate by pi/2 (90 degrees):

    >>> rot_ccw_axis1(pi/2)
    Matrix([
    [1, 0,  0],
    [0, 0, -1],
    [0, 1,  0]])

    See Also
    ========

    rot_givens: Returns a Givens rotation matrix (generalized rotation for
        any number of dimensions)
    rot_axis1: Returns a rotation matrix for a rotation of theta (in radians)
        about the 1-axis (clockwise around the x axis)
    rot_ccw_axis2: Returns a rotation matrix for a rotation of theta (in radians)
        about the 2-axis (counterclockwise around the y axis)
    rot_ccw_axis3: Returns a rotation matrix for a rotation of theta (in radians)
        about the 3-axis (counterclockwise around the z axis)
    rz   r   rx   r†   r‡   rˆ   s    r   Úrot_ccw_axis1r”   :  rŠ   r   )r   )Úmodulesc                 óÌ   — ddl m}m}  ||t          ¬¦  «        } ||¦  «        D ]=}t	          | ›dd                     t          t          |¦  «        ¦  «        ›�fi |¤Ž||<   Œ>|S )aI  Create a numpy ndarray of symbols (as an object array).

    The created symbols are named ``prefix_i1_i2_``...  You should thus provide a
    non-empty prefix if you want your symbols to be unique for different output
    arrays, as SymPy symbols with identical names are the same object.

    Parameters
    ----------

    prefix : string
      A prefix prepended to the name of every symbol.

    shape : int or tuple
      Shape of the created array.  If an int, the array is one-dimensional; for
      more than one dimension the shape must be a tuple.

    \*\*kwargs : dict
      keyword arguments passed on to Symbol

    Examples
    ========
    These doctests require numpy.

    >>> from sympy import symarray
    >>> symarray('', 3)
    [_0 _1 _2]

    If you want multiple symarrays to contain distinct symbols, you *must*
    provide unique prefixes:

    >>> a = symarray('', 3)
    >>> b = symarray('', 3)
    >>> a[0] == b[0]
    True
    >>> a = symarray('a', 3)
    >>> b = symarray('b', 3)
    >>> a[0] == b[0]
    False

    Creating symarrays with a prefix:

    >>> symarray('a', 3)
    [a_0 a_1 a_2]

    For more than one dimension, the shape must be given as a tuple:

    >>> symarray('a', (2, 3))
    [[a_0_0 a_0_1 a_0_2]
     [a_1_0 a_1_1 a_1_2]]
    >>> symarray('a', (2, 3, 2))
    [[[a_0_0_0 a_0_0_1]
      [a_0_1_0 a_0_1_1]
      [a_0_2_0 a_0_2_1]]
    <BLANKLINE>
     [[a_1_0_0 a_1_0_1]
      [a_1_1_0 a_1_1_1]
      [a_1_2_0 a_1_2_1]]]

    For setting assumptions of the underlying Symbols:

    >>> [s.is_real for s in symarray('a', 2, real=True)]
    [True, True]
    r   )rl   Úndindex)ro   Ú_)r   rl   r—   Úobjectr   ÚjoinÚmapÚstr)Úprefixr\   r/   rl   r—   ÚarrÚindexs          r   r   r   q  s‘   € ðB %Ð$Ð$Ð$Ð$Ð$Ð$Ð$Ø
ˆ%��VÐ
$Ñ
$Ô
$€CØ�˜‘”ð &ð &ˆÝ v v v¨s¯xªx½½CÀ¹¼Ñ/HÔ/HÐ/HÐIð &ð &Ø$ð&ð &ˆˆE‰
ˆ
à€Jr   Tc                 óÌ   ‡ ‡— t          t          t          ‰ ¦  «        ¦  «        Š |sˆˆ fd„}nˆˆ fd„}t          ‰ ¦  «        }t	          |||¦  «                             ¦   «         S )aY  Given linear difference operator L of order 'k' and homogeneous
       equation Ly = 0 we want to compute kernel of L, which is a set
       of 'k' sequences: a(n), b(n), ... z(n).

       Solutions of L are linearly independent iff their Casoratian,
       denoted as C(a, b, ..., z), do not vanish for n = 0.

       Casoratian is defined by k x k determinant::

                  +  a(n)     b(n)     . . . z(n)     +
                  |  a(n+1)   b(n+1)   . . . z(n+1)   |
                  |    .         .     .        .     |
                  |    .         .       .      .     |
                  |    .         .         .    .     |
                  +  a(n+k-1) b(n+k-1) . . . z(n+k-1) +

       It proves very useful in rsolve_hyper() where it is applied
       to a generating set of a recurrence to factor out linearly
       dependent solutions and return a basis:

       >>> from sympy import Symbol, casoratian, factorial
       >>> n = Symbol('n', integer=True)

       Exponential and factorial are linearly independent:

       >>> casoratian([2**n, factorial(n)], n) != 0
       True

    c                 óB   •— ‰|                               ‰‰| z   ¦  «        S rD   ©Úsubs©rg   rh   ÚnÚseqss     €€r   ú<lambda>zcasoratian.<locals>.<lambda>à  s   ø€ ˜˜aœŸš a¨¨Q©Ñ/Ô/€ r   c                 ó<   •— ‰|                               ‰| ¦  «        S rD   r¢   r¤   s     €€r   r§   zcasoratian.<locals>.<lambda>â  s   ø€ ˜˜aœŸš a¨Ñ+Ô+€ r   )Úlistr›   r   r[   r:   Údet)r¦   r¥   ÚzeroÚfÚks   ``   r   Ú
casoratianr®   ¾  sp   øø€ õ> ••G˜TÑ"Ô"Ñ#Ô#€Dàð ,Ø/Ð/Ð/Ð/Ð/ˆˆà+Ð+Ð+Ð+Ð+ˆåˆD‰	Œ	€Aå�!�Q˜‰?Œ?×ÒÑ Ô Ð r   c                  ó$   — t          j        | i |¤ŽS )z`Create square identity matrix n x n

    See Also
    ========

    diag
    zeros
    ones
    )r:   r~   ©Úargsr/   s     r   r~   r~   é  s   € õ Œ:�tÐ&˜vÐ&Ð&Ð&r   F©ÚstrictÚunpackc                 ó*   — t          j        || |dœ|¤ŽS )aK  Returns a matrix with the provided values placed on the
    diagonal. If non-square matrices are included, they will
    produce a block-diagonal matrix.

    Examples
    ========

    This version of diag is a thin wrapper to Matrix.diag that differs
    in that it treats all lists like matrices -- even when a single list
    is given. If this is not desired, either put a `*` before the list or
    set `unpack=True`.

    >>> from sympy import diag

    >>> diag([1, 2, 3], unpack=True)  # = diag(1,2,3) or diag(*[1,2,3])
    Matrix([
    [1, 0, 0],
    [0, 2, 0],
    [0, 0, 3]])

    >>> diag([1, 2, 3])  # a column vector
    Matrix([
    [1],
    [2],
    [3]])

    See Also
    ========
    .matrixbase.MatrixBase.eye
    .matrixbase.MatrixBase.diagonal
    .matrixbase.MatrixBase.diag
    .expressions.blockmatrix.BlockMatrix
    r²   )r:   Údiag)r³   r´   Úvaluesr/   s       r   r¶   r¶   ÷  s!   € õD Œ;˜ v°fÐGÐGÀÐGÐGÐGr   c                 ó&   — t          j        | |ddœŽS )a  Apply the Gram-Schmidt process to a set of vectors.

    Parameters
    ==========

    vlist : List of Matrix
        Vectors to be orthogonalized for.

    orthonormal : Bool, optional
        If true, return an orthonormal basis.

    Returns
    =======

    vlist : List of Matrix
        Orthogonalized vectors

    Notes
    =====

    This routine is mostly duplicate from ``Matrix.orthogonalize``,
    except for some difference that this always raises error when
    linearly dependent vectors are found, and the keyword ``normalize``
    has been named as ``orthonormal`` in this function.

    See Also
    ========

    .matrixbase.MatrixBase.orthogonalize

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Gram%E2%80%93Schmidt_process
    T)Ú	normalizeÚ	rankcheck)r`   Úorthogonalize)ÚvlistÚorthonormals     r   ÚGramSchmidtr¾     s&   € õH Ô+Ø	˜+°ðð ð ð r   rT   c                 óÎ  — t          |t          ¦  «        rDd|j        vrt          d¦  «        ‚|j        dk    r|j        }|                     ¦   «         d         }t          |¦  «        r!t          |¦  «        }|st          d¦  «        ‚nt          d¦  «        ‚t          | d¦  «        st          d| z  ¦  «        ‚t          |¦  «        }||z   }t          |¦  «        }t          |¦  «        D ]\\  }}t          |d¦  «        st          d| z  ¦  «        ‚t          |¦  «        D ]%}	|                     ||	         ¦  «        |||	|z   f<   Œ&Œ]t          |¦  «        D ]T}	t          |	|¦  «        D ]A}
|                      ||	         ¦  «                             ||
         ¦  «        ||	|z   |
|z   f<   ŒBŒUt          |¦  «        D ]'}	t          |	dz   |¦  «        D ]}
||	|
f         ||
|	f<   ŒŒ(|S )a
  Compute Hessian matrix for a function f wrt parameters in varlist
    which may be given as a sequence or a row/column vector. A list of
    constraints may optionally be given.

    Examples
    ========

    >>> from sympy import Function, hessian, pprint
    >>> from sympy.abc import x, y
    >>> f = Function('f')(x, y)
    >>> g1 = Function('g')(x, y)
    >>> g2 = x**2 + 3*y
    >>> pprint(hessian(f, (x, y), [g1, g2]))
    [                   d               d            ]
    [     0        0    --(g(x, y))     --(g(x, y))  ]
    [                   dx              dy           ]
    [                                                ]
    [     0        0        2*x              3       ]
    [                                                ]
    [                     2               2          ]
    [d                   d               d           ]
    [--(g(x, y))  2*x   ---(f(x, y))   -----(f(x, y))]
    [dx                   2            dy dx         ]
    [                   dx                           ]
    [                                                ]
    [                     2               2          ]
    [d                   d               d           ]
    [--(g(x, y))   3   -----(f(x, y))   ---(f(x, y)) ]
    [dy                dy dx              2          ]
    [                                   dy           ]

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Hessian_matrix

    See Also
    ========

    sympy.matrices.matrixbase.MatrixBase.jacobian
    wronskian
    r   z)`varlist` must be a column or row vector.r   z `len(varlist)` must not be zero.z*Improper variable list in hessian functionÚdiffz'Function `f` (%s) is not differentiable)rY   r   r\   r   ru   ÚTÚtolistr   r[   r|   rX   Úzerosrm   rs   rÀ   )r¬   ÚvarlistÚconstraintsr¥   rv   ÚNÚoutr­   Úgrg   rh   s              r   ÚhessianrÉ   E  s/  € õX �'�:Ñ&Ô&ð &Ø�G”MÐ!Ð!ÝÐHÑIÔIÐIØŒ<˜1ÒÐØ”iˆGØ—.’.Ñ"Ô" 1Ô%ˆÝ�7ÑÔð GÝ�‰LŒLˆØð 	AÝÐ?Ñ@Ô@Ð@ð	Aõ ÐEÑFÔFÐFÝ�1�fÑÔð HåÐBÀQÑFÑGÔGÐGÝˆKÑÔ€AØ	ˆA‰€AÝ
�‰(Œ(€CÝ˜+Ñ&Ô&ð /ð /‰ˆˆ1Ý�q˜&Ñ!Ô!ð 	LåÐFÈÑJÑKÔKÐKÝ�q‘”ð 	/ð 	/ˆAØŸFšF 7¨1¤:Ñ.Ô.ˆC��1�q‘5�‰MˆMð	/å�1‰XŒXð Dð DˆÝ�q˜!‘”ð 	Dð 	DˆAØ !§¢ w¨q¤zÑ 2Ô 2× 7Ò 7¸À¼
Ñ CÔ CˆC��A‘�q˜1‘u�ÑÐð	Då�1‰XŒXð "ð "ˆÝ�q˜1‘u˜a‘”ð 	"ð 	"ˆAØ˜A˜q˜Dœ	ˆC��1�‰IˆIð	"à€Jr   c                 ó:   — t                                || ¬¦  «        S )zò
    Create a Jordan block:

    Examples
    ========

    >>> from sympy import jordan_cell
    >>> from sympy.abc import x
    >>> jordan_cell(x, 4)
    Matrix([
    [x, 1, 0, 0],
    [0, x, 1, 0],
    [0, 0, x, 1],
    [0, 0, 0, x]])
    )ÚsizeÚ
eigenvalue)r:   Újordan_block)Úeigenvalr¥   s     r   Újordan_cellrÏ   ’  s   € õ" ×Ò A°(ÐÑ;Ô;Ð;r   c                 ó,   — |                       |¦  «        S )a‰  Return the Hadamard product (elementwise product) of A and B

    >>> from sympy import Matrix, matrix_multiply_elementwise
    >>> A = Matrix([[0, 1, 2], [3, 4, 5]])
    >>> B = Matrix([[1, 10, 100], [100, 10, 1]])
    >>> matrix_multiply_elementwise(A, B)
    Matrix([
    [  0, 10, 200],
    [300, 40,   5]])

    See Also
    ========

    sympy.matrices.matrixbase.MatrixBase.__mul__
    )Úmultiply_elementwise)ÚAÚBs     r   Úmatrix_multiply_elementwiserÔ   ¦  s   € ð  ×!Ò! !Ñ$Ô$Ð$r   c                  ó\   — d|v r|                      d¦  «        |d<   t          j        | i |¤ŽS )zºReturns a matrix of ones with ``rows`` rows and ``cols`` columns;
    if ``cols`` is omitted a square matrix will be returned.

    See Also
    ========

    zeros
    eye
    diag
    r‚   ru   )Úpopr:   Úonesr°   s     r   r×   r×   ¹  s5   € ð ˆf€}€}ØŸš C™œˆˆv‰åŒ;˜Ð' Ð'Ð'Ð'r   éc   éd   c                 ó  — |pt          j        |¦  «        }|€| }|r| |k    rt          d| |fz  ¦  «        ‚t          | |z  ¦  «        }|dk    r6|                     |t          t          |¦  «        |z  dz  ¦  «        ¦  «        }t          | |¦  «        }	|s4|D ]0}
t          |
|¦  «        \  }}| 	                    ||¦  «        |	||f<   Œ1n@|D ]=}
t          |
|¦  «        \  }}||k    r"| 	                    ||¦  «        x|	||f<   |	||f<   Œ>|	S )a¿  Create random matrix with dimensions ``r`` x ``c``. If ``c`` is omitted
    the matrix will be square. If ``symmetric`` is True the matrix must be
    square. If ``percent`` is less than 100 then only approximately the given
    percentage of elements will be non-zero.

    The pseudo-random number generator used to generate matrix is chosen in the
    following way.

    * If ``prng`` is supplied, it will be used as random number generator.
      It should be an instance of ``random.Random``, or at least have
      ``randint`` and ``shuffle`` methods with same signatures.
    * if ``prng`` is not supplied but ``seed`` is supplied, then new
      ``random.Random`` with given ``seed`` will be created;
    * otherwise, a new ``random.Random`` with default seed will be used.

    Examples
    ========

    >>> from sympy import randMatrix
    >>> randMatrix(3) # doctest:+SKIP
    [25, 45, 27]
    [44, 54,  9]
    [23, 96, 46]
    >>> randMatrix(3, 2) # doctest:+SKIP
    [87, 29]
    [23, 37]
    [90, 26]
    >>> randMatrix(3, 3, 0, 2) # doctest:+SKIP
    [0, 2, 0]
    [2, 0, 1]
    [0, 0, 1]
    >>> randMatrix(3, symmetric=True) # doctest:+SKIP
    [85, 26, 29]
    [26, 71, 43]
    [29, 43, 57]
    >>> A = randMatrix(3, seed=1)
    >>> B = randMatrix(3, seed=2)
    >>> A == B
    False
    >>> A == randMatrix(3, seed=1)
    True
    >>> randMatrix(3, symmetric=True, percent=50) # doctest:+SKIP
    [77, 70,  0],
    [70,  0,  0],
    [ 0,  0, 88]
    Nz4For symmetric matrices, r must equal c, but %i != %irÙ   )
ÚrandomÚRandomr|   rs   Úsampler{   r[   rÃ   ÚdivmodÚrandint)Úrr‚   ÚminÚmaxÚseedÚ	symmetricÚpercentÚprngr�   rv   Úijkrg   rh   s                r   Ú
randMatrixrè   Ë  sA  € ðb Ð&•6”= Ñ&Ô&€Dà€yØˆàð Z�Q˜!’V�VÝÐOÐSTÐVWÐRXÑXÑYÔYÐYå	ˆq�1‰u‰Œ€BØ�#‚~€~Ø�[Š[˜�S¥ R¡¤¨¡°CÑ!7Ñ8Ô8Ñ9Ô9ˆåˆa�‰Œ€Aàð ;Øð 	-ð 	-ˆCÝ˜#˜q‘>”>‰DˆAˆqØ—l’l 3¨Ñ,Ô,ˆAˆa�ˆd‰GˆGð	-ð ð 	;ð 	;ˆCÝ˜#˜q‘>”>‰DˆAˆqØ�AŠvˆvØ$(§L¢L°°cÑ$:Ô$:Ð:��!�Q�$‘˜!˜A˜q˜D™'øà€Hr   Úbareissc                 ó´   ‡ ‡— d„ ‰ D ¦   «         Š t          ‰ ¦  «        }|dk    rt          j        S t          ||ˆ ˆfd„¦  «        }|                     |¦  «        S )av  
    Compute Wronskian for [] of functions

    ::

                         | f1       f2        ...   fn      |
                         | f1'      f2'       ...   fn'     |
                         |  .        .        .      .      |
        W(f1, ..., fn) = |  .        .         .     .      |
                         |  .        .          .    .      |
                         |  (n)      (n)            (n)     |
                         | D   (f1) D   (f2)  ...  D   (fn) |

    see: https://en.wikipedia.org/wiki/Wronskian

    See Also
    ========

    sympy.matrices.matrixbase.MatrixBase.jacobian
    hessian
    c                 ó,   — g | ]}t          |¦  «        ‘ŒS rT   r   )Ú.0r¬   s     r   ú
<listcomp>zwronskian.<locals>.<listcomp>.  s   € Ð/Ð/Ð/ •˜‘”Ð/Ð/Ð/r   r   c                 ó<   •— ‰|                                ‰|¦  «        S rD   )rÀ   )rg   rh   Ú	functionsÚvars     €€r   r§   zwronskian.<locals>.<lambda>2  s   ø€  )¨A¤,×"3Ò"3°C¸Ñ";Ô";€ r   )r[   r   ÚOner:   rª   )rï   rð   r)   r¥   ÚWs   ``   r   Ú	wronskianró     sb   øø€ ð. 0Ð/ YÐ/Ñ/Ô/€IÝˆI‰Œ€AØˆA‚v€vÝŒuˆÝˆq�!Ð;Ð;Ð;Ð;Ð;Ñ<Ô<€AØ�5Š5�‰=Œ=Ðr   c                  ó\   — d|v r|                      d¦  «        |d<   t          j        | i |¤ŽS )zºReturns a matrix of zeros with ``rows`` rows and ``cols`` columns;
    if ``cols`` is omitted a square matrix will be returned.

    See Also
    ========

    ones
    eye
    diag
    r‚   ru   )rÖ   r:   rÃ   r°   s     r   rÃ   rÃ   6  s5   € ð ˆf€}€}ØŸš C™œˆˆv‰åŒ<˜Ð( Ð(Ð(Ð(r   )rx   rK   )F)rT   )Nr   rØ   NFrÙ   N)ré   )<rÛ   Úsympy.core.basicr   Úsympy.core.singletonr   Úsympy.core.symbolr   Úsympy.core.sympifyr   Ú(sympy.functions.elementary.trigonometricr   r	   Úsympy.utilities.decoratorr
   Úsympy.utilities.exceptionsr   Úsympy.utilities.iterablesr   Ú
exceptionsr   Údecompositionsr   r   Ú
matrixbaser   Ú	repmatrixr   r   Úsolversr   r   Ú__doctest_requires__r   r   r^   r`   ÚMutableMatrixr:   r™   rq   rw   r„   r‰   rŒ   rŽ   r�   r’   r”   r   r®   r~   r¶   r¾   rÉ   rÏ   rÔ   r×   rè   ró   rÃ   rT   r   r   ú<module>r     s~  ðØ €€€à "Ð "Ð "Ð "Ð "Ð "Ø "Ð "Ð "Ð "Ð "Ð "Ø $Ð $Ð $Ð $Ð $Ð $Ø &Ð &Ð &Ð &Ð &Ð &Ø =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ø 8Ð 8Ð 8Ð 8Ð 8Ð 8Ø @Ð @Ð @Ð @Ð @Ð @Ø 1Ð 1Ð 1Ð 1Ð 1Ð 1à "Ð "Ð "Ð "Ð "Ð "Ø 8Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8Ø "Ð "Ð "Ð "Ð "Ð "Ø 2Ð 2Ð 2Ð 2Ð 2Ð 2Ð 2Ð 2Ø EÐ EÐ EÐ EÐ EÐ EÐ EÐ Eð &¨ yÐ1Ð ðð ð ð
FEð FEð FEð FEð FE�)ñ FEô FEð FEðRð ð ð6ð 6ð 6ð 6ð 6˜Ð&6ñ 6ô 6ð 6ð" ,Ð +€�ð ð ð ð ð ð !ð ð ð ð ð,tð tð tð tðn4*ð 4*ð 4*ðn4*ð 4*ð 4*ðn4*ð 4*ð 4*ðn4*ð 4*ð 4*ðn4*ð 4*ð 4*ðn4*ð 4*ð 4*ðn Ð˜JÐ'Ñ'Ô'ðEð Eñ (Ô'ðEðX(!ð (!ð (!ð (!ðV'ð 'ð 'ð  eð "Hð "Hð "Hð "Hð "HðJ&ð &ð &ð &ðRJð Jð Jð JðZ<ð <ð <ð(%ð %ð %ð&(ð (ð (ð$ ?DØ!%ðIð Ið Ið IðXð ð ð ð>)ð )ð )ð )ð )r   