
    ΅ic                     ~    S SK r S SKrS SKJrJr  S SKJr  SrSrSr	 " S S\5      r
 " S	 S
\
5      r " S S\
5      rg)    N)
PRECEDENCE
precedence)
StrPrinterint64_tl             c                      \ rS rSrSrS\R                  S\4S jrS\R                  S\4S jr	S!S\R                  S\S-  S\4S	 jjr
S\R                  S\4S
 jrS\R                  S\4S jrS\R                  S\4S jrS\R                  S\4S jrS\R                  S\4S jrS\R                  S\4S jrS\R                  S\4S jrS\R                  S\4S jrS\R                  S\4S jrS\R                  S\4S jrS\R                  S\4S jrS\R                  S\4S jrS\R                  S\4S jrS\R                  S\4S jrS\R                  S\4S jrS\R                  S\4S jrS\R                  S\4S jrS\R                  S\4S jrS\R                  S\4S jrS\R                  S\4S jrS\R                  S\4S jrS\R                  S\4S jr S r!g)"ExprPrinter   _torch_sympystrexprreturnc                 N    U R                  UR                  S[        U5      5      $ )N*	stringifyargsr   selfr   s     U/home/james-whalen/.local/lib/python3.13/site-packages/torch/utils/_sympy/printers.py
_print_MulExprPrinter._print_Mul   s    ~~diij.>??    c                 F    SU R                  UR                  S   5       S3$ )Nznot (r   )_printr   r   s     r   
_print_NotExprPrinter._print_Not   s#    t{{499Q<0133r   Norderc                 N    U R                  UR                  S[        U5      5      $ )Nz + r   )r   r   r   s      r   
_print_AddExprPrinter._print_Add   s    ~~dii
40@AAr   c                 j    U R                  UR                  SUR                   S3[        U5      5      $ )N )r   r   rel_opr   r   s     r   _print_RelationalExprPrinter._print_Relational   s+    ~~dii1T[[M);Z=MNNr   c                 J    U R                  UR                  S[        S   5      $ )Nz & 
BitwiseAndr   r   r   r   s     r   _print_BitwiseFn_bitwise_and(ExprPrinter._print_BitwiseFn_bitwise_and       ~~dii
<0HIIr   c                 J    U R                  UR                  S[        S   5      $ )Nz | 	BitwiseOrr*   r   s     r   _print_BitwiseFn_bitwise_or'ExprPrinter._print_BitwiseFn_bitwise_or"   s    ~~dii
;0GHHr   c                 J    U R                  UR                  S[        S   5      $ )Nz ^ 
BitwiseXorr*   r   s     r   _print_BitwiseFn_bitwise_xor(ExprPrinter._print_BitwiseFn_bitwise_xor%   r-   r   c                 P    U R                  UR                  S[        S   S-
  5      $ N % Atom      ?r*   r   s     r   
_print_ModExprPrinter._print_Mod*   #    ~~dii
60BS0HIIr   c                 \    U R                  UR                  S[        S   S-
  5      nSU S3$ )N / r9   r:   (r   r*   )r   r   ss      r   _print_FloatTrueDivExprPrinter._print_FloatTrueDiv-   s/    NN499eZ-?#-EF1#Qxr   c                 $    U R                  U5      $ N)_print_FloorDivr   s     r   _print_CleanDivExprPrinter._print_CleanDiv1   s    ##D))r   c                 >    U R                  UR                  S   5      $ Nr   r   r   s     r   _print_IdentityExprPrinter._print_Identity4   s    {{499Q<((r   c                 t    UR                   S:X  a  [        [        R                  " USS95      $ [        U5      $ )N5      )dps)_precstrsympyFloatr   s     r   _print_FloatExprPrinter._print_Float7   s2    :: u{{4R011 t9r   c                     UR                   u  p#U[        U5      :w  a  [        U5      e[        U5      nUS:  a  [        SU 35      eUS:  a  U R                  U/U-  S[        S   5      $ g)Nr   z#exponent must be non-negative, got r   Mul1)r   intAssertionErrorr   r   r   r   baseexps       r   
_print_PowExprPrinter._print_PowH   sn    II	#c(? %%#h7 #Fse!LMM7>>4&3,Z5FGGr   c                 0    [        S[        U 5       35      e)Nz#_print_ToFloat not implemented for NotImplementedErrortyper   s     r   _print_ToFloatExprPrinter._print_ToFloatX   s    !$GT
|"TUUr   c                 0    [        S[        U 5       35      e)Nz$_print_Infinity not implemented for rb   r   s     r   _print_InfinityExprPrinter._print_Infinity[       !$Hd"UVVr   c                 0    [        S[        U 5       35      e)Nz,_print_NegativeInfinity not implemented for rb   r   s     r   _print_NegativeInfinity#ExprPrinter._print_NegativeInfinity^   s    !:4:,G
 	
r   c                 0    [        S[        U 5       35      e)Nz$_print_FloorDiv not implemented for rb   r   s     r   rF   ExprPrinter._print_FloorDivc   rj   r   c                 0    [        S[        U 5       35      e)Nz%_print_PythonMod not implemented for rb   r   s     r   _print_PythonModExprPrinter._print_PythonModf   s    !$I$t*"VWWr   c                 0    [        S[        U 5       35      e)Nz&_print_IntTrueDiv not implemented for rb   r   s     r   _print_IntTrueDivExprPrinter._print_IntTrueDivi       !$J4PT:,"WXXr   c                 0    [        S[        U 5       35      e)N(_print_PowByNatural not implemented for rb   r   s     r   _print_PowByNaturalExprPrinter._print_PowByNaturall       !6tDzlC
 	
r   c                 0    [        S[        U 5       35      e)Nz$_print_FloatPow not implemented for rb   r   s     r   _print_FloatPowExprPrinter._print_FloatPowq   rj   r   c                 0    [        S[        U 5       35      e)Nz&_print_TruncToInt not implemented for rb   r   s     r   _print_TruncToIntExprPrinter._print_TruncToIntt   rv   r   c                 0    [        S[        U 5       35      e)Nz&_print_RoundToInt not implemented for rb   r   s     r   _print_RoundToIntExprPrinter._print_RoundToIntw   rv   r   c                 0    [        S[        U 5       35      e)Nz(_print_RoundDecimal not implemented for rb   r   s     r   _print_RoundDecimalExprPrinter._print_RoundDecimalz   r{   r   c                 0    [        S[        U 5       35      e)Nz(_print_TruncToFloat not implemented for rb   r   s     r   _print_TruncToFloatExprPrinter._print_TruncToFloat   r{   r    rE   )"__name__
__module____qualname____firstlineno__printmethodrS   ExprrR   r   r   r!   r&   r+   r0   r4   r;   rB   rG   rK   rU   r_   re   rh   rl   rF   rq   rt   ry   r}   r   r   r   r   __static_attributes__r   r   r   r	   r	      s   #K@uzz @c @4uzz 4c 4Buzz B#* B BOejj OS OJ J JI

 Is IJ J J
Juzz Jc J

 s *EJJ *3 *)EJJ )3 )  "	uzz 	c 	 V5:: V# VWEJJ W3 W
EJJ 
3 

WEJJ W3 WXUZZ XC XYejj YS Y


 
s 

WEJJ W3 WYejj YS YYejj YS Y


 
s 



 
s 
r   r	   c                       \ rS rSrS\R
                  S\4S jrS\R
                  S\4S jrS\R
                  S\4S jr	S\R
                  S\4S jr
S\R
                  S\4S jrS\R
                  S\4S	 jrS\R
                  S\4S
 jrS\R
                  S\4S jrS\R
                  S\4S jrS\R
                  S\4S jrS\R
                  S\4S jrS\R
                  S\4S jrS\R
                  S\4S jrS\R
                  S\4S jrS\R
                  S\4S jrS\R
                  S\4S jrS\R
                  S\4S jrS\R
                  S\4S jrS\R
                  S\4S jrS\R
                  S\4S jrS\R
                  S\4S jrS\R
                  S\4S jrS\R
                  S\4S jrS\R
                  S\4S jrS\R
                  S\4S jrS\R
                  S\4S jr S\R
                  S\4S jr!S\R
                  S\4S jr"S\R
                  S\4S  jr#S\R
                  S\4S! jr$S\R
                  S\4S" jr%S\R
                  S\4S# jr&S\R
                  S\4S$ jr'S\R
                  S\4S% jr(S&r)g')(PythonPrinter   r   r   c                     [        UR                  5      S:w  a  [        S5      eSU R                  UR                  S   5       S3$ )N   $ToFloat expects exactly one argumentztorch.sym_float(r   r   lenr   r[   r   r   s     r   re   PythonPrinter._print_ToFloat   sA    tyy>Q !GHH "$++diil";!<A>>r   c                 N    U R                  UR                  S[        U5      5      $ )Nz and r   r   s     r   
_print_AndPythonPrinter._print_And   s    ~~dii*T2BCCr   c                 N    U R                  UR                  S[        U5      5      $ )Nz or r   r   s     r   	_print_OrPythonPrinter._print_Or   s    ~~diiD1ABBr   c                 f   ^  U 4S jUR                    5       u  p#nUS:w  a	  SU SU S3nSU SU S3$ )Nc              3   \   >#    U  H!  nTR                  U[        S    S-
  5      v   M#     g7fr9   r:   Nparenthesizer   .0argr   s     r   	<genexpr>7PythonPrinter._print_ModularIndexing.<locals>.<genexpr>   s.      
HQDc:f#5#;<<	   ),rY   r@    // r   r8   r   r   r   xdivmods   `    r   _print_ModularIndexing$PythonPrinter._print_ModularIndexing   sL    
HL		
 #:A3d3%q!A1#SQr   c                     g)Nzmath.infr   r   s     r   rh   PythonPrinter._print_Infinity   s    r   c                     g)Nz	-math.infr   r   s     r   rl   %PythonPrinter._print_NegativeInfinity   s    r   c                 P    U R                  UR                  S[        S   S-
  5      $ r7   r*   r   s     r   rq   PythonPrinter._print_PythonMod   r=   r   c                 B   ^  U 4S jUR                    5       u  p#U SU 3$ )Nc              3   \   >#    U  H!  nTR                  U[        S    S-
  5      v   M#     g7fr   r   r   s     r   r   0PythonPrinter._print_FloorDiv.<locals>.<genexpr>   s+     Xis$##CF);c)ABBir   r   r   r   r   r   r   s   `   r   rF   PythonPrinter._print_FloorDiv   s#    XdiiXDr   c                 P    U R                  UR                  S[        S   S-
  5      $ )Nr?   r9   r:   r*   r   s     r   rt   PythonPrinter._print_IntTrueDiv   r=   r   c                 ,    SU R                  U5       S3$ )Nz
math.sqrt(r   )r   r   s     r   _helper_sqrtPythonPrinter._helper_sqrt   s    DKK-.a00r   c                 >    U R                  UR                  S   5      $ rJ   )r   r   r   s     r   _print_OpaqueUnaryFn_sqrt'PythonPrinter._print_OpaqueUnaryFn_sqrt   s      1..r   c                 J    U R                  UR                  S[        S   5      $ Nz ** Powr*   r   s     r   r}   PythonPrinter._print_FloatPow       ~~diiE1BCCr   c                 J    U R                  UR                  S[        S   5      $ r   r*   r   s     r   ry   !PythonPrinter._print_PowByNatural   r   r   c                     [        UR                  5      S:w  a  [        S5      eSU R                  UR                  S   5       S3$ )Nr   "floor expects exactly one argumentmath.floor(r   r   r   r   s     r   _print_floorPythonPrinter._print_floor   s?    tyy>Q !EFFT[[167q99r   c                     [        UR                  5      S:w  a  [        S5      eSU R                  UR                  S   5       S3$ )Nr   'FloorToInt expects exactly one argumentr   r   r   r   r   s     r   _print_FloorToIntPythonPrinter._print_FloorToInt   s?    tyy>Q !JKKT[[167q99r   c                     [        UR                  5      S:w  a  [        S5      eSU R                  UR                  S   5       S3$ )Nr   'TruncToInt expects exactly one argumentzmath.trunc(r   r   r   r   s     r   r   PythonPrinter._print_TruncToInt   ?    tyy>Q !JKKT[[167q99r   c                     [        UR                  5      S:w  a  [        S5      eSU R                  UR                  S   5       S3$ )Nr   $ceiling expects exactly one argument
math.ceil(r   r   r   r   s     r   _print_ceilingPythonPrinter._print_ceiling   s?    tyy>Q !GHHDKK		!56a88r   c                     [        UR                  5      S:w  a  [        S5      eSU R                  UR                  S   5       S3$ )Nr   &CeilToInt expects exactly one argumentr   r   r   r   r   s     r   _print_CeilToIntPythonPrinter._print_CeilToInt   s?    tyy>Q !IJJDKK		!56a88r   c                     [        UR                  5      S:w  a  [        S5      eSU R                  UR                  S   5       S3$ )Nr    Abs expects exactly one argumentzabs(r   r   r   r   s     r   
_print_AbsPythonPrinter._print_Abs   s?    tyy>Q !CDDdkk$))A,/022r   c                     [        UR                  5      S:  a  [        S5      eSSR                  [	        U R
                  UR                  5      5       S3$ )N   z"Max expects at least two argumentszmax(, r   r   r   r[   joinmapr   r   s     r   
_print_MaxPythonPrinter._print_Max   F    tyy>A !EFFdiiDKK ;<=Q??r   c                     [        UR                  5      S:  a  [        S5      eSSR                  [	        U R
                  UR                  5      5       S3$ )Nr   z"Min expects at least two argumentszmin(r   r   r   r   s     r   
_print_MinPythonPrinter._print_Min   r   r   c                     [        UR                  5      S:w  a  [        S5      eSU R                  UR                  S   5       S3$ )Nr    cos expects exactly one argumentz	math.cos(r   r   r   r   s     r   _print_OpaqueUnaryFn_cos&PythonPrinter._print_OpaqueUnaryFn_cos   ?    tyy>Q !CDD4;;tyy|45Q77r   c                     [        UR                  5      S:w  a  [        S5      eSU R                  UR                  S   5       S3$ )Nr   !cosh expects exactly one argumentz
math.cosh(r   r   r   r   s     r   _print_OpaqueUnaryFn_cosh'PythonPrinter._print_OpaqueUnaryFn_cosh   ?    tyy>Q !DEEDKK		!56a88r   c                     [        UR                  5      S:w  a  [        S5      eSU R                  UR                  S   5       S3$ )Nr   !acos expects exactly one argumentz
math.acos(r   r   r   r   s     r   _print_OpaqueUnaryFn_acos'PythonPrinter._print_OpaqueUnaryFn_acos  r   r   c                     [        UR                  5      S:w  a  [        S5      eSU R                  UR                  S   5       S3$ Nr   z sin expects exactly one argumentz	math.sin(r   r   r   r   s     r   _print_OpaqueUnaryFn_sin&PythonPrinter._print_OpaqueUnaryFn_sin  r   r   c                     [        UR                  5      S:w  a  [        S5      eSU R                  UR                  S   5       S3$ )Nr   !sinh expects exactly one argumentz
math.sinh(r   r   r   r   s     r   _print_OpaqueUnaryFn_sinh'PythonPrinter._print_OpaqueUnaryFn_sinh  r   r   c                     [        UR                  5      S:w  a  [        S5      eSU R                  UR                  S   5       S3$ )Nr   !asin expects exactly one argumentz
math.asin(r   r   r   r   s     r   _print_OpaqueUnaryFn_asin'PythonPrinter._print_OpaqueUnaryFn_asin  r   r   c                     [        UR                  5      S:w  a  [        S5      eSU R                  UR                  S   5       S3$ )Nr    tan expects exactly one argumentz	math.tan(r   r   r   r   s     r   _print_OpaqueUnaryFn_tan&PythonPrinter._print_OpaqueUnaryFn_tan  r   r   c                     [        UR                  5      S:w  a  [        S5      eSU R                  UR                  S   5       S3$ )Nr   !tanh expects exactly one argumentz
math.tanh(r   r   r   r   s     r   _print_OpaqueUnaryFn_tanh'PythonPrinter._print_OpaqueUnaryFn_tanh  r   r   c                     [        UR                  5      S:w  a  [        S5      eSU R                  UR                  S   5       S3$ )Nr   !atan expects exactly one argumentz
math.atan(r   r   r   r   s     r   _print_OpaqueUnaryFn_atan'PythonPrinter._print_OpaqueUnaryFn_atan   r   r   c                     [        UR                  5      S:w  a  [        S5      eSU R                  UR                  S   5       S3$ )Nr   z!log2 expects exactly one argumentz
math.log2(r   r   r   r   s     r   _print_OpaqueUnaryFn_log2'PythonPrinter._print_OpaqueUnaryFn_log2%  r   r   c                     [        UR                  5      S:w  a  [        S5      eSU R                  UR                  S   5       S3$ )Nr   'RoundToInt expects exactly one argumentround(r   r   r   r   s     r   r   PythonPrinter._print_RoundToInt*  s?    tyy>Q !JKKDIIaL12!44r   c                     [        UR                  5      S:w  a  [        S5      eUR                  u  p#[        U[        R
                  5      (       d  [        S5      eSU R                  U5       SU S3$ )Nr   *RoundDecimal expects exactly two argumentsz,ndigits must be an instance of sympy.Integerr   r   r   )r   r   r[   
isinstancerS   Integer	TypeErrorr   )r   r   numberndigitss       r   r   !PythonPrinter._print_RoundDecimal/  se    tyy>Q !MNN))'5==11JKKF+,Bwiq99r   c                     S n[        UR                  5       HD  u  p4U R                  U5      nUS:X  a  UnM   U R                  U5      nUc  UnM8  SU SU SU S3nMF     U(       a  U$ S$ )NTr@   z if z else r   0)reversedr   r   r   r   resultexpr_icond_iexpr_strcond_strs          r   _print_PiecewisePythonPrinter._print_Piecewise7  sy     "&tyy1NF{{6*H~!;;v.>%F 
$xjvhaHF 2  v(S(r   r   N)*r   r   r   r   rS   r   rR   re   r   r   r   rh   rl   rq   rF   rt   r   r   r}   ry   r   r   r   r   r   r   r   r   r   r   r  r  r	  r  r  r  r  r  r   r   r3  r   r   r   r   r   r      s(   ?5:: ?# ?$Duzz Dc DCejj CS C 5::  #  EJJ 3 EJJ 3 JUZZ JC JEJJ 3 Jejj JS J1 1 1/ejj /S /DEJJ D3 DD

 Ds D: : :
:ejj :S :
:ejj :S :95:: 9# 9
9UZZ 9C 9
3uzz 3c 3@uzz @c @
@uzz @c @
8UZZ 8C 8
9ejj 9S 9
9ejj 9S 9
8UZZ 8C 8
9ejj 9S 9
9ejj 9S 9
8UZZ 8C 8
9ejj 9S 9
9ejj 9S 9
9ejj 9S 9
5ejj 5S 5
:

 :s :)UZZ )C )r   r   c                      \ rS rSrS\R
                  S\4S jrS\R
                  S\4S jrS\R
                  S\4S jr	S\R
                  S\4S jr
S\R
                  S\4S jrS\R
                  S\4S	 jrS\R
                  S\4S
 jrS\R
                  S\4S jrS\R
                  S\4S jrS\R
                  S\4S jrS\R
                  S\4S jrS\R
                  S\4S jrS\R
                  S\4S jrS\R
                  S\4S jrS\R
                  S\4S jrS\R
                  S\4S jrS\R
                  S\4S jrS\R
                  S\4S jrS\R
                  S\4S jrS\R
                  S\4S jrS\R
                  S\4S jrS\R
                  S\4S jrS\R
                  S\4S jrS\R
                  S\4S jrS\R
                  S\4S jrS\R
                  S\4S jr S\R
                  S\4S jr!S\R
                  S\4S jr"S\R
                  S\4S  jr#S\R
                  S\4S! jr$S\R
                  S\4S" jr%S\R
                  S\4S# jr&S\R
                  S\4S$ jr'S\R
                  S\4S% jr(S\R
                  S\4S& jr)S\R
                  S\4S' jr*S\R
                  S\4S( jr+S\R
                  S\4S) jr,S*r-g+),
CppPrinteriJ  r   r   c                     [         R                  S;   a  SOSn[        U5      nU[        :  d
  U[        :  a  [        U S[         35      eU[        :X  a  US:w  a  [        S5      eSU S3$ U U 3$ )	N)darwinwin32LLLz too big to convert to r   z#unexpected minimum index type valuez(-1z << 63))sysplatformrZ   INDEX_TYPE_MAXINDEX_TYPE_MINOverflowError
INDEX_TYPEr[   )r   r   suffixis       r   _print_IntegerCppPrinter._print_IntegerK  s~    )<<#I~^!31#%<ZL IJJ. J$%JKK ((VH~r   c                 J   ^  U 4S jUR                    5       u  p#nU SU SU 3$ )Nc              3   \   >#    U  H!  nTR                  U[        S    S-
  5      v   M#     g7fr   r   r   s     r   r   *CppPrinter._print_Where.<locals>.<genexpr>Y  s.      
HQDc:f#5#;<<	r    ?  : r   )r   r   cpqs   `    r   _print_WhereCppPrinter._print_WhereX  s3    
HL		
a Cs#aS!!r   c                    S n[        UR                  5       HX  u  p4U R                  U[        S   S-
  5      nUS:X  a  UnM+  U R                  U[        S   S-
  5      nUc  UnMN  U SU SU 3nMZ     U(       a  SU S3$ S$ )	Nr9   r:   TrI  rJ  r@   r   r+  )r,  r   r   r   r-  s          r   r3  CppPrinter._print_Piecewise^  s     "&tyy1NF((F1Cc1IJH~!,,VZ5G#5MN>%F (zXJc&BF 2 !'6(!}/C/r   c           	         UR                   u  p#nU R                  U5      nUS:w  a5  U R                  U5      nUR                  (       a
  SU SU S3nO	SU SU S3nU R                  U5      nS[         SU S	[         SU S3	$ )
Nr   ,c10::div_floor_integer(static_cast<int64_t>(), static_cast<int64_t>()),c10::div_floor_floating(static_cast<double>(), static_cast<double>(z(static_cast<>(z) % static_cast<)r   doprint
is_integerrA  r   s        r   r   !CppPrinter._print_ModularIndexingp  s    iiLLO!8,,s#CB1#E]^a]bbdeB1#E\]`\aacdll3zl"QC/?
|2cURTUUr   c                     UR                   u  p#U R                  U5      nU R                  U5      nUR                  (       a	  SU SU S3$ SU SU S3$ )NrS  rT  rU  rV  rW  )r   rY  rZ  r   s       r   rF   CppPrinter._print_FloorDiv|  sa    LLOll3??A!D\]`\aacdd=aS@WX[W\\^__r   c                     [        UR                  5      S:w  a  [        S5      eSU R                  UR                  S   5       S3nUR                  (       a  S[
         SU S3$ U$ )Nr   r   std::floor(r   r   static_cast<rX  r   r   r[   r   rZ  rA  r   r   rs      r   r   CppPrinter._print_floor  s^    tyy>Q !EFF$++diil34A648OOj\A3a0JJr   c                     [        UR                  5      S:w  a  [        S5      eSU R                  UR                  S   5       S3nUR                  (       a  S[
         SU S3$ U$ )Nr   r   r_  r   r   r`  rX  ra  rb  s      r   r   CppPrinter._print_FloorToInt  s^    tyy>Q !JKK$++diil34A648OOj\A3a0JJr   c                     [        UR                  5      S:w  a  [        S5      eSU R                  UR                  S   5       S3nS[         SU S3$ )Nr   r   std::trunc(r   r   r`  rX  )r   r   r[   r   rA  rb  s      r   r   CppPrinter._print_TruncToInt  sS    tyy>Q !JKK$++diil34A6j\A3a00r   c                     [        UR                  5      S:w  a  [        S5      eSU R                  UR                  S   5       S3$ )Nr   z)TruncToFloat expects exactly one argumentrh  r   r   r   r   s     r   r   CppPrinter._print_TruncToFloat  s?    tyy>Q !LMMT[[167q99r   c                     [        UR                  5      S:w  a  [        S5      eSU R                  UR                  S   5       S3$ )Nr   r   static_cast<double>(r   r   r   r   s     r   re   CppPrinter._print_ToFloat  s?    tyy>Q !GHH%dkk$))A,&?%@BBr   c                 t    UR                   u  p#U R                  U5      nU R                  U5      nSU SU S3$ )Nzc10::div_mod(r   r   )r   rY  r   s       r   rq   CppPrinter._print_PythonMod  s=    LLOll3qcC5**r   c                 l    UR                   u  p#SU R                  U5       SU R                  U5       S3$ )Nrm  z) / static_cast<double>(r   r   r   )r   r   lhsrhss       r   rt   CppPrinter._print_IntTrueDiv  s<    99%dkk#&6%77OPTP[P[\_P`Oaabccr   c                     UR                   u  p#US:X  a  SU R                  U5       S3$ [        S[        U 5       35      e)Nr   z(1 << (rU  rx   )r   r   rc   rd   r\   s       r   ry   CppPrinter._print_PowByNatural  sH    II	19T[[-.b11!6tDzlC
 	
r   c                 l    UR                   u  p#SU R                  U5       SU R                  U5       S3$ )N	std::pow(r   r   rr  r\   s       r   r}   CppPrinter._print_FloatPow  s6    II	4;;t,-RC0@/ACCr   c                    UR                   u  p#US:X  d  US:X  a#  U R                  U5      nUS:X  a  SU S3$ SU S3$ UR                  (       a  [        U5      nUS:  a  U R	                  U/U-  S[
        S   5      nOQUS	:  a.  S
U R	                  U/[        U5      -  S[
        S   5      -   S-   nOUS	:X  a  SU R                  U5      -   nOSnUR                  (       a  S[         SU S3$ U$ SU S[        U5       S3$ )Nr:   g      
std::sqrt(r   z1.0/std::sqrt(r   r   rX   z1.0/(z1.0/z1.0r`  rX  ry  r   )	r   r   rZ  rZ   r   r   absrA  float)r   r   r]   r^   rc  s        r   r_   CppPrinter._print_Pow  s   II	#:;;t$D+.#:ZvQ'S^D6QR;SS>>c(CQwNND6C<j6GHrnndVc#h%6Z=NOP 
 T[[..8<\*Rs!4NQN tfBuSzl!44r   c                     UR                   S:X  a  UR                   nOUR                   SUR                    S3nUR                  (       a  S[         SU S3$ U$ )Nr   z.0/z.0r`  rX  r   )rM  rL  rZ  rA  rb  s      r   _print_RationalCppPrinter._print_Rational  sR    66Q;66(A66(#dffXR(A48OOj\A3a0JJr   c                     [        UR                  5      S:w  a  [        S5      eSU R                  UR                  S   5       S3nUR                  (       a  S[
         SU S3$ U$ )Nr   r   
std::ceil(r   r   r`  rX  ra  rb  s      r   r   CppPrinter._print_ceiling  s^    tyy>Q !GHHTYYq\231548OOj\A3a0JJr   c                     [        UR                  5      S:w  a  [        S5      eSU R                  UR                  S   5       S3nUR                  (       a  S[
         SU S3$ U$ )Nr   r   r  r   r   r`  rX  ra  rb  s      r   r   CppPrinter._print_CeilToInt  s^    tyy>Q !IJJTYYq\231548OOj\A3a0JJr   c           	          UR                    Vs/ s H  o R                  U5      PM     nn[        U5      S:X  a  S[         SUS    S[         SUS    S3	$ SS	R	                  U5      -   S
-   nS[         SU S3$ s  snf )Nr   zstd::min(static_cast<rX  r   ), static_cast<r   rU  {r   }z	std::min<r   r   r   r   rA  r   r   r   ar   ils        r   r   CppPrinter._print_Min      (,		2	1A	2t9>*:,ba	Q[P\\^_cde_f^ggijj tyy&,Bzl"RD22 3   A;c           	          UR                    Vs/ s H  o R                  U5      PM     nn[        U5      S:X  a  S[         SUS    S[         SUS    S3	$ SS	R	                  U5      -   S
-   nS[         SU S3$ s  snf )Nr   zstd::max(static_cast<rX  r   r  r   rU  r  r   r  z	std::max<r   r  r  s        r   r   CppPrinter._print_Max  r  r  c                     [        UR                  5      S:w  a  [        S5      eSU R                  UR                  S   5       S3$ )Nr   r   z	std::abs(r   r   r   r   s     r   r   CppPrinter._print_Abs  r   r   c                     [        UR                  5      S:w  a  [        S5      eSU R                  UR                  S   5       S3$ )Nr   r   z	std::cos(r   r   r   r   s     r   r   #CppPrinter._print_OpaqueUnaryFn_cos   r   r   c                     [        UR                  5      S:w  a  [        S5      eSU R                  UR                  S   5       S3$ )Nr   r   z
std::cosh(r   r   r   r   s     r   r   $CppPrinter._print_OpaqueUnaryFn_cosh  r   r   c                     [        UR                  5      S:w  a  [        S5      eSU R                  UR                  S   5       S3$ )Nr   r   z
std::acos(r   r   r   r   s     r   r  $CppPrinter._print_OpaqueUnaryFn_acos
  r   r   c                     [        UR                  5      S:w  a  [        S5      eSU R                  UR                  S   5       S3$ r  r   r   s     r   r  #CppPrinter._print_OpaqueUnaryFn_sin  r   r   c                     [        UR                  5      S:w  a  [        S5      eSU R                  UR                  S   5       S3$ )Nr   r  z
std::sinh(r   r   r   r   s     r   r	  $CppPrinter._print_OpaqueUnaryFn_sinh  r   r   c                     [        UR                  5      S:w  a  [        S5      eSU R                  UR                  S   5       S3$ )Nr   r  z
std::asin(r   r   r   r   s     r   r  $CppPrinter._print_OpaqueUnaryFn_asin  r   r   c                     [        UR                  5      S:w  a  [        S5      eSU R                  UR                  S   5       S3$ )Nr   r  z	std::tan(r   r   r   r   s     r   r  #CppPrinter._print_OpaqueUnaryFn_tan  r   r   c                     [        UR                  5      S:w  a  [        S5      eSU R                  UR                  S   5       S3$ )Nr   r  z
std::tanh(r   r   r   r   s     r   r  $CppPrinter._print_OpaqueUnaryFn_tanh#  r   r   c                     [        UR                  5      S:w  a  [        S5      eSU R                  UR                  S   5       S3$ )Nr   r  z
std::atan(r   r   r   r   s     r   r  $CppPrinter._print_OpaqueUnaryFn_atan(  r   r   c                 F    SU R                  UR                  S   5       S3$ )Nr|  r   r   r   r   s     r   r   $CppPrinter._print_OpaqueUnaryFn_sqrt-  #    DKK		!56a88r   c                 F    SU R                  UR                  S   5       S3$ )Nz
std::log2(r   r   r   r   s     r   r  $CppPrinter._print_OpaqueUnaryFn_log20  r  r   c                     [        UR                  5      S:w  a  [        S5      eSU R                  UR                  S   5       S3$ )Nr   r  zstd::lrint(r   r   r   r   s     r   r   CppPrinter._print_RoundToInt3  r   r   c                    [        UR                  5      S:w  a  [        S5      eUR                  u  p#UR                  (       a   US:  a  [        S5      e[	        SU S35      eU R                  U[        S   5      nSU S	U S
U*  S3$ )Nr   r#  r   z+ndigits must be negative for integer inputszOFor integer inputs, only non-negative ndigits are currently supported, but got .rX   z%static_cast<double>(std::nearbyint(1ez * z) * 1er   )r   r   r[   rZ  
ValueErrorr   r   )r   r   r'  r(  
number_strs        r   r   CppPrinter._print_RoundDecimal9  s    tyy>Q !MNN))!|$%RSSabiajjkl  &&vz%/@A
6wis:,fV]U]T^^_``r   c                     g)Ntruer   r   s     r   _print_BooleanTrueCppPrinter._print_BooleanTrueG  s    r   c                     g)Nfalser   r   s     r   _print_BooleanFalseCppPrinter._print_BooleanFalseJ  s    r   c                     g)Nz'std::numeric_limits<double>::infinity()r   r   s     r   rh   CppPrinter._print_InfinityM  s    8r   c                 *    SU R                  U5       3$ )N-)rh   r   s     r   rl   "CppPrinter._print_NegativeInfinityP  s    4''-.//r   r   N).r   r   r   r   rS   r   rR   rD  rN  r3  r   rF   r   r   r   r   re   rq   rt   ry   r}   r_   r  r   r   r   r   r   r   r   r  r  r	  r  r  r  r  r   r  r   r   r  r  rh   rl   r   r   r   r   r6  r6  J  s   5:: # " " "0UZZ 0C 0$
V5:: 
V# 
V`EJJ `3 `K K KKejj KS K1ejj 1S 1:

 :s :
C5:: C# C
+UZZ +C +dejj dS d


 
s 
DEJJ D3 D5uzz 5c 56KEJJ K3 KK5:: K# KKUZZ KC K3uzz 3c 33uzz 3c 38uzz 8c 8
8UZZ 8C 8
9ejj 9S 9
9ejj 9S 9
8UZZ 8C 8
9ejj 9S 9
9ejj 9S 9
8UZZ 8C 8
9ejj 9S 9
9ejj 9S 9
9ejj 9S 99ejj 9S 9:ejj :S :a

 as auzz c 

 s 9EJJ 93 90EJJ 03 0r   r6  )r<  rS   sympy.printing.precedencer   r   sympy.printing.strr   rA  r>  r?  r	   r   r6  r   r   r   <module>r     sN    
  < ) 

x
* x
v})K })@G0 G0r   