Ë
    täi{!  ã                  ó,  — d dl mZ d dlmZmZmZmZ d dlmZm	Z	 d dl
mZ d dlmZ d dlZ G d„ de«      Z G d	„ d
ee«      Z G d„ dee«      Z G d„ dee«      Z G d„ dee«      Zee_        ee_        ee_        ee_        ee_         e«       e_        y)é    )Úannotations)ÚBasisDependentÚBasisDependentAddÚBasisDependentMulÚBasisDependentZero)ÚSÚPow)Ú
AtomicExpr)ÚImmutableDenseMatrixNc                  óÌ   — e Zd ZU dZdZded<   ded<   ded<   ded<   ded<   d	ed
<   ed„ «       Zd„ Zd„ Z	ej                  e	_        d„ Z
d„ Ze
j                  e_        dd„Zd„ Zy)ÚDyadiczå
    Super class for all Dyadic-classes.

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Dyadic_tensor
    .. [2] Kane, T., Levinson, D. Dynamics Theory and Applications. 1985
           McGraw-Hill

    g      *@ztype[Dyadic]Ú
_expr_typeÚ	_mul_funcÚ	_add_funcÚ
_zero_funcÚ
_base_funcÚ
DyadicZeroÚzeroc                ó   — | j                   S )z®
        Returns the components of this dyadic in the form of a
        Python dictionary mapping BaseDyadic instances to the
        corresponding measure numbers.

        )Ú_components©Úselfs    úb/Volumes/fast/ai/experiments/MLX_z-image/.venv/lib/python3.12/site-packages/sympy/vector/dyadic.pyÚ
componentszDyadic.components!   s   € ð ×ÑÐó    c                ó,  — t         j                  j                  }t        |t        «      r|j
                  S t        ||«      rf|j
                  }| j                  j                  «       D ];  \  }}|j                  d   j                  |«      }|||z  |j                  d   z  z  }Œ= |S t        |t        «      rºt        j
                  }| j                  j                  «       D ]‹  \  }}	|j                  j                  «       D ]i  \  }
}|j                  d   j                  |
j                  d   «      }|j                  d   j                  |
j                  d   «      }|||	z  |z  |z  z  }Œk Œ� |S t        dt        t        |«      «      z   dz   «      ‚)a„  
        Returns the dot product(also called inner product) of this
        Dyadic, with another Dyadic or Vector.
        If 'other' is a Dyadic, this returns a Dyadic. Else, it returns
        a Vector (unless an error is encountered).

        Parameters
        ==========

        other : Dyadic/Vector
            The other Dyadic or Vector to take the inner product with

        Examples
        ========

        >>> from sympy.vector import CoordSys3D
        >>> N = CoordSys3D('N')
        >>> D1 = N.i.outer(N.j)
        >>> D2 = N.j.outer(N.j)
        >>> D1.dot(D2)
        (N.i|N.j)
        >>> D1.dot(N.j)
        N.i

        é   r   z!Inner product is not defined for z and Dyadics.)ÚsympyÚvectorÚVectorÚ
isinstancer   r   r   ÚitemsÚargsÚdotr   ÚouterÚ	TypeErrorÚstrÚtype)r   Úotherr    ÚoutvecÚkÚvÚvect_dotÚoutdyadÚk1Úv1Úk2Úv2Úouter_products                r   r$   z
Dyadic.dot-   sa  € ô6 —‘×$Ñ$ˆÜ�eÔ/Ô0Ø—;‘;ÐÜ˜˜vÔ&Ø—[‘[ˆFØŸ™×-Ñ-Ö/‘��1ØŸ6™6 !™9Ÿ=™=¨Ó/�Ø˜( Q™,¨¯©°©Ñ2Ñ2‘ð 0ð ˆMÜ˜œvÔ&Ü—k‘kˆGØŸ/™/×/Ñ/Ö1‘��BØ#×.Ñ.×4Ñ4Ö6‘F�B˜Ø!Ÿw™w q™zŸ~™~¨b¯g©g°a©jÓ9�HØ$&§G¡G¨A¡J×$4Ñ$4°R·W±W¸Q±ZÓ$@�MØ˜x¨"™}¨rÑ1°MÑAÑA‘Gñ 7ð 2ð
 ˆNäÐ?Ü¤ U£Ó,ñ-Ø/>ñ?ó @ð @r   c                ó$   — | j                  |«      S ©N)r$   ©r   r)   s     r   Ú__and__zDyadic.__and__]   s   € Ø�x‰x˜‹Ðr   c                óÂ  — t         j                  j                  }||j                  k(  rt        j                  S t        ||«      rxt        j                  }| j                  j                  «       D ]I  \  }}|j                  d   j                  |«      }|j                  d   j                  |«      }|||z  z  }ŒK |S t        t        t        |«      «      dz   dz   «      ‚)a§  
        Returns the cross product between this Dyadic, and a Vector, as a
        Vector instance.

        Parameters
        ==========

        other : Vector
            The Vector that we are crossing this Dyadic with

        Examples
        ========

        >>> from sympy.vector import CoordSys3D
        >>> N = CoordSys3D('N')
        >>> d = N.i.outer(N.i)
        >>> d.cross(N.j)
        (N.i|N.k)

        r   r   z not supported for zcross with dyadics)r   r   r    r   r   r!   r   r"   r#   Úcrossr%   r&   r'   r(   )r   r)   r    r.   r+   r,   Úcross_productr%   s           r   r9   zDyadic.crossb   s¾   € ô, —‘×$Ñ$ˆØ�F—K‘KÒÜ—;‘;ÐÜ˜˜vÔ&Ü—k‘kˆGØŸ™×-Ñ-Ö/‘��1Ø !§¡ q¡	§¡°Ó 6�ØŸ™˜q™	Ÿ™¨Ó6�Ø˜1˜u™9Ñ$‘ð 0ð ˆNäœC¤ U£Ó,Ð/DÑDØ0ñ1ó 2ð 2r   c                ó$   — | j                  |«      S r5   )r9   r6   s     r   Ú__xor__zDyadic.__xor__†   s   € Ø�z‰z˜%Ó Ð r   Nc           
     ó¶   — |€|}t        |D ��cg c])  }|D ]"  }|j                  | «      j                  |«      ‘Œ$ Œ+ c}}«      j                  dd«      S c c}}w )a%  
        Returns the matrix form of the dyadic with respect to one or two
        coordinate systems.

        Parameters
        ==========

        system : CoordSys3D
            The coordinate system that the rows and columns of the matrix
            correspond to. If a second system is provided, this
            only corresponds to the rows of the matrix.
        second_system : CoordSys3D, optional, default=None
            The coordinate system that the columns of the matrix correspond
            to.

        Examples
        ========

        >>> from sympy.vector import CoordSys3D
        >>> N = CoordSys3D('N')
        >>> v = N.i + 2*N.j
        >>> d = v.outer(N.i)
        >>> d.to_matrix(N)
        Matrix([
        [1, 0, 0],
        [2, 0, 0],
        [0, 0, 0]])
        >>> from sympy import Symbol
        >>> q = Symbol('q')
        >>> P = N.orient_new_axis('P', q, N.k)
        >>> d.to_matrix(N, P)
        Matrix([
        [  cos(q),   -sin(q), 0],
        [2*cos(q), -2*sin(q), 0],
        [       0,         0, 0]])

        é   )ÚMatrixr$   Úreshape)r   ÚsystemÚsecond_systemÚiÚjs        r   Ú	to_matrixzDyadic.to_matrix‹   sd   € ðN Ð Ø"ˆMä±6ô &±6¨aÛ$ð ?@�q—u‘u˜T“{—‘ qÕ)Ø$ð *°6ò &ó 'ß'.¡w¨q°!£}ð	5ùó &s   �.A
c                óÖ   — t        | t        «      rt        |t        «      rt        d«      ‚t        | t        «      r$t        | t	        |t
        j                  «      «      S t        d«      ‚)z' Helper for division involving dyadics zCannot divide two dyadicszCannot divide by a dyadic)r!   r   r&   Ú	DyadicMulr	   r   ÚNegativeOne)Úoner)   s     r   Ú_div_helperzDyadic._div_helper¸   sO   € ä�cœ6Ô"¤z°%¼Ô'@ÜÐ7Ó8Ð8Ü˜œVÔ$Ü˜S¤# e¬Q¯]©]Ó";Ó<Ð<äÐ7Ó8Ð8r   r5   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú_op_priorityÚ__annotations__Úpropertyr   r$   r7   r9   r<   rE   rJ   © r   r   r   r      s€   … ñ
ð €LàÓØÓØÓØÓØÓØ
Óàñ	 ó ð	 ò.@ò`ð —k‘k€G„Oò"2òH!ð —m‘m€G„Oó+5óZ9r   r   c                  ó.   ‡ — e Zd ZdZˆ fd„Zd„ Zd„ Zˆ xZS )Ú
BaseDyadicz9
    Class to denote a base dyadic tensor component.
    c                óx  •— t         j                  j                  }t         j                  j                  }t         j                  j                  }t        |||f«      rt        |||f«      st        d«      ‚||j                  k(  s||j                  k(  rt        j                  S t        ‰| �)  | ||«      }||_        d|_        |t        j                  i|_        |j                   |_        d|j"                  z   dz   |j"                  z   dz   |_        d|j$                  z   dz   |j$                  z   dz   |_        |S )	Nz1BaseDyadic cannot be composed of non-base vectorsr   Ú(Ú|Ú)z\left(z
{\middle|}z\right))r   r   r    Ú
BaseVectorÚ
VectorZeror!   r&   r   r   ÚsuperÚ__new__Ú_base_instanceÚ_measure_numberr   ÚOner   Ú_sysÚ_pretty_formÚ_latex_form)ÚclsÚvector1Úvector2r    rY   rZ   ÚobjÚ	__class__s          €r   r\   zBaseDyadic.__new__Ç   s!  ø€ Ü—‘×$Ñ$ˆÜ—\‘\×,Ñ,ˆ
Ü—\‘\×,Ñ,ˆ
ä˜' J°
Ð#;Ô<Ü˜w¨°ZÐ(@ÔAÜð &ó 'ð 'ð ˜Ÿ™Ò# w°&·+±+Ò'=Ü—;‘;Ðä‰g‰o˜c 7¨GÓ4ˆØ ˆÔØˆÔØ¤§¡˜,ˆŒØ—<‘<ˆŒØ '×"6Ñ"6Ñ6¸Ñ<Ø$×1Ñ1ñ2Ø47ñ8ˆÔà$ w×':Ñ':Ñ:¸]ÑJØ"×.Ñ.ñ/Ø1;ñ<ˆŒð ˆ
r   c                ó–   — dj                  |j                  | j                  d   «      |j                  | j                  d   «      «      S )Nz({}|{})r   r   ©ÚformatÚ_printr#   ©r   Úprinters     r   Ú	_sympystrzBaseDyadic._sympystrà   s>   € Ø×ÑØ�N‰N˜4Ÿ9™9 Q™<Ó(¨'¯.©.¸¿¹À1¹Ó*FóHð 	Hr   c                ó–   — dj                  |j                  | j                  d   «      |j                  | j                  d   «      «      S )NzBaseDyadic({}, {})r   r   ri   rl   s     r   Ú
_sympyreprzBaseDyadic._sympyreprä   s>   € Ø#×*Ñ*Ø�N‰N˜4Ÿ9™9 Q™<Ó(¨'¯.©.¸¿¹À1¹Ó*FóHð 	Hr   )rK   rL   rM   rN   r\   rn   rp   Ú__classcell__)rg   s   @r   rT   rT   Â   s   ø„ ñôò2HöHr   rT   c                  ó6   — e Zd ZdZd„ Zed„ «       Zed„ «       Zy)rG   z% Products of scalars and BaseDyadics c                ó8   — t        j                  | g|¢­i |¤Ž}|S r5   )r   r\   ©rc   r#   Úoptionsrf   s       r   r\   zDyadicMul.__new__ì   ó!   € Ü×'Ñ'¨Ð>¨dÒ>°gÑ>ˆØˆ
r   c                ó   — | j                   S )z) The BaseDyadic involved in the product. )r]   r   s    r   Úbase_dyadiczDyadicMul.base_dyadicð   s   € ð ×"Ñ"Ð"r   c                ó   — | j                   S )zU The scalar expression involved in the definition of
        this DyadicMul.
        )r^   r   s    r   Úmeasure_numberzDyadicMul.measure_numberõ   s   € ð
 ×#Ñ#Ð#r   N)rK   rL   rM   rN   r\   rQ   rx   rz   rR   r   r   rG   rG   é   s2   „ Ù/òð ñ#ó ð#ð ñ$ó ñ$r   rG   c                  ó   — e Zd ZdZd„ Zd„ Zy)Ú	DyadicAddz Class to hold dyadic sums c                ó8   — t        j                  | g|¢­i |¤Ž}|S r5   )r   r\   rt   s       r   r\   zDyadicAdd.__new__   rv   r   c                ó¤   ‡— t        | j                  j                  «       «      }|j                  d„ ¬«       dj	                  ˆfd„|D «       «      S )Nc                ó(   — | d   j                  «       S )Nr   )Ú__str__)Úxs    r   Ú<lambda>z%DyadicAdd._sympystr.<locals>.<lambda>  s   €   1¡§¡¤r   )Úkeyz + c              3  óL   •K  — | ]  \  }}‰j                  ||z  «      –— Œ y ­wr5   )rk   )Ú.0r+   r,   rm   s      €r   Ú	<genexpr>z&DyadicAdd._sympystr.<locals>.<genexpr>  s#   øè ø€ ÐB¹E±D°A°q˜'Ÿ.™.¨¨Q©×/¹Eùs   ƒ!$)Úlistr   r"   ÚsortÚjoin)r   rm   r"   s    ` r   rn   zDyadicAdd._sympystr  s>   ø€ Ü�T—_‘_×*Ñ*Ó,Ó-ˆØ�
‰
Ñ/ˆ
Ô0Ø�z‰zÓB¹EÓBÓBÐBr   N)rK   rL   rM   rN   r\   rn   rR   r   r   r|   r|   ý   s   „ Ù%òóCr   r|   c                  ó"   — e Zd ZdZdZdZdZd„ Zy)r   z'
    Class to denote a zero dyadic
    g333333*@z(0|0)z#(\mathbf{\hat{0}}|\mathbf{\hat{0}})c                ó0   — t        j                  | «      }|S r5   )r   r\   )rc   rf   s     r   r\   zDyadicZero.__new__  s   € Ü ×(Ñ(¨Ó-ˆØˆ
r   N)rK   rL   rM   rN   rO   ra   rb   r\   rR   r   r   r   r   
  s   „ ñð €LØ€LØ8€Kór   r   )Ú
__future__r   Úsympy.vector.basisdependentr   r   r   r   Ú
sympy.corer   r	   Úsympy.core.exprr
   Úsympy.matrices.immutabler   r?   Úsympy.vectorr   r   rT   rG   r|   r   r   r   r   r   r   r   rR   r   r   Ú<module>r’      s¢   ðÝ "÷Pó Pç Ý &Ý CÛ ôt9ˆ^ô t9ôn$H�˜ô $HôN$Ð! 6ô $ô(
CÐ! 6ô 
CôÐ# Vô ð €Ô Ø€Ô Ø€Ô Ø€Ô Ø€Ô Ù‹l€…r   