
    ЦiE                       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
  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\5      r# " 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 r+\#\#l,        \&\#l-        \%\#l.        \'\#l/        \$\#l0        \'" 5       \#l1        g)     )annotations)product)Add)	StdFactKB)
AtomicExprExpr)Pow)S)default_sort_key)sympifysqrt)ImmutableDenseMatrix)BasisDependentZeroBasisDependentBasisDependentMulBasisDependentAdd)
CoordSys3D)Dyadic
BaseDyadic	DyadicAddc                  4   \ 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'   \	S 5       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zeroc                    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    R/var/www/html/ai-image-ml/venv/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.normalize@   s     nn&&&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.functionsr4   )fieldr4   r%   s     r&   r4   *Vector.dot.<locals>.directional_derivative}   s    I-eT::r)   )
isinstancer   r    r   r!   r'   itemsargsdotsympy.vector.deloperatorr2   	TypeErrorstr)r%   otheroutveckvvect_dotr2   r4   s   `       r&   r;   
Vector.dotF   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r;   r%   r?   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   r1   )	r8   r   r    r!   r'   r9   crossr:   outer)r%   r?   outdyadrA   rB   cross_productrM   s          r&   rL   Vector.cross   s    @ eV$$$
++{{"kkG((..0 $

166!9 5%++AFF1I6u9$ 1 NT!!r)   c                $    U R                  U5      $ rF   rL   rH   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)r8   r   r=   r    r   r!   r   r'   r9   r   r   )r%   r?   k1v1k2v2r:   s          r&   rM   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

)equalsr   r!   r
   Zeror;   )r%   r?   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.operatorsrc   r8   r    r
   r^   nextiterbase_vectorstupler;   )r%   rc   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      $ rF   )rM   rH   s     r&   __or__Vector.__or__  rU   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]])

)Matrixrg   r;   )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'   r9   getrr   r   r!   )r%   partsvectmeasures       r&   separateVector.separate6  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)	r8   r   r=   r
   r^   
ValueError	VectorMulr	   NegativeOne)oner?   s     r&   _div_helperVector._div_helperP  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__propertyr'   r+   r.   r;   rI   rL   rS   rM   r`   rk   rn   rt   r{   r   __static_attributes__r   r)   r&   r   r      s     IIL
   (!'< | kkGO*"X! mmGO" H;4 6 66! ]]FN/:4	Cr)   r   c                  \   ^  \ 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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)formatr>   ranger~   r8   r   r=   _vector_namessuper__new__r
   _base_instanceOner#   _measure_number_name_pretty_form_latex_form_system_idr   _assumptions_sys)	clsindexrr   
pretty_str	latex_strnameobjassumptions	__class__s	           r&   r   BaseVector.__new__b  s   e,Je,I_
	N	a#677&*--;<<##E*goc1U8V4 ,eeLL3&-	
?#/$d+$[1
 
r)   c                    U R                   $ rF   )r   r$   s    r&   rr   BaseVector.system  s    ||r)   c                    U R                   $ rF   )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   rr   s       r&   
_sympyreprBaseVector._sympyrepr  s1    ~~f%+f.B.B5.IIIr)   c                    U 1$ rF   r   r$   s    r&   free_symbolsBaseVector.free_symbols  s	    vr)   r   )NN)r   r   r   r   r   r   r   rr   r   r   r   r   __classcell__)r   s   @r&   r   r   \  sA    
!F  J  r)   r   c                  $    \ rS rSrSrS rS rSrg)	VectorAddi  z*
Class to denote sum of Vector instances.
c                :    [         R                  " U /UQ70 UD6nU$ rF   )r   r   r   r:   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{   r9   sortrg   r'   r   )	r%   r   ret_strr9   rr   ry   
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$ rF   )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$ rF   )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$ rF   )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      $ rF   )rL   r   r   r%   hintss     r&   doit
Cross.doit  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)Doti  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      $ rF   )r;   r   r   r   s     r&   r   Dot.doit  s    4;;,,r)   r   Nr   r   r)   r&   r   r     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rF   rR   .0rj   vect2s     r&   	<genexpr>cross.<locals>.<genexpr>!  s     !F:a%5//:   c              3  <   >#    U  H  n[        TU5      v   M     g 7frF   rR   r   rj   vect1s     r&   r   r   #  s     !F:a%q//:r   r   >   r   r1      r1   r   express)r8   r   r   fromiterr:   r   r   r   r!   
differencepoprg   	functionsr  rL   r~   r   r    r   re   rf   r'   r9   )r   r   n1n2n3signr  rB   rX   m1rZ   m2s   ``          r&   rL   rL     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rF   rG   r   s     r&   r   dot.<locals>.<genexpr>Q  s     >:aC5MM:r   c              3  <   >#    U  H  n[        TU5      v   M     g 7frF   rG   r   s     r&   r   r  S  s     >:aCqMM:r   r1   r  )r8   r   r  r:   r   r   r
   r   r^   r  r  r;   r~   r   r    r   re   rf   r'   r9   )r   r   r  rB   rX   r  rZ   r  s   ``      r&   r;   r;   @  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)2
__future__r   	itertoolsr   sympy.core.addr   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   rq   sympy.vector.basisdependentr   r   r   r   sympy.vector.coordsysrectr   sympy.vector.dyadicr   r   r   r   r   r   r   r    r   r   rL   r;   r   r   r   r   r   r!   r   r)   r&   <module>r!     s    "   , ,   " / & 9 C: : 0 = =FC^ FCR
6 6r!6 ,$!6 $,#V /F /@-$ -B-`'T      lr)   