
    \hbO                       S SK Jr  S SKJr  S SKJrJr  S SKJr  S SK	J
r
Jr  S SKJr  S SKJr  S SKJr  S S	KJr  S S
KJr  S SKJr  S SKJrJrJrJr  S SKJr  S SK J!r!J"r"J#r#  S SK$J%r%   " S S\5      r&S r'S\'" \5      /0\RP                  \&'    " S S\&\
5      r) " S S\\&5      r* " S S\\&5      r+ " S S\\&5      r, " S S\&5      r- " S S\5      r.S  r/S! r0\&\&l1        \+\&l2        \*\&l3        \,\&l4        \)\&l5        \," 5       \&l6        g")#    )annotations)product)AddBasic)	StdFactKB)
AtomicExprExpr)Pow)S)default_sort_key)sympifysqrt)ImmutableDenseMatrix)BasisDependentZeroBasisDependentBasisDependentMulBasisDependentAdd)
CoordSys3D)Dyadic
BaseDyadic	DyadicAdd)
VectorKindc                  R   \ rS rSr% SrSrSrSrS\S'   S\S'   S\S	'   S\S
'   S\S'   S\S'   \	" 5       r
S\S'   \S 5       rS rS rS rS rS r\R                  \l        S rS r\R                  \l        S rS!S jr\S 5       rS r\R                  \l        S rS rS rSrg )"Vector   z
Super class for all Vector classes.
Ideally, neither this class nor any of its subclasses should be
instantiated by the user.
FTg      (@ztype[Vector]
_expr_type	_mul_func	_add_func
_zero_func
_base_func
VectorZerozeror   kindc                    U R                   $ )a*  
Returns the components of this vector in the form of a
Python dictionary mapping BaseVector instances to the
corresponding measure numbers.

Examples
========

>>> from sympy.vector import CoordSys3D
>>> C = CoordSys3D('C')
>>> v = 3*C.i + 4*C.j + 5*C.k
>>> v.components
{C.i: 3, C.j: 4, C.k: 5}

)_componentsselfs    K/var/www/auris/envauris/lib/python3.13/site-packages/sympy/vector/vector.py
componentsVector.components(   s    &     c                    [        X -  5      $ )z'
Returns the magnitude of this vector.
r   r'   s    r)   	magnitudeVector.magnitude=   s     DK  r,   c                &    X R                  5       -  $ )z0
Returns the normalized version of this vector.
)r.   r'   s    r)   	normalizeVector.normalizeC   s     nn&&&r,   c                N    X-
  nUR                  U5      nUR                  S5      $ )a  
Check if ``self`` and ``other`` are identically equal vectors.

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

Checks if two vector expressions are equal for all possible values of
the symbols present in the expressions.

Examples
========

>>> from sympy.vector import CoordSys3D
>>> from sympy.abc import x, y
>>> from sympy import pi
>>> C = CoordSys3D('C')

Compare vectors that are equal or not:

>>> C.i.equals(C.j)
False
>>> C.i.equals(C.i)
True

These two vectors are equal if `x = y` but are not identically equal
as expressions since for some values of `x` and `y` they are unequal:

>>> v1 = x*C.i + C.j
>>> v2 = y*C.i + C.j
>>> v1.equals(v1)
True
>>> v1.equals(v2)
False

Vectors from different coordinate systems can be compared:

>>> D = C.orient_new_axis('D', pi/2, C.i)
>>> D.j.equals(C.j)
False
>>> D.j.equals(C.k)
True

Parameters
==========

other: Vector
    The other vector expression to compare with.

Returns
=======

``True``, ``False`` or ``None``. A return value of ``True`` indicates
that the two vectors are identically equal. A return value of ``False``
indicates that they are not. In some cases it is not possible to
determine if the two vectors are identically equal and ``None`` is
returned.

See Also
========

sympy.core.expr.Expr.equals
r   )dotequals)r(   otherdiff	diff_mag2s       r)   r5   Vector.equalsI   s*    ~ |HHTN	""r,   c                   ^  [        U[        5      (       a  [        T [        5      (       a  [        R                  $ [        R                  nUR
                  R                  5        H:  u  p4UR                  S   R                  T 5      nX%U-  UR                  S   -  -  nM<     U$ SSK	J
n  [        X[        45      (       d  [        [        U5      S-   S-   5      e[        X5      (       a  U 4S jnU$ [        T U5      $ )aV  
Returns the dot product of this Vector, either with another
Vector, or a Dyadic, or a Del operator.
If 'other' is a Vector, returns the dot product scalar (SymPy
expression).
If 'other' is a Dyadic, the dot product is returned as a Vector.
If 'other' is an instance of Del, returns the directional
derivative operator as a Python function. If this function is
applied to a scalar expression, it returns the directional
derivative of the scalar field wrt this Vector.

Parameters
==========

other: Vector/Dyadic/Del
    The Vector or Dyadic we are dotting with, or a Del operator .

Examples
========

>>> from sympy.vector import CoordSys3D, Del
>>> C = CoordSys3D('C')
>>> delop = Del()
>>> C.i.dot(C.j)
0
>>> C.i & C.i
1
>>> v = 3*C.i + 4*C.j + 5*C.k
>>> v.dot(C.k)
5
>>> (C.i & delop)(C.x*C.y*C.z)
C.y*C.z
>>> d = C.i.outer(C.i)
>>> C.i.dot(d)
C.i

r      )Delz is not a vector, dyadic or zdel operatorc                "   > SSK Jn  U" U T5      $ )Nr   )directional_derivative)sympy.vector.functionsr>   )fieldr>   r(   s     r)   r>   *Vector.dot.<locals>.directional_derivative   s    I-eT::r,   )
isinstancer   r"   r   r#   r*   itemsargsr4   sympy.vector.deloperatorr<   	TypeErrorstr)r(   r6   outveckvvect_dotr<   r>   s   `       r)   r4   
Vector.dot   s    P eV$$$
++{{"[[F((..066!9==.Q,22 1 M0%v//CJ)GG*+ , , e!!; *)4r,   c                $    U R                  U5      $ Nr4   r(   r6   s     r)   __and__Vector.__and__   s    xxr,   c                |   [        U[        5      (       a  [        U [        5      (       a  [        R                  $ [        R                  nUR                  R                  5        HH  u  p4U R                  UR                  S   5      nUR                  UR                  S   5      nX$U-  -  nMJ     U$ [        X5      $ )a  
Returns the cross product of this Vector with another Vector or
Dyadic instance.
The cross product is a Vector, if 'other' is a Vector. If 'other'
is a Dyadic, this returns a Dyadic instance.

Parameters
==========

other: Vector/Dyadic
    The Vector or Dyadic we are crossing with.

Examples
========

>>> from sympy.vector import CoordSys3D
>>> C = CoordSys3D('C')
>>> C.i.cross(C.j)
C.k
>>> C.i ^ C.i
0
>>> v = 3*C.i + 4*C.j + 5*C.k
>>> v ^ C.i
5*C.j + (-4)*C.k
>>> d = C.i.outer(C.i)
>>> C.j.cross(d)
(-1)*(C.k|C.i)

r   r;   )	rB   r   r"   r#   r*   rC   crossrD   outer)r(   r6   outdyadrI   rJ   cross_productrU   s          r)   rT   Vector.cross   s    @ eV$$$
++{{"kkG((..0 $

166!9 5%++AFF1I6u9$ 1 NT!!r,   c                $    U R                  U5      $ rN   rT   rP   s     r)   __xor__Vector.__xor__       zz%  r,   c                   [        U[        5      (       d  [        S5      e[        U [        5      (       d  [        U[        5      (       a  [        R
                  $ [        U R                  R                  5       UR                  R                  5       5       VVVVs/ s H  u  u  p#u  pEX5-  [        X$5      -  PM     nnnnn[        U6 $ s  snnnnf )aA  
Returns the outer product of this vector with another, in the
form of a Dyadic instance.

Parameters
==========

other : Vector
    The Vector with respect to which the outer product is to
    be computed.

Examples
========

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

z!Invalid operand for outer product)rB   r   rF   r"   r   r#   r   r*   rC   r   r   )r(   r6   k1v1k2v2rD   s          r)   rU   Vector.outer   s    . %((?@@z**5*--;;
 4??002E4D4D4J4J4LMOM 4F8BXbJr..M 	 O $Os   !C

c                8   U R                  [        R                  5      (       a'  U(       a  [        R                  $ [        R                  $ U(       a#  U R                  U5      U R                  U 5      -  $ U R                  U5      U R                  U 5      -  U -  $ )aC  
Returns the vector or scalar projection of the 'other' on 'self'.

Examples
========

>>> from sympy.vector.coordsysrect import CoordSys3D
>>> C = CoordSys3D('C')
>>> i, j, k = C.base_vectors()
>>> v1 = i + j + k
>>> v2 = 3*i + 4*j
>>> v1.projection(v2)
7/3*C.i + 7/3*C.j + 7/3*C.k
>>> v1.projection(v2, scalar=True)
7/3

)r5   r   r#   r   Zeror4   )r(   r6   scalars      r)   
projectionVector.projection$  sj    $ ;;v{{###1664488E?TXXd^3388E?TXXd^3d::r,   c                D   SSK Jn  [        U [        5      (       a/  [        R
                  [        R
                  [        R
                  4$ [        [        U" U 5      5      5      R                  5       n[        U Vs/ s H  o0R                  U5      PM     sn5      $ s  snf )ai  
Returns the components of this vector but the output includes
also zero values components.

Examples
========

>>> from sympy.vector import CoordSys3D, Vector
>>> C = CoordSys3D('C')
>>> v1 = 3*C.i + 4*C.j + 5*C.k
>>> v1._projections
(3, 4, 5)
>>> v2 = C.x*C.y*C.z*C.i
>>> v2._projections
(C.x*C.y*C.z, 0, 0)
>>> v3 = Vector.zero
>>> v3._projections
(0, 0, 0)
r   )_get_coord_systems)sympy.vector.operatorsrj   rB   r"   r   re   nextiterbase_vectorstupler4   )r(   rj   base_vecis       r)   _projectionsVector._projections>  sn    , 	>dJ''FFAFFAFF++/567DDF848ahhqk84554s   <Bc                $    U R                  U5      $ rN   )rU   rP   s     r)   __or__Vector.__or__Z  r]   r,   c                |    [        UR                  5        Vs/ s H  o R                  U5      PM     sn5      $ s  snf )a  
Returns the matrix form of this vector with respect to the
specified coordinate system.

Parameters
==========

system : CoordSys3D
    The system wrt which the matrix form is to be computed

Examples
========

>>> from sympy.vector import CoordSys3D
>>> C = CoordSys3D('C')
>>> from sympy.abc import a, b, c
>>> v = a*C.i + b*C.j + c*C.k
>>> v.to_matrix(C)
Matrix([
[a],
[b],
[c]])

)Matrixrn   r4   )r(   systemunit_vecs      r)   	to_matrixVector.to_matrix_  sA    4 **,., /7xx),. / 	/ .s   9c                    0 nU R                   R                  5        H@  u  p#UR                  UR                  [        R
                  5      X#-  -   XR                  '   MB     U$ )a]  
The constituents of this vector in different coordinate systems,
as per its definition.

Returns a dict mapping each CoordSys3D to the corresponding
constituent Vector.

Examples
========

>>> from sympy.vector import CoordSys3D
>>> R1 = CoordSys3D('R1')
>>> R2 = CoordSys3D('R2')
>>> v = R1.i + R2.i
>>> v.separate() == {R1: R1.i, R2: R2.i}
True

)r*   rC   getry   r   r#   )r(   partsvectmeasures       r)   separateVector.separate|  sR    ( !__224MD"'))DKK"E"&.#1E++ 5 r,   c                2   [        U [        5      (       a   [        U[        5      (       a  [        S5      e[        U [        5      (       aC  U[        R                  :X  a  [        S5      e[        U [        U[        R                  5      5      $ [        S5      e)z'Helper for division involving vectors. zCannot divide two vectorszCannot divide a vector by zeroz#Invalid division involving a vector)	rB   r   rF   r   re   
ValueError	VectorMulr
   NegativeOne)oner6   s     r)   _div_helperVector._div_helper  so    c6""z%'@'@788V$$ !ABBS#eQ]]";<<ABBr,    N)F)__name__
__module____qualname____firstlineno____doc__	is_scalar	is_Vector_op_priority__annotations__r   r$   propertyr*   r.   r1   r5   r4   rQ   rT   r[   rU   rg   rr   ru   r{   r   r   __static_attributes__r   r,   r)   r   r      s     IIL
!|D*#   (!'A#F< | kkGO*"X! mmGO" H;4 6 66! ]]FN/:4	Cr,   r   c                   ^  U 4S jnU$ )Nc                   > [         [        0T   n/ nU R                   H5  n[        UR                  [
        5      (       d  M$  UR                  U5        M7     U[        :X  a  [        U6 R                  SS9$ g )NF)deep)r   	VectorAddrD   rB   r$   r   appenddoit)expr	vec_classvectorstermclss       r)   _postprocessor)get_postprocessor.<locals>._postprocessor  sj    )$S)	IID$))Z00t$  	!g&+++77 "r,   r   )r   r   s   ` r)   get_postprocessorr     s    8 r,   r   c                  b   ^  \ rS rSrSrS
U 4S jjr\S 5       rS rS r	\S 5       r
S rS	rU =r$ )
BaseVectori  z!
Class to denote a base vector.

c                N  > Uc  SR                  U5      nUc  SR                  U5      n[        U5      n[        U5      nU[        SS5      ;  a  [        S5      e[	        U[
        5      (       d  [        S5      eUR                  U   n[        TU ]%  U [        U5      U5      nXfl        U[        R                  0Ul        [        R                  Ul        UR                  S-   U-   Ul        SU-   Ul        XFl        X&l        X4Ul        S	S
0n[)        U5      Ul        X&l        U$ )Nzx{}zx_{}r      zindex must be 0, 1 or 2zsystem should be a CoordSys3D. commutativeT)formatrG   ranger   rB   r   rF   _vector_namessuper__new__r   _base_instanceOner&   _measure_number_name_pretty_form_latex_form_system_idr   _assumptions_sys)	r   indexry   
pretty_str	latex_strnameobjassumptions	__class__s	           r)   r   BaseVector.__new__  s   e,Je,I_
	N	a#677&*--;<<##E*goc1U8V4 ,eeLL3&-	
?#/$d+$[1
 
r,   c                    U R                   $ rN   )r   r'   s    r)   ry   BaseVector.system  s    ||r,   c                    U R                   $ rN   )r   )r(   printers     r)   	_sympystrBaseVector._sympystr  s    zzr,   c                f    U R                   u  p#UR                  U5      S-   UR                  U   -   $ )Nr   )r   _printr   )r(   r   r   ry   s       r)   
_sympyreprBaseVector._sympyrepr  s1    ~~f%+f.B.B5.IIIr,   c                    U 1$ rN   r   r'   s    r)   free_symbolsBaseVector.free_symbols  s	    vr,   c                    U $ rN   r   r'   s    r)   _eval_conjugateBaseVector._eval_conjugate  s    r,   r   )NN)r   r   r   r   r   r   r   ry   r   r   r   r   r   __classcell__)r   s   @r)   r   r     sK    
!F  J   r,   r   c                  $    \ rS rSrSrS rS rSrg)r   i  z*
Class to denote sum of Vector instances.
c                :    [         R                  " U /UQ70 UD6nU$ rN   )r   r   r   rD   optionsr   s       r)   r   VectorAdd.__new__  !    ''>d>g>
r,   c                8   Sn[        U R                  5       R                  5       5      nUR                  S S9  U HW  u  pEUR	                  5       nU H<  nXuR
                  ;   d  M  U R
                  U   U-  nX!R                  U5      S-   -  nM>     MY     US S $ )Nr   c                (    U S   R                  5       $ )Nr   )__str__)xs    r)   <lambda>%VectorAdd._sympystr.<locals>.<lambda>  s    1r,   keyz + )listr   rC   sortrn   r*   r   )	r(   r   ret_strrC   ry   r   
base_vectsr   	temp_vects	            r)   r   VectorAdd._sympystr  s    T]]_**,-

/
0!LF,,.J' $ 2Q 6I~~i85@@G   " s|r,   r   N)r   r   r   r   r   r   r   r   r   r,   r)   r   r     s    
r,   r   c                  >    \ rS rSrSrS r\S 5       r\S 5       rSr	g)r   i  z6
Class to denote products of scalars and BaseVectors.
c                :    [         R                  " U /UQ70 UD6nU$ rN   )r   r   r   s       r)   r   VectorMul.__new__  r   r,   c                    U R                   $ )z(The BaseVector involved in the product. )r   r'   s    r)   base_vectorVectorMul.base_vector  s     """r,   c                    U R                   $ )zDThe scalar expression involved in the definition of
this VectorMul.
)r   r'   s    r)   measure_numberVectorMul.measure_number  s    
 ###r,   r   N)
r   r   r   r   r   r   r   r   r   r   r   r,   r)   r   r     s4     # # $ $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 vector
g333333(@0z\mathbf{\hat{0}}c                2    [         R                  " U 5      nU$ rN   )r   r   )r   r   s     r)   r   VectorZero.__new__%  s     ((-
r,   r   N)
r   r   r   r   r   r   r   r   r   r   r   r,   r)   r"   r"     s     LL%Kr,   r"   c                  $    \ rS rSrSrS rS rSrg)Crossi*  a\  
Represents unevaluated Cross product.

Examples
========

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

c                    [        U5      n[        U5      n[        U5      [        U5      :  a  [        X!5      * $ [        R                  " XU5      nXl        X#l        U$ rN   )r   r   r   r	   r   _expr1_expr2r   expr1expr2r   s       r)   r   Cross.__new__<  sT    E"%5e%<<%'''ll3u-


r,   c                B    [        U R                  U R                  5      $ rN   )rT   r   r   r(   hintss     r)   r   
Cross.doitF  s    T[[$++..r,   r   Nr   r   r   r   r   r   r   r   r   r,   r)   r   r   *  s    "/r,   r   c                  $    \ rS rSrSrS rS rSrg)DotiJ  aW  
Represents unevaluated Dot product.

Examples
========

>>> from sympy.vector import CoordSys3D, Dot
>>> from sympy import symbols
>>> R = CoordSys3D('R')
>>> a, b, c = symbols('a b c')
>>> v1 = R.i + R.j + R.k
>>> v2 = a * R.i + b * R.j + c * R.k
>>> Dot(v1, v2)
Dot(R.i + R.j + R.k, a*R.i + b*R.j + c*R.k)
>>> Dot(v1, v2).doit()
a + b + c

c                    [        U5      n[        U5      n[        X/[        S9u  p[        R                  " XU5      nXl        X#l        U$ )Nr   )r   sortedr   r	   r   r   r   r   s       r)   r   Dot.__new__^  sD    un2BCll3u-


r,   c                B    [        U R                  U R                  5      $ rN   )r4   r   r   r   s     r)   r   Dot.doitg  s    4;;,,r,   r   Nr  r   r,   r)   r  r  J  s    &-r,   r  c                  ^ ^ [        T [        5      (       a)  [        R                  U4S jT R                   5       5      $ [        T[        5      (       a)  [        R                  U 4S jTR                   5       5      $ [        T [
        5      (       a  [        T[
        5      (       a  T R                  TR                  :X  a  T R                  S   nTR                  S   nX#:X  a  [        R                  $ 1 SkR                  X#15      R                  5       nUS-   S-  U:X  a  SOSnUT R                  R                  5       U   -  $ SSKJn   U" T TR                  5      n[        UT5      $ [        T ["        5      (       d  [        T["        5      (       a  [        R                  $ [        T [$        5      (       a=  ['        [)        T R*                  R-                  5       5      5      u  pU	[        UT5      -  $ [        T[$        5      (       a=  ['        [)        TR*                  R-                  5       5      5      u  pU[        T U
5      -  $ [!        T T5      $ ! [         a    [!        T T5      s $ f = f)	a2  
Returns cross product of two vectors.

Examples
========

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

c              3  <   >#    U  H  n[        UT5      v   M     g 7frN   rZ   .0rq   vect2s     r)   	<genexpr>cross.<locals>.<genexpr>|  s     !F:a%5//:   c              3  <   >#    U  H  n[        TU5      v   M     g 7frN   rZ   r  rq   vect1s     r)   r  r  ~  s     !F:a%q//:r  r   >   r   r;      r;   r   express)rB   r   r   fromiterrD   r   r   r   r#   
differencepoprn   	functionsr  rT   r   r   r"   r   rl   rm   r*   rC   )r  r  n1n2n3signr  rJ   r`   m1rb   m2s   ``          r)   rT   rT   k  s     %!!!F5::!FFF%!!!F5::!FFF%$$E:)F)F::#ABABx{{"$$bX.335Bq&A+1"D

//1"555&	#uzz*A E?"%$$
5*(E(E{{%##d5++11345%E"""%##d5++11345%r"""  	'&&	's   I I10I1c                .  ^ ^ [        T [        5      (       a*  [        R                  " U4S jT R                   5       5      $ [        T[        5      (       a*  [        R                  " U 4S jTR                   5       5      $ [        T [        5      (       a{  [        T[        5      (       af  T R
                  TR
                  :X  a&  T T:X  a  [        R                  $ [        R                  $ SSK	J
n   U" TT R
                  5      n[        T U5      $ [        T [        5      (       d  [        T[        5      (       a  [        R                  $ [        T [        5      (       a=  [!        [#        T R$                  R'                  5       5      5      u  pEU[        UT5      -  $ [        T[        5      (       a=  [!        [#        TR$                  R'                  5       5      5      u  pgU[        T U5      -  $ [        T T5      $ ! [         a    [        T T5      s $ f = f)a  
Returns dot product of two vectors.

Examples
========

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

c              3  <   >#    U  H  n[        UT5      v   M     g 7frN   rO   r  s     r)   r  dot.<locals>.<genexpr>  s     >:aC5MM:r  c              3  <   >#    U  H  n[        TU5      v   M     g 7frN   rO   r  s     r)   r  r&    s     >:aCqMM:r  r;   r  )rB   r   r  rD   r   r   r   r   re   r  r  r4   r   r  r"   r   rl   rm   r*   rC   )r  r  r  rJ   r`   r"  rb   r#  s   ``      r)   r4   r4     s     %||>5::>>>%||>5::>>>%$$E:)F)F::#!UN15566&	!uzz*A ua= %$$
5*(E(Evv%##d5++11345#b%.  %##d5++11345#eR.  ue  	%ue$$	%s   2G; ;HHN)7
__future__r   	itertoolsr   
sympy.corer   r   sympy.core.assumptionsr   sympy.core.exprr   r	   sympy.core.powerr
   sympy.core.singletonr   sympy.core.sortingr   sympy.core.sympifyr   (sympy.functions.elementary.miscellaneousr   sympy.matrices.immutabler   rx   sympy.vector.basisdependentr   r   r   r   sympy.vector.coordsysrectr   sympy.vector.dyadicr   r   r   sympy.vector.kindr   r   r   "_constructor_postprocessor_mappingr   r   r   r"   r   r  rT   r4   r   r   r   r    r!   r#   r   r,   r)   <module>r8     s	   "  ! , ,   " / & 9 C: : 0 = = (KC^ KC^
 
c"#4 ( ( 09 9x!6 ,$!6 $,#V /F /@-$ -B-`'T      lr,   