K iQ.ddlmZddlmZddlmZmZddl m Z m Z ddl m Z ddlmZddlmZddlmZdd lmZmZmZdd lmZerdd lmZGd d eZGddeeZGddeeZ GddeZ!y)) annotations) TYPE_CHECKING)simplifytrigsimp)call_highest_priority _sympifyit) StdFactKBdiff)Integral)factor)SAddMul)Expr) BaseVectorceZdZUdZded<eddZeddZedd Zed d Z e d e ed dZ e d e eddZ dZe d e eddZeddZd$dZexjej"jz c_eZdZexjejz c_dZexjejz c_dZdZdZdZdZdZexjejz c_d%d Zd!Z d"Z!e!xje"jz c_d#Z#y)&BasisDependentz Super class containing functionality common to vectors and dyadics. Named so because the representation of these quantities in sympy.vector is dependent on the basis they are expressed in. BasisDependentZerozero__radd__c&|j||SN _add_funcselfothers a/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sympy/vector/basisdependent.py__add__zBasisDependent.__add__s~~dE**r c&|j||Srrrs rrzBasisDependent.__radd__s~~eT**r!__rsub__c(|j|| Srrrs r__sub__zBasisDependent.__sub__#s~~dUF++r!r%c(|j|| Srrrs rr#zBasisDependent.__rsub__'s~~edU++r!r__rmul__c&|j||Sr _mul_funcrs r__mul__zBasisDependent.__mul__+s~~dE**r!r+c&|j||Srr)rs rr'zBasisDependent.__rmul__0s~~eT**r!cB|jtj|Sr)r*r NegativeOners r__neg__zBasisDependent.__neg__5s~~ammT22r! __rtruediv__c$|j|Sr) _div_helperrs r __truediv__zBasisDependent.__truediv__8s&&r!r4ctdS)NzInvalid divisor for division) TypeErrorrs rr1zBasisDependent.__rtruediv__=s788r!Nc||||||d}|j} |jjD]\} } | | j|fi|| zz } | S)z Implements the SymPy evalf routine for this quantity. evalf's documentation ===================== )subsmaxnchopstrictquadverbose)r componentsitemsevalf) rnr8r9r:r;r<r=optionsveckvs rr@zBasisDependent.evalfAsftD6w0iiOO))+ -DAq 71771((1, ,C - r!c |jjDcgc]\}}t|fi||z}}}|j|Scc}}w)z Implements the SymPy simplify routine for this quantity. simplify's documentation ======================== )r>r?simpr)rkwargsrDrEsimp_componentss rrzBasisDependent.simplifyTsW$(??#8#8#:<1a ,V,q0<<t~~//<A c |jjDcgc]\}}t|fi||z}}}|j|Scc}}w)z Implements the SymPy trigsimp routine, for this quantity. trigsimp's documentation ======================== )r>r?tsimpr)roptsrDrEtrig_componentss rrzBasisDependent.trigsimpbsW$(??#8#8#:<1a!+d+a/<<t~~//r?r r)rsymbols assumptionsrDrEintegral_componentss r_eval_IntegralzBasisDependent._eval_Integralys`+/??+@+@+BD#'1a (CGC{CaGDDt~~233DA c&|tjfS)z Returns the expression as a tuple wrt the following transformation - expression -> a/b -> a, b rOner/s ras_numer_denomzBasisDependent.as_numer_denom~sQUU{r!c |jjDcgc]\}}t|g|i||z}}}|j|Scc}}w)z Implements the SymPy factor routine, on the scalar parts of a basis-dependent expression. factor's documentation ======================== )r>r?fctrr)rargsrHrDrEfctr_componentss rr zBasisDependent.factors\$(??#8#8#:<1a 3D3F3a7<<t~~//).0xrs r z.BasisDependent.as_coeff_add..sH1DOOA..Hs)tupler>)rdepss` r as_coeff_addzBasisDependent.as_coeff_adds%HHHHHr!c |D]}t|tstd|jj Dcgc]\}}t |g|i||z}}}|j |Scc}}w)z Implements the SymPy diff routine, for vectors. diff's documentation ======================== zInvalid arg for differentiation) isinstancerr6r>r?dfr)rrdrHrlrDrEdiff_componentss rr zBasisDependent.diffs CA!^, ABB C$(??#8#8#:<1aa1$1&1A5<<t~~//doitr)rhintsrldoit_componentss rrvzBasisDependent.doitsY%)OO5 34??1-22;U;a?55t~~//5s)A )NdFFNF)F)$__name__ __module__ __qualname____doc____annotations__rr rr%r#rNotImplementedr+r'r0r4r1r@rrArrGrrLrRrTrWr\rar rcrhrpr rsrvrQr!rrrs :&+'+9%+&+:&,',9%,&,(:&+')+(9%+&)+3(>*'+)'=)9*9  MMTZZ'''M A 0  $ 0  %'%4  0 NNdll"NI 0 LLBJJL0r!rc"eZdZdZfdZxZS)BasisDependentAddzt Denotes sum of basis dependent quantities such that they cannot be expressed as base or Mul instances. cli}|D]}t||jskt|tr|j|j}nAt|t r|j |j}ntt|dz||jk(r|jD]'}|j|d|j|z||<)t|j}|D]}||dk(s ||=t|dk(r |jS|Dcgc] }|||z }}t |@|g|i|}t|tr|j|jSddi} t#| |_||_t|jdj(|_|Scc}w)Nz cannot be interpreted correctlyr commutativeT)rr _expr_typerr*rdrrr6strrr>getlistkeyslensuper__new__r _assumptions _components_sys) clsrdrBr>argrltempnewargsobjrZ __class__s rrzBasisDependentAdd.__new__s  ICc3>>2c3''#--#((4CS)'#--#((4C#CH$F%GHHchh^^ I *q! 4s~~a7H H 1  I I JOO%& "A!}!qM " z?a 88O/991z!}$99goc7G7w7 c3  3==#((+ +$d+ $[1$*+Q/44 :sF1)r{r|r}r~r __classcell__rs@rrrs ''r!rc>eZdZdZdZdZefdZdZxZ S)BasisDependentMulzJ Denotes product of base- basis dependent quantity with a scalar. c*|j|i|}|Sr)_new)rrdrBrs rrzBasisDependentMul.__new__schh(( r!ct||Sr)type)rrds r _new_rawargszBasisDependentMul._new_rawargsstDz4  r!cddlm}m}m}m}d}t j }d} g} |D]} t| |jr|dz }d} !| t jk(rd} 7t| |j|jfr!|dz }| j} || jz}zt| |jr|dz }| } t| ||||fr| j| || z}|dkDr t!d|dk(r t#|i|S| r |j$St |jr8| j&D cgc]} |j|| }} |j|St)|T||| jg| i|}t|t,r|j|j&S| j|_ ||_ ddi}t/||_| j|i|_| jj4|_|Scc} w)Nr)CrossDotCurlGradientFTzInvalid multiplicationr) sympy.vectorrrrrrr`rr _zero_funcZero _base_funcr*_base_instance_measure_numberrappend ValueErrorrrrdrrrr rrr)rrdrBrrrrcountmeasure_numberzeroflag extra_argsrexprrlrrrZrs rrzBasisDependentMul._news;;  &C#s~~. C#..#--!@A ))#"5"55C/ C%dH!=>!!#&#%! &$ 1956 6 aZ(( ( 88O dCMM * II'}}^Q7'G' 3=='* *goc>"11)))!() c3  3==#((+ +!00,$d+ $[1..?&&++ #'s9Hc|j|j}d|vsd|vsd|vrd|zdz}|dz|j|jzS)N(-+)*)_printrr)rprinter measure_strs r _sympystrzBasisDependentMul._sympystr1s[nnT%9%9: ; #"4{" +c1KS 7>>$2E2E#FFFr!) r{r|r}r~rr classmethodrrrrs@rrrs-! 88tGr!rceZdZUdZiZded<ded<fdZdZedd Z e Z ed d Z ed d Z eddZ eddZdZdZdZxZS)rz: Class to denote a zero basis dependent instance. zdict['BaseVector', Expr]r>r _latex_formcpt||}tj|fj |_|Sr)rrrr__hash___hash)rrrs rrzBasisDependentZero.__new__@s0goc"VVSM**,  r!c|jSr)rr/s rrzBasisDependentZero.__hash__Gs zzr!__req__c.t||jSr)rrrrs r__eq__zBasisDependentZero.__eq__Js%11r!rcHt||jr|StdNz#Invalid argument types for additionrrrr6rs rr zBasisDependentZero.__add__P! eT__ -LAB Br!r cHt||jr|Stdrrrs rrzBasisDependentZero.__radd__Wrr!r#cJt||jr| StdNz&Invalid argument types for subtractionrrs rr%zBasisDependentZero.__sub__^s# eT__ -6MDE Er!r%cHt||jr|Stdrrrs rr#zBasisDependentZero.__rsub__es! eT__ -LDE Er!c|SrrQr/s rr0zBasisDependentZero.__neg__ls r!c|S)z@ Returns the normalized version of this vector. rQr/s r normalizezBasisDependentZero.normalizeos  r!cy)N0rQ)rrs rrzBasisDependentZero._sympystrusr!)r{r|r}r~r>rrrrrrr rr%r#r0rrrrs@rrr9s,.J(-9%2&2G:&C'C 9%C&C :&F'F 9%F&F  r!rN)" __future__rtypingrsympy.simplifyrrGrrLsympy.core.decoratorsrrsympy.core.assumptionsr sympy.core.functionr rssympy.integrals.integralsr sympy.polys.polytoolsr rc sympy.corerrrsympy.core.exprrsympy.vector.vectorrrrrrrQr!rrsi" >C,*.0"" .c0Tc0L--`OGOGd==r!