ó
    Š*£hƒ¥  ã                  ó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
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    " S S5      r! " S S\"5      r# " S S\$5      r%S r& " S S\5      r'SS jr(S r)S S jr*S r+S!S jr,S S jr-S r.g)"é    )Úannotations)ÚAny©Úwraps)ÚAddÚMulÚPowÚSÚsympifyÚFloat)ÚBasic)ÚExprÚUnevaluatedExpr)ÚLambda)Ú_keep_coeff)Údefault_sort_key)ÚSymbol)Úre)Ú
StrPrinter)Ú
precedenceÚ
PRECEDENCEc                  ó$   • \ rS rSrSrS rS rSrg)Úrequiresé   z9Decorator for registering requirements on print methods. c                ó   • Xl         g ©N©Ú_req)ÚselfÚkwargss     ÚW/home/mande/repo/quber/.venv/lib/python3.13/site-packages/sympy/printing/codeprinter.pyÚ__init__Úrequires.__init__   s   € Ø�	ó    c                ó6   ^ ^• UU 4S jn[        T5      " U5      $ )Nc                ó–   >• TR                   R                  5        H  u  p4[        X5      R                  U5        M!     T" U /UQ70 UD6$ r   )r   ÚitemsÚgetattrÚupdate)Úself_Úargsr    ÚkÚvÚmethodr   s        €€r!   Ú_method_wrapperÚ*requires.__call__.<locals>._method_wrapper   sB   ø€ ØŸ	™	Ÿ™Ö)‘�Ü˜Ó!×(Ñ(¨Ö+ñ *á˜%Ð1 $Ò1¨&Ñ1Ð1r$   r   )r   r.   r/   s   `` r!   Ú__call__Úrequires.__call__   s   ù€ ö	2ô �VŒ}˜_Ó-Ð-r$   r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r"   r1   Ú__static_attributes__© r$   r!   r   r      s   † ÙDòõ.r$   r   c                  ó   • \ rS rSrSrSrg)ÚAssignmentErroré   z9
Raised if an assignment variable for a loop is missing.
r9   N©r3   r4   r5   r6   r7   r8   r9   r$   r!   r;   r;      ó   † ñò 	r$   r;   c                  ó   • \ rS rSrSrSrg)ÚPrintMethodNotImplementedErroré%   z8
Raised if a _print_* method is missing in the Printer.
r9   Nr=   r9   r$   r!   r@   r@   %   r>   r$   r@   c                ó¢   • [        U [        5      (       a  SSKJn  U" S U  5       6 $ [        U [        5      (       a  [	        S U  5       5      $ U $ )Nr   )ÚListc              3  ó8   #   • U  H  n[        U5      v •  M     g 7fr   ©Ú_convert_python_lists©Ú.0Úes     r!   Ú	<genexpr>Ú(_convert_python_lists.<locals>.<genexpr>.   s   é € Ð<º°1Ô+¨A×.Ð.ºùó   ‚c              3  ó8   #   • U  H  n[        U5      v •  M     g 7fr   rE   rG   s     r!   rJ   rK   0   s   é € Ð;²s°!Ô*¨1×-Ð-²sùrL   )Ú
isinstanceÚlistÚsympy.codegen.abstract_nodesrC   Útuple)ÚargrC   s     r!   rF   rF   +   sF   € Ü�#”t×ÑÝ5ÙÑ<¹Ó<Ð=Ð=Ü	�Cœ×	Ñ	ÜÑ;±sÓ;Ó;Ð;àˆ
r$   c            	      ó:  ^ • \ rS rSr% SrSSSS.rSSS	S
SS	S	SS.rS\S'   0 SS/ 4_SS/ 4_SS/ 4_SS/ 4_SS/ 4_SS/ 4_SS/ 4_SS/ 4_SS/ 4_SS / 4_S!S / 4_S"S / 4_S#S$/ 4_S%S&/ 4_S'S&/ 4_S(S$/ 4_S)SS*/4_0 S+S,/ 4_S-S$/ 4_S.S$S*/4_S/S0/ 4_S1S$S*/4_S2S$S*/4_S3S$/ 4_S4S,/ 4_S5S*/ 4_S6S*/ 4_S7S*/ 4_S8S9/ 4_S:S9/ 4_S;S</ 4_S=S</ 4_S>S?/ 4_S@S?S$/4_ESAS*/ 40ErSnU 4SB jjr	SC r
SnSD jrSnSE jrSF rSG rSH rSI rSJ rSK rSL rSM rSN rSO rSP rSQ rSR rSS rST rSU rSV rSW rU 4SX jrSY r SZ r!\!r"S[ r#Sr$S\ r%S] r&S^ r'S_ r(S` r)Sa r*Sb r+Sc r,Sd r-Se r.Sf r/Sg r0Sh r1Si r2Sj r3Sk r4Sl r5\5r6\5r7\5r8\5r9\5r:\5r;\5r<\5r=\5r>\5r?\5r@\5rA\5rB\5rC\5rD\5rE\5rF\5rG\5rH\5rI\5rJ\5rKSmrLU =rM$ )oÚCodePrinteré5   z.
The base class for code-printing subclasses.
z&&z||Ú!)ÚandÚorÚnotNÚautoFÚ_T)ÚorderÚ	full_precÚerror_on_reservedÚreserved_word_suffixÚhumanÚinlineÚallow_unknown_functionsÚstrictzdict[str, Any]Ú_default_settingsÚcotÚtanÚcscÚsinÚsecÚcosÚacotÚatanÚacscÚasinÚasecÚacosÚcothÚexpÚcschÚsechÚacothÚlogÚacschÚasechÚcatalanÚgammaÚ	fibonacciÚsqrtÚlucasÚbetaÚsincÚ	PiecewiseÚModÚfloorÚ	factorialÚ
factorial2ÚsubfactorialÚ
uppergammaÚRisingFactorialÚFallingFactorialÚbinomialÚfracÚMaxÚMinÚ	HeavisideÚerf2ÚerfÚerfcÚLiÚliÚEiÚdirichlet_etaÚzetaÚ
riemann_xiÚSingularityFunctionc                óú   >• [         TU ]  US9  U R                  R                  SS5      S :X  a,  U R                  R                  SS5      S:H  U R                  S'   [	        U S5      (       d  [        5       U l        g g )N)Úsettingsrc   Tr`   Úreserved_words)Úsuperr"   Ú	_settingsÚgetÚhasattrÚsetrš   )r   r™   Ú	__class__s     €r!   r"   ÚCodePrinter.__init__t   sm   ø€ Ü‰Ñ (ÐÑ+Ø�>‰>×Ñ˜h¨Ó-°Ó5à'+§~¡~×'9Ñ'9¸'À4Ó'HÈDÑ'PˆD�N‰N˜8Ñ$Ü�tÐ-×.Ñ.Ü"%£%ˆDÕð /r$   c                ó0   • UR                  [        S 5      $ )Nc                ó‚   • [        U [        5      (       a   U R                  S   R                  (       a  U $ [	        U 5      $ )Nr   )rN   r   r+   Úis_realr   )rR   s    r!   Ú<lambda>Ú5CodePrinter._handle_UnevaluatedExpr.<locals>.<lambda>}   s<   € ´:Ø”÷4"ñ 4"Ø&)§h¡h¨q¡k×&9×&9ð -0ð -GÜ?AÀ#»wð-Gr$   )Úreplacer   ©r   Úexprs     r!   Ú_handle_UnevaluatedExprÚ#CodePrinter._handle_UnevaluatedExpr|   s   € Ø�|‰|œBñ !Gó Hð 	Hr$   c                ó@  ^ ^^^^• SSK Jm  SSKJmJm  UUUUU 4S jm[        U5      nT" X5      nT R                  U5      n[        5       T l        [        5       T l	        T R                  U5      R                  5       nT R                  S   (       Ga  / nT R                  (       a‹  UR                  T R                  SR                  T R                   5      5      5        [#        T R                  [$        S9 H6  nUR                  T R                  ['        U5      R(                  5      5        M8     [#        T R                  [$        S9 H%  u  pVUR                  T R+                  XV5      5        M'     XC-   nT R-                  U5      nSR/                  U5      nO`T R-                  U5      nT R                   VV	s1 s H  u  p‰UT R                  U	5      4iM     n
nn	U
T R                  SR/                  U5      4n[        5       T l        [        5       T l	        U$ s  sn	nf )	aL  
Print the expression as code.

Parameters
----------
expr : Expression
    The expression to be printed.

assign_to : Symbol, string, MatrixSymbol, list of strings or Symbols (optional)
    If provided, the printed code will set the expression to a variable or multiple variables
    with the name or names given in ``assign_to``.
r   ©ÚMatrixSymbol)Ú	CodeBlockÚ
Assignmentc           
     ór  >• Uc  [        U 5      $ [        U[        [        45      (       an  [	        U 5      [	        U5      :w  a-  [        SR                  [	        U 5      [	        U5      5      5      eT" [        X5       VVs/ s H  u  p#T" X#5      PM     snn6 $ [        U[        5      (       a1  U R                  (       a  T" U/U R                  Q76 nOX[        U5      nOL[        U[        5      (       d7  [        SR                  [        T5      R                  [        U5      5      5      eT" X5      $ s  snnf )Nz;Failed to assign an expression of length {} to {} variablesz%{} cannot assign to object of type {})r   rN   rO   rQ   ÚlenÚ
ValueErrorÚformatÚzipÚstrÚ	is_MatrixÚshaper   r   Ú	TypeErrorÚtyper3   )	r©   Ú	assign_toÚlhsÚrhsr°   r¯   r®   Ú_handle_assign_tor   s	       €€€€€r!   r¾   Ú.CodePrinter.doprint.<locals>._handle_assign_to�   s  ø€ ØÑ Ü˜t“}Ð$Ü˜)¤d¬E ]×3Ñ3Ü�t“9¤ I£Ó.Ü$Ð%b×%iÑ%iÔjmÐnrÓjsÔuxð  zCó  vDó  &Eó  Fð  FÙ ÌsÐSWÔOcÔ"dÒOcÁ8À3Ñ#4°SÖ#>ÑOcÒ"dÐeÐeÜ˜)¤S×)Ñ)Ø—>—>Ù ,¨YÐ D¸¿¹Ò D‘Iä & yÓ 1‘IÜ 	¬5×1Ñ1ÜÐ G× NÑ NÜ˜T›
×+Ñ+¬T°)«_ó!>ó ?ð ?á˜iÓ.Ð.ùó #es   Â D3
r`   zNot supported in {}:©ÚkeyÚ
)Ú"sympy.matrices.expressions.matexprr®   Úsympy.codegen.astr¯   r°   rF   rª   rŸ   Ú_not_supportedÚ_number_symbolsÚ_printÚ
splitlinesrœ   ÚappendÚ_get_commentr´   ÚlanguageÚsortedr¶   rº   r3   Ú_declare_number_constÚ_format_codeÚjoin)r   r©   r»   ÚlinesÚ
frontlinesÚnameÚvalueÚresultr,   r-   Únum_symsr°   r¯   r®   r¾   s   `          @@@@r!   ÚdoprintÚCodePrinter.doprint€   sÂ  ü€ õ 	Dß;÷	/ñ 	/ô" % TÓ*ˆÙ  Ó1ˆð ×+Ñ+¨DÓ1ˆô "›eˆÔÜ"›uˆÔà—‘˜DÓ!×,Ñ,Ó.ˆð �>‰>˜'×"Ð"ØˆJØ×"×"Ø×!Ñ! $×"3Ñ"3Ø.×5Ñ5°d·m±mÓDó#Fô Gä" 4×#6Ñ#6¼CÔ@�DØ×%Ñ% d×&7Ñ&7¼¸T»
×8KÑ8KÓ&LÖMñ Aä% d×&:Ñ&:ÄÔD‘�Ø×!Ñ! $×"<Ñ"<¸TÓ"IÖJñ  EàÑ&ˆEØ×%Ñ% eÓ,ˆEØ—Y‘Y˜uÓ%‰Fà×%Ñ% eÓ,ˆEØ8<×8LÒ8LÔMÒ8L±°˜˜DŸK™K¨›NÓ+Ñ8LˆHÑMØ × 3Ñ 3°T·Y±Y¸uÓ5EÐFˆFÜ!›eˆÔÜ"›uˆÔØˆùó	 Ns   Æ:Hc           	     óê  • U R                   R                  SS5      (       a   SSKJn  U R	                  X5      nU" U5      nO/ nS U40nU R                  U5      u  pgS U;   a!  [        R                  " U [        US    6 5      nO[        R                  " U S5      nU R                  U5      n	/ n
X‰:w  aN  U
R                  U5        Ub  U R                  U	< SU< 35      nU
R                  U5        U
R                  U5        U GHS  n[        U[        5      (       d  M  U R                  X±5      nU R                  U5      u  pÍX[    GH  nXå;   aO  X^    Vs/ s H  n[!        UR#                  5       5      PM     snX^    Vs/ s H  nS /PM     sn:X  d  [%        S5      eUc  ['        S5      eUR)                  U5      (       a  [+        S5      eU
R                  U5        U
R                  U5        U	< S[        R                  " XU-   5      < 3nU
R                  U R                  U5      5        U
R                  U5        U
R                  U5        GM     GMV     S	R-                  U
5      $ s  snf s  snf )
NÚcontractTr   )Úget_contraction_structureú = z0FIXME: no support for contractions in factor yetz"need assignment variable for loopszZFIXME: lhs present in rhs,                                this is undefined in CodePrinterrÂ   )rœ   r�   Úsympy.tensorrÚ   Ú_get_expression_indicesÚ_get_loop_opening_endingr   rÖ   r   rÇ   ÚextendÚ_get_statementrÉ   rN   rQ   Ú_sort_optimizedrO   ÚkeysÚNotImplementedErrorr;   Úhasr³   rÏ   )r   r©   r»   rÚ   ÚindicesÚdummiesÚopenloopÚ	closeloopÚtextÚlhs_printedrÐ   ÚdÚ
openloop_dÚcloseloop_dÚtermÚfs                   r!   Ú_doprint_loopsÚCodePrinter._doprint_loopsÃ   sN  € ð �>‰>×Ñ˜j¨$×/Ñ/Ý>à×2Ñ2°4ÓCˆGá/°Ó5‰GàˆGØ˜d˜W�oˆGØ"×;Ñ;¸GÓDÑˆð �7‹?Ü×%Ò% d¬C°¸±Ð,?Ó@‰Dô ×%Ò% d¨AÓ.ˆDð —k‘k )Ó,ˆØˆØÓØ�L‰L˜Ô"ØÑ$Ø×*Ñ*»ÂTÐ+JÓK�Ø�L‰L˜ÔØ�L‰L˜Ô#ô ˆAÜ˜!œU×#Ó#Ø×.Ñ.¨qÓ7�Ø*.×*GÑ*GØó+Ñ'�
ð $�J�DØ“ÈÊÓ0WÊÀA´°a·f±f³h¶ÉÑ0WØ07²Ó>²¨1 £±Ñ>ó1?ô
 2ØNóPð Pð %Ñ,Ü"1Ø Dó#Fð FàŸ8™8 I×.Ñ.Ü",ð .Bó #Cð Cð Ÿ™ XÔ.ØŸ™ ZÔ0Û,7¼×9KÒ9KØ ¨dÑ"2õ:4ð  5˜àŸ™ T×%8Ñ%8¸Ó%>Ô?ØŸ™ [Ô1ØŸ™ Y×/ôE 'ñ ðT �y‰y˜ÓÐùòG 1XùÚ>s   Å#I+Å?I0
c                óž   • SSK Jn  U" U5      u  pEU" U5      u  peU(       a	  U(       d  UnXF:w  a  [        SU-  5      eU R                  XB5      $ )Nr   )Úget_indicesz2lhs indices must match non-dummy rhs indices in %s)rÜ   ró   r³   rá   )r   r©   r»   ró   ÚrindsÚjunkÚlindss          r!   rÝ   Ú#CodePrinter._get_expression_indices  s[   € Ý,Ù! $Ó'‰ˆÙ! )Ó,‰ˆö žØˆEØ‹>Üð )Ø+/ñ0ó 1ð 1ð ×#Ñ# EÓ5Ð5r$   c                ó*  ^	• SSK Jn  U(       d  / $ 0 m	U H  nST	U'   M
     UR                  U5      nU H>  n[        UR                  5       H"  u  px T	U==   U R                  U5      -  ss'   M$     M@     [        UU	4S jS9$ ! [         a     ME  f = f)Nr   )ÚIndexedc                ó   >• TU    $ r   r9   )ÚxÚscore_tables    €r!   r¥   Ú-CodePrinter._sort_optimized.<locals>.<lambda>5  s	   ø€ ¨[¸ª^r$   rÀ   )Úsympy.tensor.indexedrù   ÚatomsÚ	enumeraterå   Ú_rate_index_positionÚKeyErrorrÌ   )
r   rå   r©   rù   ÚiÚarraysÚarrÚpÚindrü   s
            @r!   rá   ÚCodePrinter._sort_optimized   s›   ø€ å0æØˆIð ˆÛˆAØˆK˜‹Nñ ð —‘˜GÓ$ˆÛˆCÜ# C§K¡KÖ0‘�ðØ Ó$¨×(AÑ(AÀ!Ó(DÑDÕ$ó 1ñ ô �gÔ#;Ñ<Ð<øô  ó Úðús   ÁBÂ
BÂBc                ó   • [        S5      e)z˜function to calculate score based on position among indices

This method is used to sort loops in an optimized order, see
CodePrinter._sort_optimized()
ú=This function must be implemented by subclass of CodePrinter.©rã   )r   r  s     r!   r  Ú CodePrinter._rate_index_position7  s   € ô "ð #=ó >ð 	>r$   c                ó   • [        S5      e)z1Formats a codestring with the proper line ending.r
  r  )r   Ú
codestrings     r!   rà   ÚCodePrinter._get_statement@  ó   € ä!ð #=ó >ð 	>r$   c                ó   • [        S5      e)z#Formats a text string as a comment.r
  r  )r   ré   s     r!   rÊ   ÚCodePrinter._get_commentE  r  r$   c                ó   • [        S5      e)z3Declare a numeric constant at the top of a functionr
  r  )r   rÒ   rÓ   s      r!   rÍ   Ú!CodePrinter._declare_number_constJ  r  r$   c                ó   • [        S5      e)zvTake in a list of lines of code, and format them accordingly.

This may include indenting, wrapping long lines, etc...r
  r  )r   rÐ   s     r!   rÎ   ÚCodePrinter._format_codeO  s   € ô "ð #=ó >ð 	>r$   c                ó   • [        S5      e)zGReturns a tuple (open_lines, close_lines) containing lists
of codelinesr
  r  )r   rå   s     r!   rÞ   Ú$CodePrinter._get_loop_opening_endingV  s   € ô "ð #=ó >ð 	>r$   c                ó–   • UR                   R                  S5      (       a  SUR                   -   $ SUR                   UR                  4-  $ )NÚDummy_r[   z%s_%d)rÒ   Ú
startswithÚdummy_indexr¨   s     r!   Ú_print_DummyÚCodePrinter._print_Dummy\  s?   € Ø�9‰9×Ñ ×)Ñ)Ø˜Ÿ™‘?Ð"à˜dŸi™i¨×)9Ñ)9Ð:Ñ:Ð:r$   c                ó8   • U R                  UR                  5      $ r   )rÇ   Úlabelr¨   s     r!   Ú
_print_IdxÚCodePrinter._print_Idxb  s   € Ø�{‰{˜4Ÿ:™:Ó&Ð&r$   c                ó€   • SR                  UR                   Vs/ s H  o R                  U5      PM     sn5      $ s  snf )NrÂ   )rÏ   r+   rÇ   )r   r©   r  s      r!   Ú_print_CodeBlockÚCodePrinter._print_CodeBlocke  s-   € Ø�y‰y°$·)²)Ó<²)¨QŸ+™+ až.±)Ñ<Ó=Ð=ùÒ<s   š;c                ó   • [        U5      $ r   )r¶   ©r   Ústrings     r!   Ú_print_StringÚCodePrinter._print_Stringh  s   € Ü�6‹{Ðr$   c                ó    • SUR                   -  $ )Nz"%s")ré   ©r   rR   s     r!   Ú_print_QuotedStringÚCodePrinter._print_QuotedStringk  s   € Ø˜Ÿ™Ñ Ð r$   c                ó6   • U R                  [        U5      5      $ r   )rÊ   r¶   r'  s     r!   Ú_print_CommentÚCodePrinter._print_Commentn  s   € Ø× Ñ ¤ V£Ó-Ð-r$   c                óh  • SSK Jn  SSKJn  SSKJn  SSKJn  UR                  nUR                  n[        UR                  U5      (       a`  / n/ n	UR                   H-  u  p«UR                  U" Xj5      5        U	R                  U5        M/     U" [        X‰5      6 nU R                  U5      $ [        Xd5      (       a`  / nU R                  U5       H8  u  pïU" XnU4   X~U4   5      nU R                  U5      nUR                  U5        M:     SR!                  U5      $ U R"                  R%                  SS5      (       a=  UR'                  U5      (       d  UR'                  U5      (       a  U R)                  Xv5      $ U R                  U5      nU R                  U5      nU R+                  U< S	U< 35      $ )
Nr   )r°   )r€   r­   )ÚIndexedBaserÂ   rÙ   FrÛ   )rÄ   r°   Ú$sympy.functions.elementary.piecewiser€   rÃ   r®   rþ   r3  r¼   r½   rN   r+   rÉ   rµ   rÇ   Ú_traverse_matrix_indicesrÏ   rœ   r�   rä   rð   rà   )r   r©   r°   r€   r®   r3  r¼   r½   ÚexpressionsÚ
conditionsrI   ÚcÚtemprÐ   r  ÚjÚcode0Úlhs_codeÚrhs_codes                      r!   Ú_print_AssignmentÚCodePrinter._print_Assignmentq  ss  € Ý0ÝBÝCÝ4Ø�h‰hˆØ�h‰hˆä�d—h‘h 	×*Ñ*ð ˆKØˆJØŸ(œ(‘�Ø×"Ñ"¡:¨cÓ#5Ô6Ø×!Ñ! !Ö$ñ #ñ œc +Ó:Ð;ˆDØ—;‘;˜tÓ$Ð$Ü˜×*Ñ*ð ˆEØ×7Ñ7¸Ö<‘�Ù! #¨ d¡)¨S°A°©YÓ7�ØŸ™ DÓ)�Ø—‘˜UÖ#ñ =ð —9‘9˜UÓ#Ð#Ø�^‰^×Ñ 
¨E×2Ñ2¸¿¹À×8LÑ8LØ—‘˜×$Ñ$ð ×&Ñ& sÓ0Ð0à—{‘{ 3Ó'ˆHØ—{‘{ 3Ó'ˆHØ×&Ñ&³HºhÐ'GÓHÐHr$   c                óØ   ^ • T R                  UR                  5      nT R                  UR                  5      nT R                  SR                  " U 4S jX!R
                  U4 5       6 5      $ )Nz{} {} {}c              3  óF   >#   • U  H  nTR                  U5      v •  M     g 7fr   ©rÇ   ©rH   rR   r   s     €r!   rJ   Ú9CodePrinter._print_AugmentedAssignment.<locals>.<genexpr>š  s   øé € ÐHÒ*G 3ˆd�k‰k˜#×ÐÒ*Gùó   ƒ!)rÇ   r¼   r½   rà   r´   Úop)r   r©   r<  r=  s   `   r!   Ú_print_AugmentedAssignmentÚ&CodePrinter._print_AugmentedAssignment–  s[   ø€ Ø—;‘;˜tŸx™xÓ(ˆØ—;‘;˜tŸx™xÓ(ˆØ×"Ñ" :×#4Ò#4ÜH¨8·W±W¸hÑ*GÓHð$Jó Kð 	Kr$   c                ór   ^ • UR                   < SSR                  U 4S jUR                   5       5      < S3$ )NÚ(ú, c              3  óF   >#   • U  H  nTR                  U5      v •  M     g 7fr   rB  rC  s     €r!   rJ   Ú2CodePrinter._print_FunctionCall.<locals>.<genexpr>Ÿ  s   øé € ÐFÒ3E¨C�t—{‘{ 3×'Ð'Ò3EùrE  Ú))rÒ   rÏ   Úfunction_argsr¨   s   ` r!   Ú_print_FunctionCallÚCodePrinter._print_FunctionCallœ  s.   ø€ à�IŒIØ�I‰IÔF°4×3EÒ3EÓFÖGðIð 	Ir$   c                ó8   • U R                  UR                  5      $ r   )rÇ   Úsymbolr¨   s     r!   Ú_print_VariableÚCodePrinter._print_Variable¡  s   € Ø�{‰{˜4Ÿ;™;Ó'Ð'r$   c                óÆ   >• [         TU ]  U5      nX R                  ;   aA  U R                  S   (       a  Sn[	        UR                  U5      5      eX R                  S   -   $ U$ )Nr^   zVThis expression includes the symbol "{}" which is a reserved keyword in this language.r_   )r›   Ú_print_Symbolrš   rœ   r³   r´   )r   r©   rÒ   Úmsgr    s       €r!   rW  ÚCodePrinter._print_Symbol¤  s^   ø€ Ü‰wÑ$ TÓ*ˆà×&Ñ&Ó&Ø�~‰~Ð1×2ð<�ä  §¡¨DÓ!1Ó2Ð2ØŸ.™.Ð)?Ñ@Ñ@Ð@àˆKr$   c                ód   • XR                   ;   =(       d    [        U SR                  U5      S5      $ )z}Check if function ``name`` is either a known function or has its own
printing method. Used to check if rewriting is possible.z	_print_{}F)Úknown_functionsr(   r´   )r   rÒ   s     r!   Ú
_can_printÚCodePrinter._can_print°  s.   € ð ×+Ñ+Ñ+×]¬w°t¸[×=OÑ=OÐPTÓ=UÐW\Ó/]Ð]r$   c           	     ó6  ^ • UR                   R                  T R                  ;   a²  T R                  UR                   R                     n[        U[        5      (       a$  U< ST R                  UR                  S5      < S3$ U H  u  p4U" UR                  6 (       d  M    O   Wb1   U" UR                   Vs/ s H  nT R                  US5      PM     sn6 $ O÷[        US5      (       aG  [        UR                  [        5      (       a(  T R                  UR                  " UR                  6 5      $ UR                   R                  T R                  ;   a{  T R                  UR                   R                     u  pgT R                  U5      (       a@  [        U 4S jU 5       5      (       a&  ST R                  UR!                  U5      5      -   S-   $ UR"                  (       aq  T R$                  R'                  SS5      (       aP  T R                  UR                   5      < SSR)                  [+        T R                  UR                  5      5      < S3$ T R-                  U5      $ s  snf ! [         a'    U< ST R                  UR                  S5      < S3s $ f = f)	NrJ  rK  rN  r   Ú_imp_c              3  óF   >#   • U  H  nTR                  U5      v •  M     g 7fr   )r\  )rH   rï   r   s     €r!   rJ   Ú.CodePrinter._print_Function.<locals>.<genexpr>É  s   øé € Ð0YÊ[È°·±À×1CÐ1CÊ[ùrE  rb   F)Úfuncr3   r[  rN   r¶   Ú	stringifyr+   Úparenthesizer¹   rž   r_  r   rÇ   Ú_rewriteable_functionsr\  ÚallÚrewriteÚis_Functionrœ   r�   rÏ   ÚmapÚ_print_not_supported)r   r©   Ú	cond_funcÚcondrb  ÚitemÚtarget_fÚrequired_fss   `       r!   Ú_print_FunctionÚCodePrinter._print_Functionµ  sþ  ø€ Ø�9‰9×Ñ ×!5Ñ!5Ó5Ø×,Ñ,¨T¯Y©Y×-?Ñ-?Ñ@ˆIÜ˜)¤S×)Ñ)Û#,¨d¯n©n¸T¿Y¹YÈÖ.MÐNÐNã"+‘J�DÙ˜TŸY™Y×'Ð'Ùñ #,ð Ñ#ðRÙ#ÈTÏYÊYÓ%WÊYÀT d×&7Ñ&7¸¸aÖ&@ÉYÑ%WÐXÐXð $ô
 �T˜7×#Ñ#¬
°4·:±:¼v×(FÑ(Fà—;‘;˜tŸzšz¨4¯9©9Ð5Ó6Ð6Ø�Y‰Y×Ñ 4×#>Ñ#>Ó>à$(×$?Ñ$?ÀÇ	Á	×@RÑ@RÑ$SÑ!ˆHØ�‰˜x×(Ñ(¬SÔ0YÉ[Ó0Y×-YÑ-YØ˜TŸ[™[¨¯©°hÓ)?Ó@Ñ@À3ÑFÐFà×× §¡× 2Ñ 2Ð3LÈe× TÑ TØ#Ÿ{™{¨4¯9©9Ö5°t·y±yÄÀTÇ[Á[ÐRV×R[ÑR[ÓA\Ö7]Ð^Ð^à×,Ñ,¨TÓ2Ð2ùò &XøÜ$ó RÛ+/°·±ÀÇ	Á	È4Ö1PÐQÒQðRús$   Â'I' Â7I"ÃI' É"I' É'.JÊJc                ó6  • UR                   tp#UR                    H6  nUR                  (       a  M  [        SU R                  R                  -  5      e   SUR
                  R                  -  n[        XS 5      nUc^  U R                  R                  SS5      (       a,  [        S[        U 5       S[        U5       3SU 3-   S-   5      eU R                  U5      $ [        U5      nUR                    Vs/ s H  o‡U   PM	     n	nU" UR                   U	5      $ s  snf )	NzL%s._print_Derivative(...) only supports functions with symbols as arguments.z_print_Derivative_%src   FúUnsupported by ú: z
Printer has no method: úV
Set the printer option 'strict' to False in order to generate partially printed code.)r+   Ú	is_Symbolr³   r    r3   rb  r(   rœ   r�   r@   rº   rj  Údict)
r   r©   ÚobjÚwrt_order_pairsÚfunc_argÚ	meth_nameÚpmethÚordersrR   Ú
seq_orderss
             r!   Ú_print_DerivativeÚCodePrinter._print_DerivativeÓ  s  € Ø $§	¡	ÐˆØŸœˆHØ×%×%Ñ%Ü Ð!oØ!%§¡×!8Ñ!8ñ"9ó :ð :ñ !ð +¨S¯X©X×->Ñ->Ñ>ˆ	Ü˜¨Ó.ˆØ‰=Ø�~‰~×!Ñ! (¨E×2Ñ2Ü4Ø%¤d¨4£j \°´D¸³J°<Ð@Ø/°	¨{Ð;ñ<àmñnóð ð
 ×,Ñ,¨TÓ2Ð2Ü�oÓ&ˆØ-0¯XªXÓ6ªX c˜S”k©Xˆ
Ð6Ù�S—X‘X˜zÓ*Ð*ùò 7s   Ã3Dc           	     óJ  • U R                   R                  SS5      (       a6  U R                  [        UR	                  U R                   S   5      5      5      $ U R
                  R                  U[        UR	                  U R                   S   5      5      45        [        U5      $ )Nra   FÚ	precision)rœ   r�   rÇ   r   ÚevalfrÆ   Úaddr¶   r¨   s     r!   Ú_print_NumberSymbolÚCodePrinter._print_NumberSymbolê  s‚   € Ø�>‰>×Ñ˜h¨×.Ñ.Ø—;‘;œu T§Z¡Z°·±¸{Ñ0KÓ%LÓMÓNÐNð × Ñ ×$Ñ$ dÜ�d—j‘j §¡°Ñ!<Ó=Ó>ð&@ô Aä�t“9Ðr$   c                ó$   • U R                  U5      $ r   ©r…  r¨   s     r!   Ú_print_CatalanÚCodePrinter._print_Catalanô  ó   € Ø×'Ñ'¨Ó-Ð-r$   c                ó$   • U R                  U5      $ r   rˆ  r¨   s     r!   Ú_print_EulerGammaÚCodePrinter._print_EulerGammaö  r‹  r$   c                ó$   • U R                  U5      $ r   rˆ  r¨   s     r!   Ú_print_GoldenRatioÚCodePrinter._print_GoldenRatioø  r‹  r$   c                ó$   • U R                  U5      $ r   rˆ  r¨   s     r!   Ú_print_TribonacciConstantÚ%CodePrinter._print_TribonacciConstantú  r‹  r$   c                ó$   • U R                  U5      $ r   rˆ  r¨   s     r!   Ú_print_Exp1ÚCodePrinter._print_Exp1ü  r‹  r$   c                ó$   • U R                  U5      $ r   rˆ  r¨   s     r!   Ú	_print_PiÚCodePrinter._print_Piþ  r‹  r$   c                ó    ^ ^• [        U5      mST R                  S   -  R                  UU 4S j[        UR                  [
        S9 5       5      $ )Nú %s rW   c              3  óH   >#   • U  H  nTR                  UT5      v •  M     g 7fr   ©rd  ©rH   ÚaÚPRECr   s     €€r!   rJ   Ú)CodePrinter._print_And.<locals>.<genexpr>  s)   øé € ð 6BÚ@�Að 7;×6GÑ6GÈÈ4×6PÐ6PÚ@ùó   ƒ"rÀ   ©r   Ú
_operatorsrÏ   rÌ   r+   r   ©r   r©   r¡  s   ` @r!   Ú
_print_AndÚCodePrinter._print_And  sK   ù€ Ü˜$ÓˆØ˜Ÿ™¨Ñ/Ñ/×5Ñ5õ 6BÜ §	¡	Ô/?Ò@ó6Bó Bð 	Br$   c                ó    ^ ^• [        U5      mST R                  S   -  R                  UU 4S j[        UR                  [
        S9 5       5      $ )Nrœ  rX   c              3  óH   >#   • U  H  nTR                  UT5      v •  M     g 7fr   rž  rŸ  s     €€r!   rJ   Ú(CodePrinter._print_Or.<locals>.<genexpr>  s)   øé € ð 5BÚ@�Að 6:×5FÑ5FÀqÈ$×5OÐ5OÚ@ùr£  rÀ   r¤  r¦  s   ` @r!   Ú	_print_OrÚCodePrinter._print_Or  sK   ù€ Ü˜$ÓˆØ˜Ÿ™¨Ñ.Ñ.×4Ñ4õ 5BÜ §	¡	Ô/?Ò@ó5Bó Bð 	Br$   c                óþ   ^ ^• T R                   R                  S5      c  T R                  UR                  5       5      $ [	        U5      mST R                   S   -  R                  UU 4S jUR                   5       5      $ )NÚxorrœ  c              3  óH   >#   • U  H  nTR                  UT5      v •  M     g 7fr   rž  rŸ  s     €€r!   rJ   Ú)CodePrinter._print_Xor.<locals>.<genexpr>  s(   øé € ð 6$Ú"�Að 7;×6GÑ6GÈÈ4×6PÐ6PÚ"ùr£  ©r¥  r�   rÇ   Úto_nnfr   rÏ   r+   r¦  s   ` @r!   Ú
_print_XorÚCodePrinter._print_Xor  si   ù€ Ø�?‰?×Ñ˜uÓ%Ñ-Ø—;‘;˜tŸ{™{›}Ó-Ð-Ü˜$ÓˆØ˜Ÿ™¨Ñ/Ñ/×5Ñ5õ 6$ØŸšó6$ó $ð 	$r$   c                óþ   ^ ^• T R                   R                  S5      c  T R                  UR                  5       5      $ [	        U5      mST R                   S   -  R                  UU 4S jUR                   5       5      $ )NÚ
equivalentrœ  c              3  óH   >#   • U  H  nTR                  UT5      v •  M     g 7fr   rž  rŸ  s     €€r!   rJ   Ú0CodePrinter._print_Equivalent.<locals>.<genexpr>  s*   øé € ð =$Ú"�Að >B×=NÑ=NÈqÐRV×=WÐ=WÚ"ùr£  r²  r¦  s   ` @r!   Ú_print_EquivalentÚCodePrinter._print_Equivalent  si   ù€ Ø�?‰?×Ñ˜|Ó,Ñ4Ø—;‘;˜tŸ{™{›}Ó-Ð-Ü˜$ÓˆØ˜Ÿ™¨Ñ6Ñ6×<Ñ<õ =$ØŸšó=$ó $ð 	$r$   c                óv   • [        U5      nU R                  S   U R                  UR                  S   U5      -   $ )NrY   r   )r   r¥  rd  r+   r¦  s      r!   Ú
_print_NotÚCodePrinter._print_Not  s5   € Ü˜$ÓˆØ�‰˜uÑ%¨×(9Ñ(9¸$¿)¹)ÀA¹,ÈÓ(MÑMÐMr$   c                ó@   • U R                  UR                  5       5      $ r   )rÇ   r³  r¨   s     r!   Ú_print_BooleanFunctionÚ"CodePrinter._print_BooleanFunction  s   € Ø�{‰{˜4Ÿ;™;›=Ó)Ð)r$   c                ó:   • SU R                   " UR                  6 -  $ )Nz	isnan(%s)©rÇ   r+   r,  s     r!   Ú_print_isnanÚCodePrinter._print_isnan   ó   € Ø˜TŸ[š[¨#¯(©(Ð3Ñ3Ð3r$   c                ó:   • SU R                   " UR                  6 -  $ )Nz	isinf(%s)rÃ  r,  s     r!   Ú_print_isinfÚCodePrinter._print_isinf#  rÆ  r$   c           	     ó:  • [        U5      nUR                  5       u  p4US:  a  [        U* U5      nSnOSn/ n/ n/ nU R                  S;  a  UR	                  5       n	O[
        R                  " U5      n	U	 GH9  n
U
R                  (       Ga  U
R                  (       Ga   U
R                  R                  (       aå  U
R                  R                  (       aÊ  U
R                  S:w  a1  UR                  [        U
R                  U
R                  * SS95        MŸ  [        U
R                   S   R                   5      S:w  a0  [#        U
R                  [
        5      (       a  UR                  U
5        UR                  [        U
R                  U
R                  * 5      5        GM(  UR                  U
5        GM<     U=(       d    [$        R&                  /n[        U5      S:X  a1  US:X  a+  U R)                  US   S	[*        S
   [*        S   -   -  5      /nO U Vs/ s H  oÀR)                  XÂ5      PM     nnU Vs/ s H  oÀR)                  XÂ5      PM     nnU HP  n
U
R                  U;   d  M  SX×R-                  U
R                  5         -  X×R-                  U
R                  5      '   MR     U(       d  USR/                  U5      -   $ [        U5      S:X  a  USR/                  U5      -   S-   US   -   $ USR/                  U5      -   SSR/                  U5      -  -   $ s  snf s  snf )Nr   Ú-Ú )ÚoldÚnoneéÿÿÿÿF)Úevaluateé   g      à?r	   r   z(%s)Ú*Ú/z/(%s))r   Úas_coeff_Mulr   r\   Úas_ordered_factorsr   Ú	make_argsÚis_commutativeÚis_Powrr   Úis_RationalÚis_negativerÉ   r	   Úbaser²   r+   rN   r
   ÚOnerd  r   ÚindexrÏ   )r   r©   Úprecr8  rI   Úsignr   ÚbÚ	pow_parenr+   rm  Úa_strrû   Úb_strs                 r!   Ú
_print_MulÚCodePrinter._print_Mul&  sw  € ä˜$Óˆà× Ñ Ó"‰ˆØˆq‹5Ü ˜r 1Ó%ˆDØ‰DàˆDàˆØˆàˆ	à�:‰:˜_Ó,Ø×*Ñ*Ó,‰Dô —=’= Ó&ˆDô ˆDØ×"×"Ð" t§{§{ {°t·x±x×7K×7KÐPT×PXÑPX×Pd×PdØ—8‘8˜r“>Ø—H‘HœS §¡¨T¯X©X¨IÀÑFÖGä˜4Ÿ9™9 Q™<×,Ñ,Ó-°Ó2´zÀ$Ç)Á)ÌS×7QÑ7QØ!×(Ñ(¨Ô.Ø—H‘HœS §¡¨T¯X©X¨IÓ6×7à—‘˜—ñ ð �L”!—%‘%�ˆäˆq‹6�Q‹;˜4 3›;ð
 ×&Ñ& q¨¡t¨S´*¸UÑ2CÄJÈuÑDUÑ2UÑ-VÓWÐX‰Eá9:Ó;º°A×&Ñ& qÖ/¹ˆEÐ;Ù56Ó7²Q°×"Ñ" 1Ö+±QˆÐ7ó ˆDØ�y‰y˜A�~Ø,2°U¿7¹7À4Ç9Á9Ó;MÑ5NÑ,N�—g‘g˜dŸi™iÓ(Ó)ñ ö Ø˜#Ÿ(™( 5›/Ñ)Ð)Ü�‹V�q‹[Ø˜#Ÿ(™( 5›/Ñ)¨CÑ/°%¸±(Ñ:Ð:à˜#Ÿ(™( 5›/Ñ)¨G°c·h±h¸u³oÑ,EÑEÐEùò <ùÚ7s   ÈLÈ1Lc                ó
  • U R                   R                  SS5      (       a&  [        S[        U 5       S[        U5       3S-   5      e U R                  R                  U5        U R                  U5      $ ! [         a     Nf = f)Nrc   Frs  rt  ru  )rœ   r�   r@   rº   rÅ   r„  r¹   ÚemptyPrinterr¨   s     r!   rj  Ú CodePrinter._print_not_supported`  s‡   € Ø�>‰>×Ñ˜h¨×.Ñ.Ü0Ø!¤$ t£* ¨R´°T³
¨|Ð<Øiñjóð ð	Ø×Ñ×#Ñ# DÔ)ð × Ñ  Ó&Ð&øô ó 	áð	ús   Á	A5 Á5
BÂB)rÅ   rÆ   rš   r   )Nr3   r4   r5   r6   r7   r¥  rd   Ú__annotations__re  r"   rª   rÖ   rð   rÝ   rá   r  rà   rÊ   rÍ   rÎ   rÞ   r  r!  r$  r)  r-  r0  r>  rG  rP  rT  rW  r\  rp  Ú_print_Exprr  Ú_print_Heavisider…  r‰  r�  r�  r“  r–  r™  r§  r¬  r´  rº  r½  rÀ  rÄ  rÈ  rä  rj  Ú_print_BasicÚ_print_ComplexInfinityÚ_print_ExprCondPairÚ_print_GeometryEntityÚ_print_InfinityÚ_print_IntegralÚ_print_IntervalÚ_print_AccumulationBoundsÚ_print_LimitÚ_print_MatrixBaseÚ_print_DeferredVectorÚ
_print_NaNÚ_print_NegativeInfinityÚ_print_OrderÚ_print_RootOfÚ_print_RootsOfÚ_print_RootSumÚ_print_UniformÚ_print_UnitÚ_print_WildÚ_print_WildFunctionÚ_print_Relationalr8   Ú__classcell__)r    s   @r!   rT   rT   5   s  ø‡ ñð
 ØØñ€Jð ØØ"Ø #ØØØ#(Øñ	)Ð�~ó 	ð$Ø�E˜2�;ð$à�E˜2�;ð$ð �E˜2�;ð$ð �V˜R�Lð	$ð
 �V˜R�Lð$ð �V˜R�Lð$ð �U˜B�Kð$ð �U˜B�Kð$ð �U˜B�Kð$ð �e˜R�[ð$ð �e˜R�[ð$ð �e˜R�[ð$ð ˜ �}ð$ð ˜& "˜ð$ð �f˜b�\ð$ð  �W˜b�Mð!$ð" �U˜[˜MÐ*ñ#$ð$ �G˜R�=ð%$ð& ˜' 2˜ð'$ð( ˜7 [ MÐ2ð)$ð* ˜\¨2Ð.ð+$ð,  ¨+¨Ð7ð-$ð.  ¨;¨-Ð 8ð/$ð0 ˜ "˜ð1$ð2 �W˜b�Mð3$ð4 �K Ð$ð5$ð6 �K Ð$ð7$ð8 ˜+ rÐ*ð9$ð: �U˜B�Kð;$ð< �U˜B�Kð=$ð> �4˜�*ð?$ð@ �4˜�*ðA$ðB ˜f b˜\ðC$ðD ˜6 G 9Ð-ñE$ðF " K°Ð#4ñG$Ð÷L(òHôAôFM ò^6ò=ò.>ò>ò
>ò
>ò
>ò>ò;ò'ò>òò!ò.ò#IòJKòIò
(õ
ò^ò
3ð8 "€Kò+ð* Ðòò.ò.ò.ò.ò.ò.òBò
Bò
$ò$òNò*ò4ò4ò8Fòt'ð (€LØ1ÐØ.ÐØ0ÐØ*€OØ*€OØ*€OØ 4ÐØ'€LØ,ÐØ0ÐØ%€JØ2ÐØ'€LØ(€MØ)€NØ)€NØ)€NØ&€KØ&€KØ.ÐØ,Ör$   rT   Nc                ó\   • SSK Jn  XBR                  5          " U5      R                  X5      $ )aì  Converts an expr to a string of c code

Parameters
==========

expr : Expr
    A SymPy expression to be converted.
assign_to : optional
    When given, the argument is used as the name of the variable to which
    the expression is assigned. Can be a string, ``Symbol``,
    ``MatrixSymbol``, or ``Indexed`` type. This is helpful in case of
    line-wrapping, or for expressions that generate multi-line statements.
standard : str, optional
    String specifying the standard. If your compiler supports a more modern
    standard you may set this to 'c99' to allow the printer to use more math
    functions. [default='c89'].
precision : integer, optional
    The precision for numbers such as pi [default=17].
user_functions : dict, optional
    A dictionary where the keys are string representations of either
    ``FunctionClass`` or ``UndefinedFunction`` instances and the values
    are their desired C string representations. Alternatively, the
    dictionary value can be a list of tuples i.e. [(argument_test,
    cfunction_string)] or [(argument_test, cfunction_formater)]. See below
    for examples.
dereference : iterable, optional
    An iterable of symbols that should be dereferenced in the printed code
    expression. These would be values passed by address to the function.
    For example, if ``dereference=[a]``, the resulting code would print
    ``(*a)`` instead of ``a``.
human : bool, optional
    If True, the result is a single string that may contain some constant
    declarations for the number symbols. If False, the same information is
    returned in a tuple of (symbols_to_declare, not_supported_functions,
    code_text). [default=True].
contract: bool, optional
    If True, ``Indexed`` instances are assumed to obey tensor contraction
    rules and the corresponding nested loops over indices are generated.
    Setting contract=False will not generate loops, instead the user is
    responsible to provide values for the indices in the code.
    [default=True].

Examples
========

>>> from sympy import ccode, symbols, Rational, sin, ceiling, Abs, Function
>>> x, tau = symbols("x, tau")
>>> expr = (2*tau)**Rational(7, 2)
>>> ccode(expr)
'8*M_SQRT2*pow(tau, 7.0/2.0)'
>>> ccode(expr, math_macros={})
'8*sqrt(2)*pow(tau, 7.0/2.0)'
>>> ccode(sin(x), assign_to="s")
's = sin(x);'
>>> from sympy.codegen.ast import real, float80
>>> ccode(expr, type_aliases={real: float80})
'8*M_SQRT2l*powl(tau, 7.0L/2.0L)'

Simple custom printing can be defined for certain types by passing a
dictionary of {"type" : "function"} to the ``user_functions`` kwarg.
Alternatively, the dictionary value can be a list of tuples i.e.
[(argument_test, cfunction_string)].

>>> custom_functions = {
...   "ceiling": "CEIL",
...   "Abs": [(lambda x: not x.is_integer, "fabs"),
...           (lambda x: x.is_integer, "ABS")],
...   "func": "f"
... }
>>> func = Function('func')
>>> ccode(func(Abs(x) + ceiling(x)), standard='C89', user_functions=custom_functions)
'f(fabs(x) + CEIL(x))'

or if the C-function takes a subset of the original arguments:

>>> ccode(2**x + 3**x, standard='C99', user_functions={'Pow': [
...   (lambda b, e: b == 2, lambda b, e: 'exp2(%s)' % e),
...   (lambda b, e: b != 2, 'pow')]})
'exp2(x) + pow(3, x)'

``Piecewise`` expressions are converted into conditionals. If an
``assign_to`` variable is provided an if statement is created, otherwise
the ternary operator is used. Note that if the ``Piecewise`` lacks a
default term, represented by ``(expr, True)`` then an error will be thrown.
This is to prevent generating an expression that may not evaluate to
anything.

>>> from sympy import Piecewise
>>> expr = Piecewise((x + 1, x > 0), (x, True))
>>> print(ccode(expr, tau, standard='C89'))
if (x > 0) {
tau = x + 1;
}
else {
tau = x;
}

Support for loops is provided through ``Indexed`` types. With
``contract=True`` these expressions will be turned into loops, whereas
``contract=False`` will just print the assignment expression that should be
looped over:

>>> from sympy import Eq, IndexedBase, Idx
>>> len_y = 5
>>> y = IndexedBase('y', shape=(len_y,))
>>> t = IndexedBase('t', shape=(len_y,))
>>> Dy = IndexedBase('Dy', shape=(len_y-1,))
>>> i = Idx('i', len_y-1)
>>> e=Eq(Dy[i], (y[i+1]-y[i])/(t[i+1]-t[i]))
>>> ccode(e.rhs, assign_to=e.lhs, contract=False, standard='C89')
'Dy[i] = (y[i + 1] - y[i])/(t[i + 1] - t[i]);'

Matrices are also supported, but a ``MatrixSymbol`` of the same dimensions
must be provided to ``assign_to``. Note that any expression that can be
generated normally can also exist inside a Matrix:

>>> from sympy import Matrix, MatrixSymbol
>>> mat = Matrix([x**2, Piecewise((x + 1, x > 0), (x, True)), sin(x)])
>>> A = MatrixSymbol('A', 3, 1)
>>> print(ccode(mat, A, standard='C89'))
A[0] = pow(x, 2);
if (x > 0) {
   A[1] = x + 1;
}
else {
   A[1] = x;
}
A[2] = sin(x);
r   )Úc_code_printers)Úsympy.printing.cr  ÚlowerrÖ   )r©   r»   Ústandardr™   r  s        r!   Úccoder  Š  s(   € õD 1ØŸ>™>Ó+Ò,¨XÓ6×>Ñ>¸tÓOÐOr$   c                ó.   • [        [        U 40 UD65        g)z0Prints C representation of the given expression.N)Úprintr  ©r©   r™   s     r!   Úprint_ccoder    s   € ä	Œ%�Ñ
!˜Ñ
!Õ"r$   c                ó<   • SSK Jn  U" U5      R                  X5      $ )a³  Converts an expr to a string of fortran code

Parameters
==========

expr : Expr
    A SymPy expression to be converted.
assign_to : optional
    When given, the argument is used as the name of the variable to which
    the expression is assigned. Can be a string, ``Symbol``,
    ``MatrixSymbol``, or ``Indexed`` type. This is helpful in case of
    line-wrapping, or for expressions that generate multi-line statements.
precision : integer, optional
    DEPRECATED. Use type_mappings instead. The precision for numbers such
    as pi [default=17].
user_functions : dict, optional
    A dictionary where keys are ``FunctionClass`` instances and values are
    their string representations. Alternatively, the dictionary value can
    be a list of tuples i.e. [(argument_test, cfunction_string)]. See below
    for examples.
human : bool, optional
    If True, the result is a single string that may contain some constant
    declarations for the number symbols. If False, the same information is
    returned in a tuple of (symbols_to_declare, not_supported_functions,
    code_text). [default=True].
contract: bool, optional
    If True, ``Indexed`` instances are assumed to obey tensor contraction
    rules and the corresponding nested loops over indices are generated.
    Setting contract=False will not generate loops, instead the user is
    responsible to provide values for the indices in the code.
    [default=True].
source_format : optional
    The source format can be either 'fixed' or 'free'. [default='fixed']
standard : integer, optional
    The Fortran standard to be followed. This is specified as an integer.
    Acceptable standards are 66, 77, 90, 95, 2003, and 2008. Default is 77.
    Note that currently the only distinction internally is between
    standards before 95, and those 95 and after. This may change later as
    more features are added.
name_mangling : bool, optional
    If True, then the variables that would become identical in
    case-insensitive Fortran are mangled by appending different number
    of ``_`` at the end. If False, SymPy Will not interfere with naming of
    variables. [default=True]

Examples
========

>>> from sympy import fcode, symbols, Rational, sin, ceiling, floor
>>> x, tau = symbols("x, tau")
>>> fcode((2*tau)**Rational(7, 2))
'      8*sqrt(2.0d0)*tau**(7.0d0/2.0d0)'
>>> fcode(sin(x), assign_to="s")
'      s = sin(x)'

Custom printing can be defined for certain types by passing a dictionary of
"type" : "function" to the ``user_functions`` kwarg. Alternatively, the
dictionary value can be a list of tuples i.e. [(argument_test,
cfunction_string)].

>>> custom_functions = {
...   "ceiling": "CEIL",
...   "floor": [(lambda x: not x.is_integer, "FLOOR1"),
...             (lambda x: x.is_integer, "FLOOR2")]
... }
>>> fcode(floor(x) + ceiling(x), user_functions=custom_functions)
'      CEIL(x) + FLOOR1(x)'

``Piecewise`` expressions are converted into conditionals. If an
``assign_to`` variable is provided an if statement is created, otherwise
the ternary operator is used. Note that if the ``Piecewise`` lacks a
default term, represented by ``(expr, True)`` then an error will be thrown.
This is to prevent generating an expression that may not evaluate to
anything.

>>> from sympy import Piecewise
>>> expr = Piecewise((x + 1, x > 0), (x, True))
>>> print(fcode(expr, tau))
      if (x > 0) then
         tau = x + 1
      else
         tau = x
      end if

Support for loops is provided through ``Indexed`` types. With
``contract=True`` these expressions will be turned into loops, whereas
``contract=False`` will just print the assignment expression that should be
looped over:

>>> from sympy import Eq, IndexedBase, Idx
>>> len_y = 5
>>> y = IndexedBase('y', shape=(len_y,))
>>> t = IndexedBase('t', shape=(len_y,))
>>> Dy = IndexedBase('Dy', shape=(len_y-1,))
>>> i = Idx('i', len_y-1)
>>> e=Eq(Dy[i], (y[i+1]-y[i])/(t[i+1]-t[i]))
>>> fcode(e.rhs, assign_to=e.lhs, contract=False)
'      Dy(i) = (y(i + 1) - y(i))/(t(i + 1) - t(i))'

Matrices are also supported, but a ``MatrixSymbol`` of the same dimensions
must be provided to ``assign_to``. Note that any expression that can be
generated normally can also exist inside a Matrix:

>>> from sympy import Matrix, MatrixSymbol
>>> mat = Matrix([x**2, Piecewise((x + 1, x > 0), (x, True)), sin(x)])
>>> A = MatrixSymbol('A', 3, 1)
>>> print(fcode(mat, A))
      A(1, 1) = x**2
         if (x > 0) then
      A(2, 1) = x + 1
         else
      A(2, 1) = x
         end if
      A(3, 1) = sin(x)
r   )ÚFCodePrinter)Úsympy.printing.fortranr  rÖ   )r©   r»   r™   r  s       r!   Úfcoder    s   € õh 4Ù˜Ó!×)Ñ)¨$Ó:Ð:r$   c                ó.   • [        [        U 40 UD65        g)zqPrints the Fortran representation of the given expression.

See fcode for the meaning of the optional arguments.
N)r
  r  r  s     r!   Úprint_fcoder  ‹  s   € ô
 
Œ%�Ñ
!˜Ñ
!Õ"r$   c                ó\   • SSK Jn  XBR                  5          " U5      R                  X5      $ )z#C++ equivalent of :func:`~.ccode`. r   )Úcxx_code_printers)Úsympy.printing.cxxr  r  rÖ   )r©   r»   r  r™   r  s        r!   Úcxxcoder  ’  s%   € å4ØŸ^™^Ó-Ò.¨xÓ8×@Ñ@ÀÓQÐQr$   c                óô   • SSK Jn  U" U5      nUR                  U 5      n [        U [        5      (       a4  UR
                  R                  5        H  u  pVU R                  XV5      n M     UR                  X5      $ )a  Converts an expr to a string of Rust code

Parameters
==========

expr : Expr
    A SymPy expression to be converted.
assign_to : optional
    When given, the argument is used as the name of the variable to which
    the expression is assigned. Can be a string, ``Symbol``,
    ``MatrixSymbol``, or ``Indexed`` type. This is helpful in case of
    line-wrapping, or for expressions that generate multi-line statements.
precision : integer, optional
    The precision for numbers such as pi [default=15].
user_functions : dict, optional
    A dictionary where the keys are string representations of either
    ``FunctionClass`` or ``UndefinedFunction`` instances and the values
    are their desired C string representations. Alternatively, the
    dictionary value can be a list of tuples i.e. [(argument_test,
    cfunction_string)].  See below for examples.
dereference : iterable, optional
    An iterable of symbols that should be dereferenced in the printed code
    expression. These would be values passed by address to the function.
    For example, if ``dereference=[a]``, the resulting code would print
    ``(*a)`` instead of ``a``.
human : bool, optional
    If True, the result is a single string that may contain some constant
    declarations for the number symbols. If False, the same information is
    returned in a tuple of (symbols_to_declare, not_supported_functions,
    code_text). [default=True].
contract: bool, optional
    If True, ``Indexed`` instances are assumed to obey tensor contraction
    rules and the corresponding nested loops over indices are generated.
    Setting contract=False will not generate loops, instead the user is
    responsible to provide values for the indices in the code.
    [default=True].

Examples
========

>>> from sympy import rust_code, symbols, Rational, sin, ceiling, Abs, Function
>>> x, tau = symbols("x, tau")
>>> rust_code((2*tau)**Rational(7, 2))
'8.0*1.4142135623731*tau.powf(7_f64/2.0)'
>>> rust_code(sin(x), assign_to="s")
's = x.sin();'

Simple custom printing can be defined for certain types by passing a
dictionary of {"type" : "function"} to the ``user_functions`` kwarg.
Alternatively, the dictionary value can be a list of tuples i.e.
[(argument_test, cfunction_string)].

>>> custom_functions = {
...   "ceiling": "CEIL",
...   "Abs": [(lambda x: not x.is_integer, "fabs", 4),
...           (lambda x: x.is_integer, "ABS", 4)],
...   "func": "f"
... }
>>> func = Function('func')
>>> rust_code(func(Abs(x) + ceiling(x)), user_functions=custom_functions)
'(fabs(x) + x.ceil()).f()'

``Piecewise`` expressions are converted into conditionals. If an
``assign_to`` variable is provided an if statement is created, otherwise
the ternary operator is used. Note that if the ``Piecewise`` lacks a
default term, represented by ``(expr, True)`` then an error will be thrown.
This is to prevent generating an expression that may not evaluate to
anything.

>>> from sympy import Piecewise
>>> expr = Piecewise((x + 1, x > 0), (x, True))
>>> print(rust_code(expr, tau))
tau = if (x > 0.0) {
    x + 1
} else {
    x
};

Support for loops is provided through ``Indexed`` types. With
``contract=True`` these expressions will be turned into loops, whereas
``contract=False`` will just print the assignment expression that should be
looped over:

>>> from sympy import Eq, IndexedBase, Idx
>>> len_y = 5
>>> y = IndexedBase('y', shape=(len_y,))
>>> t = IndexedBase('t', shape=(len_y,))
>>> Dy = IndexedBase('Dy', shape=(len_y-1,))
>>> i = Idx('i', len_y-1)
>>> e=Eq(Dy[i], (y[i+1]-y[i])/(t[i+1]-t[i]))
>>> rust_code(e.rhs, assign_to=e.lhs, contract=False)
'Dy[i] = (y[i + 1] - y[i])/(t[i + 1] - t[i]);'

Matrices are also supported, but a ``MatrixSymbol`` of the same dimensions
must be provided to ``assign_to``. Note that any expression that can be
generated normally can also exist inside a Matrix:

>>> from sympy import Matrix, MatrixSymbol
>>> mat = Matrix([x**2, Piecewise((x + 1, x > 0), (x, True)), sin(x)])
>>> A = MatrixSymbol('A', 3, 1)
>>> print(rust_code(mat, A))
A = [x.powi(2), if (x > 0.0) {
    x + 1
} else {
    x
}, x.sin()];
r   )ÚRustCodePrinter)	Úsympy.printing.rustr  Ú_rewrite_known_functionsrN   r   Úfunction_overridesÚvaluesr§   rÖ   )r©   r»   r™   r  ÚprinterÚsrc_funcÚdst_funcs          r!   Ú	rust_coder   ˜  si   € õX 4Ù˜hÓ'€GØ×+Ñ+¨DÓ1€DÜ�$œ×ÑØ")×"<Ñ"<×"CÑ"CÖ"EÑˆHØ—<‘< Ó3ŠDñ #Fà�?‰?˜4Ó+Ð+r$   c                ó.   • [        [        U 40 UD65        g)z3Prints Rust representation of the given expression.N)r
  r   r  s     r!   Úprint_rust_coder"    s   € ä	Œ)�DÑ
%˜HÑ
%Õ&r$   )NÚc99r   )Nzc++11)/Ú
__future__r   Útypingr   Ú	functoolsr   Ú
sympy.corer   r   r	   r
   r   r   Úsympy.core.basicr   Úsympy.core.exprr   r   Úsympy.core.functionr   Úsympy.core.mulr   Úsympy.core.sortingr   Úsympy.core.symbolr   Ú$sympy.functions.elementary.complexesr   Úsympy.printing.strr   Úsympy.printing.precedencer   r   r   Ú	Exceptionr;   rã   r@   rF   rT   r  r  r  r  r  r   r"  r9   r$   r!   Ú<module>r2     s‘   ðÝ "Ý å ç 7× 7Ý "ß 1Ý &Ý &Ý /Ý $Ý 3Ý )ß <÷
.ñ 
.ô	�iô 	ô	Ð%8ô 	òôN	-�*ô N	-ôjCPòJ#ôu;òp#ôRôr,ój'r$   