o
    §ƒðjë  ã                   @   sH  d Z ddlmZ ddlmZmZ ddlmZ ddlm	Z	m
Z
 ddlmZ dg d	¢iZed d
d
… g d¢ ed< ed d
d
… ed< ed  d¡ dddœddiddddœdœZdD ]
Ze ¡ ed e< qZdD ]
Ze ¡ ed e< qgdd„ Zdd„ ZG dd „ d ƒZG d!d"„ d"ee	ƒZG d#d$„ d$ee
ƒZG d%d&„ d&ee
ƒZeeed'œZd
S )(z
C++ code printer
é    )Úchain)ÚTypeÚnoneé   )Úrequires)ÚC89CodePrinterÚC99CodePrinter)ÚcxxcodeúC++98)JÚandÚand_eqÚasmÚautoÚbitandÚbitorÚboolÚbreakÚcasezcatch,ÚcharÚclassÚcomplÚconstÚ
const_castÚcontinueÚdefaultÚdeleteÚdoÚdoubleÚdynamic_castÚelseÚenumÚexplicitÚexportÚexternÚfalseÚfloatÚforÚfriendÚgotoÚifÚinlineÚintÚlongÚmutableÚ	namespaceÚnewÚnotÚnot_eqÚoperatorÚorÚor_eqÚprivateÚ	protectedÚpublicÚregisterÚreinterpret_castÚreturnÚshortÚsignedÚsizeofÚstaticÚstatic_castÚstructÚswitchÚtemplateÚthisÚthrowÚtrueÚtryÚtypedefÚtypeidÚtypenameÚunionÚunsignedÚusingÚvirtualÚvoidÚvolatileÚwchar_tÚwhileÚxorÚxor_eqN)
ÚalignasÚalignofÚchar16_tÚchar32_tÚ	constexprÚdecltypeÚnoexceptÚnullptrÚstatic_assertÚthread_localúC++11úC++17r8   ÚfmodÚceil)ÚModÚceilingÚgammaÚtgammaÚbetaÚexpintÚriemann_zeta)rf   ÚEiÚzeta)r
   r^   r_   )ÚAbsÚexpÚlogÚlog10ÚsqrtÚsinÚcosÚtanÚasinÚacosÚatanÚatan2ÚsinhÚcoshÚtanhÚfloor)ÚasinhÚacoshÚatanhÚerfÚerfcc                    s@   d| }t | |ƒrtdƒ‚‡ fdd„}dt |_t| ||ƒ d S )Nz	_print_%sz1Edit method (or subclass) instead of overwriting.c              	      s    d  | jˆ d t| j|jƒ¡¡S )Nz{}{}({})z, )ÚformatÚ_nsÚjoinÚmapÚ_printÚargs©ÚselfÚexpr©Ú	func_name© ú”/tmp/claude-1000/-var-www-html-academy/3f42efd1-c2b7-4d08-9b05-30d86bb35479/scratchpad/piper/venv/lib/python3.10/site-packages/sympy/printing/cxx.pyÚ_print_methodG   s    z+_attach_print_method.<locals>._print_methodzPrints code for %s)ÚhasattrÚ
ValueErrorÚkÚ__doc__Úsetattr)ÚclsÚ
sympy_namerŠ   Ú	meth_namer�   r‹   r‰   rŒ   Ú_attach_print_methodC   s   

r–   c                 C   s(   || j   ¡ D ]
\}}t| ||ƒ qd S ©N)ÚstandardÚitemsr–   )r“   Úcontr”   Úcxx_namer‹   r‹   rŒ   Ú_attach_print_methodsM   s   ÿrœ   c                       sv   e Zd ZdZdZdZd‡ fdd„	Zedhd�d	d
„ ƒZedhd�dd„ ƒZ	dd„ Z
dd„ Zedhd�dd„ ƒZ‡  ZS )Ú_CXXCodePrinterBaseÚ_cxxcodezC++zstd::Nc                    s   t ƒ  |pi ¡ d S r—   )ÚsuperÚ__init__)r‡   Úsettings©Ú	__class__r‹   rŒ   r    W   s   z_CXXCodePrinterBase.__init__Ú	algorithm)Úheadersc              	   C   óZ   ddl m} t|jƒdkr|  |jd ¡S d| j|  |jd ¡|  ||jdd … Ž ¡f S )Nr   )ÚMaxr   z%smax(%s, %s))Ú(sympy.functions.elementary.miscellaneousr§   Úlenr…   r„   r�   )r‡   rˆ   r§   r‹   r‹   rŒ   Ú
_print_MaxZ   ó   ÿz_CXXCodePrinterBase._print_Maxc              	   C   r¦   )Nr   )ÚMinr   z%smin(%s, %s))r¨   r¬   r©   r…   r„   r�   )r‡   rˆ   r¬   r‹   r‹   rŒ   Ú
_print_Minb   r«   z_CXXCodePrinterBase._print_Minc                 C   s   |j tkr
d|j S tdƒ‚)Nzusing %sz#C++98 does not support type aliases)Úaliasr   Útyper�   r†   r‹   r‹   rŒ   Ú_print_usingj   s   

z _CXXCodePrinterBase._print_usingc                 C   s   |j \}d|  |¡ S )Nzthrow %s)r…   r„   )r‡   ÚrsÚargr‹   r‹   rŒ   Ú_print_Raisep   s   z _CXXCodePrinterBase._print_RaiseÚ	stdexceptc                 C   s   |j \}d| j|  |¡f S )Nz%sruntime_error(%s))r…   r�   r„   )r‡   ÚreÚmessager‹   r‹   rŒ   Ú_print_RuntimeError_t   s   z(_CXXCodePrinterBase._print_RuntimeError_r—   )Ú__name__Ú
__module__Ú__qualname__ÚprintmethodÚlanguager�   r    r   rª   r­   r°   r³   r·   Ú__classcell__r‹   r‹   r¢   rŒ   r�   R   s    




r�   c                   @   s   e Zd ZdZeed ƒZdS )ÚCXX98CodePrinterr
   N)r¸   r¹   rº   r˜   ÚsetÚreservedÚreserved_wordsr‹   r‹   r‹   rŒ   r¾   z   s    r¾   c                       sØ   e Zd ZdZeed ƒZeee	j
 ¡ edƒddhfedƒddhfedƒddhfed	ƒd
dhfedƒddhfedƒddhfedƒddhfedƒddhfedƒddhfedƒddhfedƒdi ¡ ƒƒZ
‡ fdd„Z‡  ZS )ÚCXX11CodePrinterr^   Úint8Úint8_tÚcstdintÚint16Úint16_tÚint32Úint32_tÚint64Úint64_tÚuint8Úuint8_tÚuint16Úuint16_tÚuint32Úuint32_tÚuint64Úuint64_tÚ	complex64zstd::complex<float>ÚcomplexÚ
complex128zstd::complex<double>r   )r   Nc                    s(   |j tkrtƒ  |¡S d|j| jd� S )Nzusing %(alias)s = %(type)s)Úapply)r®   r   rŸ   r°   Úkwargsr„   r†   r¢   r‹   rŒ   r°   –   s   
zCXX11CodePrinter._print_using)r¸   r¹   rº   r˜   r¿   rÀ   rÁ   Údictr   r¾   Útype_mappingsr™   r   r°   r½   r‹   r‹   r¢   rŒ   rÂ   ‚   s(    õòrÂ   c                   @   sJ   e Zd ZdZeed ƒZeej	fi e
d ¤ŽZ	dd„ Zdd„ Zdd„ ZdS )	ÚCXX17CodePrinterr_   c                 C   ó
   |   |¡S r—   ©Ú_print_math_funcr†   r‹   r‹   rŒ   Ú_print_beta¥   ó   
zCXX17CodePrinter._print_betac                 C   rÜ   r—   rÝ   r†   r‹   r‹   rŒ   Ú	_print_Ei¨   rà   zCXX17CodePrinter._print_Eic                 C   rÜ   r—   rÝ   r†   r‹   r‹   rŒ   Ú_print_zeta«   rà   zCXX17CodePrinter._print_zetaN)r¸   r¹   rº   r˜   r¿   rÀ   rÁ   rÙ   r   Ú_kfÚ_math_functionsrß   rá   râ   r‹   r‹   r‹   rŒ   rÛ   Ÿ   s    rÛ   )zc++98zc++11zc++17)r‘   Ú	itertoolsr   Úsympy.codegen.astr   r   Úcodeprinterr   Úcr   r   Úsympy.printing.codeprinterr	   rÀ   Úremoverä   r�   Úlowerr–   rœ   r�   r¾   rÂ   rÛ   Úcxx_code_printersr‹   r‹   r‹   rŒ   Ú<module>   sF    ÿþÿýø
(
ý