K i{!,ddlmZddlmZmZmZmZddlmZm Z ddl m Z ddl m ZddlZGddeZGd d ee ZGd d eeZGd deeZGddeeZee_ee_ee_ee_ee_ee_y)) annotations)BasisDependentBasisDependentAddBasisDependentMulBasisDependentZero)SPow) AtomicExpr)ImmutableDenseMatrixNceZdZUdZdZded<ded<ded<ded<ded<d ed <ed Zd Zd Z eje _dZ dZ e je _ddZ dZ 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 DyadicZerozeroc|jS)z Returns the components of this dyadic in the form of a Python dictionary mapping BaseDyadic instances to the corresponding measure numbers. ) _componentsselfs Y/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sympy/vector/dyadic.py componentszDyadic.components!sc,tjj}t|tr |j St||rf|j }|j jD];\}}|jdj|}|||z|jdzz }=|St|trtj }|j jD]\}} |j jD]i\} } |jdj| jd}|jdj| jd} ||| z| z| zz }k|Stdtt|zdz)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 rz!Inner product is not defined for z and Dyadics.)sympyvectorVector isinstancerrritemsargsdotr outer TypeErrorstrtype) rotherr outveckvvect_dotoutdyadk1v1k2v2 outer_products rr$z Dyadic.dot-st6$$ e/ 0;;  v &[[F--/ 3166!9==/(Q,22 3M v &kkG////1 BB#..446BFB!wwqz~~bggaj9H$&GGAJ$4$4RWWQZ$@Mx"}r1MAAGB B N?U ,-/>?@ @rc$|j|SN)r$rr)s r__and__zDyadic.__and__]sxxrctjj}||jk(rtjSt ||rxtj}|j jD]I\}}|jdj|}|jdj|}|||zz }K|Sttt|dzdz)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) rrz not supported for zcross with dyadics)rrr rr r!rr"r#crossr%r&r'r()rr)r r.r+r, cross_productr%s rr9z Dyadic.crossbs,$$ FKK ;;  v &kkG--/ %1 !q  6 q  61u9$ %NCU ,/DD012 2rc$|j|Sr5)r9r6s r__xor__zDyadic.__xor__szz%  rNc ||}t|Dcgc])}|D]"}|j|j|$+c}}jddScc}}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)rsystem second_systemijs r to_matrixzDyadic.to_matrixsaN  "M6&a$&aquuT{q)&)&''.wq!} 5&s.A ct|trt|tr tdt|tr$t|t |t j Std)z' Helper for division involving dyadics zCannot divide two dyadicszCannot divide by a dyadic)r!r r& DyadicMulr r NegativeOne)oner)s r _div_helperzDyadic._div_helpersO c6 "z%'@78 8 V $S#eQ]]";< <78 8rr5)__name__ __module__ __qualname____doc__ _op_priority__annotations__propertyrr$r7r9r<rErJrrr r s L      .@`kkGO"2H!mmGO+5Z9rr c.eZdZdZfdZdZdZxZS) BaseDyadicz9 Class to denote a base dyadic tensor component. cxtjj}tjj}tjj}t |||frt |||fs t d||jk(s||jk(rtjSt|)|||}||_ d|_ |tji|_|j |_d|j"zdz|j"zdz|_d|j$zdz|j$zdz|_|S) Nz1BaseDyadic cannot be composed of non-base vectorsr(|)z\left(z {\middle|}z\right))rrr BaseVector VectorZeror!r&rr super__new___base_instance_measure_numberrOner_sys _pretty_form _latex_form)clsvector1vector2r rYrZobj __class__s rr\zBaseDyadic.__new__s!$$\\,, \\,, 'J #;<wZ(@A&' ' #w&++'=;; goc7G4 ,<<'"6"66<$112478$w':'::]J"../1;< rcdj|j|jd|j|jdS)Nz({}|{})rrformat_printr#rprinters r _sympystrzBaseDyadic._sympystrs> NN499Q< ('..1*FH Hrcdj|j|jd|j|jdS)NzBaseDyadic({}, {})rrrirls r _sympyreprzBaseDyadic._sympyreprs>#** NN499Q< ('..1*FH Hr)rKrLrMrNr\rnrp __classcell__)rgs@rrTrTs2HHrrTc6eZdZdZdZedZedZy)rGz% Products of scalars and BaseDyadics c8tj|g|i|}|Sr5)rr\rcr#optionsrfs rr\zDyadicMul.__new__!''>d>g> rc|jS)z) The BaseDyadic involved in the product. )r]rs r base_dyadiczDyadicMul.base_dyadics"""rc|jS)zU The scalar expression involved in the definition of this DyadicMul. )r^rs rmeasure_numberzDyadicMul.measure_numbers ###rN)rKrLrMrNr\rQrxrzrRrrrGrGs2/##$$rrGceZdZdZdZdZy) DyadicAddz Class to hold dyadic sums c8tj|g|i|}|Sr5)rr\rts rr\zDyadicAdd.__new__rvrct|jj}|jddj fd|DS)Nc(|djS)Nr)__str__)xs rz%DyadicAdd._sympystr..s1r)keyz + c3LK|]\}}j||zywr5)rk).0r+r,rms r z&DyadicAdd._sympystr..s"BDAq'..Q/Bs!$)listrr"sortjoin)rrmr"s ` rrnzDyadicAdd._sympystrs>T__**,- / 0zzBEBBBrN)rKrLrMrNr\rnrRrrr|r|s%Crr|c"eZdZdZdZdZdZdZy)rz' Class to denote a zero dyadic g333333*@z(0|0)z#(\mathbf{\hat{0}}|\mathbf{\hat{0}})c0tj|}|Sr5)rr\)rcrfs rr\zDyadicZero.__new__s ((- rN)rKrLrMrNrOrarbr\rRrrrr sLL8Krr) __future__rsympy.vector.basisdependentrrrr sympy.corerr sympy.core.exprr sympy.matrices.immutabler r? sympy.vectorrr rTrGr|rrrrrrrrRrrrs"PP&Ct9^t9n$H$HN$!6$( C!6 C #V l r