
    \hk%                         S SK r S SKJr  S SKJrJrJr  S SKJr  S SK	J
r
JrJrJrJr  S SKJr  S SKJr  S SKJr  S	 rS
 r " S S\5      r " S S\5      r " S S\5      rSS jrSS jrSS jr " S S\5      rS rg)    N)Expr)sympifySpreorder_traversal)
CoordSys3D)Vector	VectorMul	VectorAddCrossDot)
Derivative)Add)Mulc                     [        U 5      n[        5       nU H;  n[        U[        5      (       d  M  UR	                  U5        UR                  5         M=     [        U5      $ N)r   set
isinstancer   addskip	frozenset)exprgretis       N/var/www/auris/envauris/lib/python3.13/site-packages/sympy/vector/operators.py_get_coord_systemsr      sJ    4 A
%Ca$$GGAJFFH  S>    c                     [         R                  " S 5      nU R                   H  nU[        U5      ==   U-  ss'   M     [	        UR                  5       5      $ )Nc                  "    [         R                  $ r   )r   One r   r   <lambda>._split_mul_args_wrt_coordsys.<locals>.<lambda>   s    r   )collectionsdefaultdictargsr   listvalues)r   dr   s      r   _split_mul_args_wrt_coordsysr*      sG    .AYY	
Q
 A%  
r   c                   $    \ rS rSrSrS rS rSrg)Gradient   z
Represents unevaluated Gradient.

Examples
========

>>> from sympy.vector import CoordSys3D, Gradient
>>> R = CoordSys3D('R')
>>> s = R.x*R.y*R.z
>>> Gradient(s)
Gradient(R.x*R.y*R.z)

c                 T    [        U5      n[        R                  " X5      nXl        U$ r   r   r   __new___exprclsr   objs      r   r0   Gradient.__new__+   #    t}ll3%	
r   c                 *    [        U R                  SS9$ NTdoit)gradientr1   selfhintss     r   r:   Gradient.doit1   s    

..r   r!   N__name__
__module____qualname____firstlineno____doc__r0   r:   __static_attributes__r!   r   r   r,   r,      s    /r   r,   c                   $    \ rS rSrSrS rS rSrg)
Divergence5   z
Represents unevaluated Divergence.

Examples
========

>>> from sympy.vector import CoordSys3D, Divergence
>>> R = CoordSys3D('R')
>>> v = R.y*R.z*R.i + R.x*R.z*R.j + R.x*R.y*R.k
>>> Divergence(v)
Divergence(R.y*R.z*R.i + R.x*R.z*R.j + R.x*R.y*R.k)

c                 T    [        U5      n[        R                  " X5      nXl        U$ r   r/   r2   s      r   r0   Divergence.__new__D   r6   r   c                 *    [        U R                  SS9$ r8   )
divergencer1   r<   s     r   r:   Divergence.doitJ   s    $**400r   r!   Nr@   r!   r   r   rH   rH   5   s    1r   rH   c                   $    \ rS rSrSrS rS rSrg)CurlN   z
Represents unevaluated Curl.

Examples
========

>>> from sympy.vector import CoordSys3D, Curl
>>> R = CoordSys3D('R')
>>> v = R.y*R.z*R.i + R.x*R.z*R.j + R.x*R.y*R.k
>>> Curl(v)
Curl(R.y*R.z*R.i + R.x*R.z*R.j + R.x*R.y*R.k)

c                 T    [        U5      n[        R                  " X5      nXl        U$ r   r/   r2   s      r   r0   Curl.__new__]   r6   r   c                 *    [        U R                  SS9$ r8   )curlr1   r<   s     r   r:   	Curl.doitc   s    DJJT**r   r!   Nr@   r!   r   r   rP   rP   N   s    +r   rP   c           	         ^ [        U 5      n[        U5      S:X  a  [        R                  $ [        U5      S:X  Ga!  [	        [        U5      5      nUR                  5       u  p4nUR                  5       u  pgnUR                  5       u  pnU R                  U5      nU R                  U5      nU R                  U5      n[        R                  nU[        X-  U5      [        X-  U5      -
  U-  X-  -  -  nU[        X-  U5      [        X-  U5      -
  U-  X-  -  -  nU[        X-  U5      [        X-  U5      -
  U-  X-  -  -  nT(       a  UR                  5       $ U$ [        U [        [        45      (       a]  SSKJn   [	        [        U5      5      nU R"                   Vs/ s H  nU" UUSS9PM     nn[        R&                  " U4S jU 5       5      $ [        U [(        [*        45      (       a  U R"                   Vs/ s H'  n[        U[        [,        [.        45      (       d  M%  UPM)     snS   n[(        R&                  " S U R"                   5       5      n[-        [1        U5      U5      R                  5       U[3        UTS9-  -   nT(       a  UR                  5       $ U$ [        U [,        [4        [.        45      (       a  [5        U 5      $ [%        S	5      es  snf ! [$         a    U R"                  n GNBf = fs  snf )
a  
Returns the curl of a vector field computed wrt the base scalars
of the given coordinate system.

Parameters
==========

vect : Vector
    The vector operand

doit : bool
    If True, the result is returned after calling .doit() on
    each component. Else, the returned expression contains
    Derivative instances

Examples
========

>>> from sympy.vector import CoordSys3D, curl
>>> R = CoordSys3D('R')
>>> v1 = R.y*R.z*R.i + R.x*R.z*R.j + R.x*R.y*R.k
>>> curl(v1)
0
>>> v2 = R.x*R.y*R.z*R.i
>>> curl(v2)
R.x*R.y*R.j + (-R.x*R.z)*R.k

r      expressT	variablesc              3   8   >#    U  H  n[        UTS 9v   M     g7fr9   N)rU   .0r   r:   s     r   	<genexpr>curl.<locals>.<genexpr>   s     %G$Qd14&8$   c              3   j   #    U  H)  n[        U[        [        [        45      (       a  M%  Uv   M+     g 7fr   r   r   r   r,   r`   r   s     r   ra   rb      $     !gYjVUZ\dLe>f!!Y   $3	3r9   zInvalid argument for curl)r   lenr   zeronextiterbase_vectorsbase_scalarslame_coefficientsdotr   r:   r   r   r
   sympy.vectorrZ   r&   
ValueErrorfromiterr   r	   r   r,   r;   rU   rP   )vectr:   	coord_sysr   jkxyzh1h2h3vectxvectyvectzoutvecrZ   csr&   vectorscalarress    `                    r   rU   rU   g   s   < #4(I
9~{{	Y1	i)	((*a((*a002
:ej!,ej!,-01257W> 	>:ej!,ej!,-01257W> 	>:ej!,ej!,-01257W> 	> ;;= dS),--,!$y/*@D		J	126	J %%%G$%GGGsI.//!%WAjVUH<U.VaWXYZF\\!gTYY!ggF(&16686$vTXBY;YYCxxz!JudH566:899 K !yy! Xs0   ?"K !K3K >$K;&K;K K87K8c           	         ^ [        U 5      n[        U5      S:X  a  [        R                  $ [        U5      S:X  Ga  [	        U [
        [        [        45      (       a  [        U 5      $ [        [        U5      5      nUR                  5       u  p4nUR                  5       u  pgnUR                  5       u  pn[        U R                  U5      XjU5      X-  U-  -  n[        U R                  U5      X{U	5      X-  U-  -  n[        U R                  U5      XU
5      X-  U-  -  nX-   U-   nT(       a  UR!                  5       $ U$ [	        U ["        [$        45      (       a*  ["        R&                  " U4S jU R(                   5       5      $ [	        U [*        [,        45      (       a  U R(                   Vs/ s H'  n[	        U[.        [
        [        45      (       d  M%  UPM)     snS   n[*        R&                  " S U R(                   5       5      n[1        U[3        U5      5      U[5        UTS9-  -   nT(       a  UR!                  5       $ U$ [	        U [
        [        [        45      (       a  [        U 5      $ [7        S5      es  snf )a+  
Returns the divergence of a vector field computed wrt the base
scalars of the given coordinate system.

Parameters
==========

vector : Vector
    The vector operand

doit : bool
    If True, the result is returned after calling .doit() on
    each component. Else, the returned expression contains
    Derivative instances

Examples
========

>>> from sympy.vector import CoordSys3D, divergence
>>> R = CoordSys3D('R')
>>> v1 = R.x*R.y*R.z * (R.i+R.j+R.k)

>>> divergence(v1)
R.x*R.y + R.x*R.z + R.y*R.z
>>> v2 = 2*R.y*R.z*R.j
>>> divergence(v2)
2*R.z

r   rX   c              3   8   >#    U  H  n[        UTS 9v   M     g7fr^   )rM   r_   s     r   ra   divergence.<locals>.<genexpr>   s     L)Q
14 8)rc   c              3   j   #    U  H)  n[        U[        [        [        45      (       a  M%  Uv   M+     g 7fr   re   rf   s     r   ra   r      rg   rh   r9   zInvalid argument for divergence)r   ri   r   Zeror   r   rP   r,   rH   rk   rl   rm   rn   ro   _diff_conditionalrp   r:   r   r
   rs   r&   r   r	   r   r   r;   rM   rr   )rt   r:   ru   r   rv   rw   rx   ry   rz   r{   r|   r}   vxvyvzr   r   r   s    `                r   rM   rM      s	   < #4(I
9~vv	Y1	dUD(344d##i)	((*a((*a002
txx{A26"txx{A26"txx{A26"gl88:
dS),--<<L$))LLLsI.//!%WAjVUH<U.VaWXYZF\\!gTYY!ggFfhv./&FQU9V2VVCxxz!JudH566d##>?? Xs   .$I;I;c                   ^  [        T 5      n[        U5      S:X  a  [        R                  $ [        U5      S:X  a  [	        [        U5      5      nUR                  5       u  p4nUR                  5       u  pgnUR                  5       u  pn[        T U	5      U-  n[        T U
5      U-  n[        T U5      U-  nU(       a  X-  X-  -   X-  -   R                  5       $ X-  X-  -   X-  -   $ [        T [        [        45      (       a'  [        R                  " S T R                   5       5      $ [        T [         ["        45      (       a+  [%        T 5      n[        R                  " U 4S jU 5       5      $ ['        T 5      $ )a_  
Returns the vector gradient of a scalar field computed wrt the
base scalars of the given coordinate system.

Parameters
==========

scalar_field : SymPy Expr
    The scalar field to compute the gradient of

doit : bool
    If True, the result is returned after calling .doit() on
    each component. Else, the returned expression contains
    Derivative instances

Examples
========

>>> from sympy.vector import CoordSys3D, gradient
>>> R = CoordSys3D('R')
>>> s1 = R.x*R.y*R.z
>>> gradient(s1)
R.y*R.z*R.i + R.x*R.z*R.j + R.x*R.y*R.k
>>> s2 = 5*R.x**2*R.z
>>> gradient(s2)
10*R.x*R.z*R.i + 5*R.x**2*R.k

r   rX   c              3   8   #    U  H  n[        U5      v   M     g 7fr   r;   rf   s     r   ra   gradient.<locals>.<genexpr>$  s     %M;Lahqkk;Ls   c              3   F   >#    U  H  nTU-  [        U5      -  v   M     g 7fr   r   )r`   r   scalar_fields     r   ra   r   '  s     %PalQ&6!&Das   !)r   ri   r   rj   rk   rl   ro   rm   rn   r   r:   r   r   r
   rs   r&   r   r	   r*   r,   )r   r:   ru   r{   r|   r}   r   rv   rw   rx   ry   rz   r   r   r   ss   `               r   r;   r;      sK   : #<0I
9~{{	Y1	i)	002
((*a((*aa(2-a(2-a(2-FRVObf,2244v''lS)$455%%%M<;L;L%MMMlS)$455,\:A%%%Pa%PPP%%r   c                   $    \ rS rSrSrS rS rSrg)	Laplaciani+  z
Represents unevaluated Laplacian.

Examples
========

>>> from sympy.vector import CoordSys3D, Laplacian
>>> R = CoordSys3D('R')
>>> v = 3*R.x**3*R.y**2*R.z**3
>>> Laplacian(v)
Laplacian(3*R.x**3*R.y**2*R.z**3)

c                 T    [        U5      n[        R                  " X5      nXl        U$ r   r/   r2   s      r   r0   Laplacian.__new__:  r6   r   c                 2    SSK Jn  U" U R                  5      $ )Nr   )	laplacian)sympy.vector.functionsr   r1   )r=   r>   r   s      r   r:   Laplacian.doit@  s    4$$r   r!   Nr@   r!   r   r   r   r   +  s    %r   r   c                     SSK Jn  U" XR                  SS9nX#-  U-  nU(       a  [        Xa5      $ [        R
                  $ )z
First re-expresses expr in the system that base_scalar belongs to.
If base_scalar appears in the re-expressed form, differentiates
it wrt base_scalar.
Else, returns 0
r   rY   Tr[   )r   rZ   systemr   r   r   )r   base_scalarcoeff_1coeff_2rZ   new_exprargs          r   r   r   E  s<     /t//4@H

h
&C+.:c':AFF:r   )T)r$   sympy.core.exprr   
sympy.corer   r   r   sympy.vector.coordsysrectr   sympy.vector.vectorr   r	   r
   r   r   sympy.core.functionr   sympy.core.addr   sympy.core.mulr   r   r*   r,   rH   rP   rU   rM   r;   r   r   r!   r   r   <module>r      sw       5 5 0 H H *  /t /21 12+4 +2H:V@@F3&l% %4
;r   