
    \h{!                    ,   S SK Jr  S SKJrJrJrJr  S SKJrJ	r	  S SK
Jr  S SKJr  S SKr " S S\5      r " S	 S
\\5      r " S S\\5      r " S S\\5      r " S S\\5      r\\l        \\l        \\l        \\l        \\l        \" 5       \l        g)    )annotations)BasisDependentBasisDependentAddBasisDependentMulBasisDependentZero)SPow)
AtomicExpr)ImmutableDenseMatrixNc                      \ rS rSr% SrSrS\S'   S\S'   S\S'   S\S'   S\S	'   S
\S'   \S 5       rS r	S r
\	R                  \
l        S rS r\R                  \l        SS jrS rSrg)Dyadic   z
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                    U R                   $ )z
Returns the components of this dyadic in the form of a
Python dictionary mapping BaseDyadic instances to the
corresponding measure numbers.

)_componentsselfs    K/var/www/auris/envauris/lib/python3.13/site-packages/sympy/vector/dyadic.py
componentsDyadic.components!   s         c                J   [         R                  R                  n[        U[        5      (       a  UR
                  $ [        X5      (       af  UR
                  nU R                  R                  5        H:  u  pEUR                  S   R                  U5      nX6U-  UR                  S   -  -  nM<     U$ [        U[        5      (       a  [        R
                  nU R                  R                  5        H  u  pUR                  R                  5        Hh  u  pUR                  S   R                  U
R                  S   5      nUR                  S   R                  U
R                  S   5      nXvU	-  U-  U-  -  nMj     M     U$ [        S[        [        U5      5      -   S-   5      e)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&   
Dyadic.dot-   s^   6 $$e/00;;&&[[F--/66!9==/Q,22 0 Mv&&kkG////1#..446FB!wwqz~~bggaj9H$&GGAJ$4$4RWWQZ$@M"}r1MAAG 7 2
 N?U,-/>? @ @r   c                $    U R                  U5      $ N)r&   r   r+   s     r   __and__Dyadic.__and__]   s    xxr   c                   [         R                  R                  nXR                  :X  a  [        R                  $ [        X5      (       ax  [        R                  nU R                  R                  5        HH  u  pEUR                  S   R                  U5      nUR                  S   R                  U5      nX5U-  -  nMJ     U$ [        [        [        U5      5      S-   S-   5      e)a7  
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"   r0   r-   r.   cross_productr'   s           r   r=   Dyadic.crossb   s    , $$KK;;&&kkG--/ !q	 6q	6u9$ 0 NCU,/DD01 2 2r   c                $    U R                  U5      $ r8   )r=   r9   s     r   __xor__Dyadic.__xor__   s    zz%  r   Nc           
         Uc  Un[        U VVs/ s H,  nU  H"  oCR                  U 5      R                  U5      PM$     M.     snn5      R                  SS5      $ s  snnf )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_matrixDyadic.to_matrix   sb    N  "M6 &6a$ ?@uuT{q)$ *6 & ''.wq!}	5 &s   3A
c                    [        U [        5      (       a   [        U[        5      (       a  [        S5      e[        U [        5      (       a$  [        U [	        U[
        R                  5      5      $ [        S5      e)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_helperDyadic._div_helper   sX    c6""z%'@'@788V$$S#eQ]]";<<788r    r8   )__name__
__module____qualname____firstlineno____doc___op_priority__annotations__propertyr   r&   r:   r=   rA   rK   rQ   __static_attributes__rS   r   r   r   r      s    
 L
	  	 .@` kkGO"2H! mmGO+5Z9r   r   c                  8   ^  \ rS rSrSrU 4S jrS rS rSrU =r	$ )
BaseDyadic   z1
Class to denote a base dyadic tensor component.
c                  > [         R                  R                  n[         R                  R                  n[         R                  R                  n[        XU45      (       a  [        X$U45      (       d  [        S5      eXR                  :X  d  X#R                  :X  a  [        R                  $ [        TU ])  XU5      nXfl        SUl        U[        R                  0Ul        UR                   Ul        SUR"                  -   S-   UR"                  -   S-   Ul        SUR$                  -   S-   UR$                  -   S-   Ul        U$ )	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"   rd   re   obj	__class__s          r   rg   BaseDyadic.__new__   s   $$\\,,
\\,,
'
#;<<wZ(@AA & ' ' #w++'=;;gocG4 ,<<'"6"66<$112478$w':'::]J"../1;< 
r   c                    SR                  UR                  U R                  S   5      UR                  U R                  S   5      5      $ )Nz({}|{})r   r   format_printr%   r   printers     r   	_sympystrBaseDyadic._sympystr   s>    NN499Q<('..1*FH 	Hr   c                    SR                  UR                  U R                  S   5      UR                  U R                  S   5      5      $ )NzBaseDyadic({}, {})r   r   ru   rx   s     r   
_sympyreprBaseDyadic._sympyrepr   s>    #**NN499Q<('..1*FH 	Hr   rS   )
rT   rU   rV   rW   rX   rg   rz   r}   r\   __classcell__)rr   s   @r   r^   r^      s    2HH Hr   r^   c                  >    \ rS rSrSrS r\S 5       r\S 5       rSr	g)rN      z$Products of scalars and BaseDyadics c                :    [         R                  " U /UQ70 UD6nU$ r8   )r   rg   rn   r%   optionsrq   s       r   rg   DyadicMul.__new__   !    ''>d>g>
r   c                    U R                   $ )z(The BaseDyadic involved in the product. )rh   r   s    r   base_dyadicDyadicMul.base_dyadic   s     """r   c                    U R                   $ )zDThe scalar expression involved in the definition of
this DyadicMul.
)ri   r   s    r   measure_numberDyadicMul.measure_number   s    
 ###r   rS   N)
rT   rU   rV   rW   rX   rg   r[   r   r   r\   rS   r   r   rN   rN      s2    / # # $ $r   rN   c                  $    \ rS rSrSrS rS rSrg)	DyadicAdd   zClass to hold dyadic sums c                :    [         R                  " U /UQ70 UD6nU$ r8   )r   rg   r   s       r   rg   DyadicAdd.__new__   r   r   c                   ^ [        U R                  R                  5       5      nUR                  S S9  SR	                  U4S jU 5       5      $ )Nc                (    U S   R                  5       $ )Nr   )__str__)xs    r   <lambda>%DyadicAdd._sympystr.<locals>.<lambda>  s    1r   )keyz + c              3  N   >#    U  H  u  pTR                  X-  5      v   M     g 7fr8   )rw   ).0r-   r.   ry   s      r   	<genexpr>&DyadicAdd._sympystr.<locals>.<genexpr>  s!     BEDA'..//Es   "%)listr   r$   sortjoin)r   ry   r$   s    ` r   rz   DyadicAdd._sympystr  s>    T__**,-

/
0zzBEBBBr   rS   N)rT   rU   rV   rW   rX   rg   rz   r\   rS   r   r   r   r      s    %Cr   r   c                  *    \ rS rSrSrSrSrSrS rSr	g)	r   i
  z
Class to denote a zero dyadic
g333333*@z(0|0)z#(\mathbf{\hat{0}}|\mathbf{\hat{0}})c                2    [         R                  " U 5      nU$ r8   )r   rg   )rn   rq   s     r   rg   DyadicZero.__new__  s     ((-
r   rS   N)
rT   rU   rV   rW   rX   rY   rl   rm   rg   r\   rS   r   r   r   r   
  s     LL8Kr   r   )
__future__r   sympy.vector.basisdependentr   r   r   r   
sympy.corer   r	   sympy.core.exprr
   sympy.matrices.immutabler   rE   sympy.vectorr    r   r^   rN   r   r   r   r   r   r   r   r   rS   r   r   <module>r      s    "P P  & C t9^ t9n$H $HN$!6 $(
C!6 
C#V       lr   