U
     ‹Ñhë  ã                K   @   sì  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d	d
dddddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRgJiZed dSdS… dTdUdVdWdXdYdZd[d\d]g
 ed^< ed^ dSdS… ed_< ed_  d7¡ d`dadbœdcddidedfdgdhœdiœZdjD ]Ze ¡ ed e< �qTdkD ]Ze ¡ ed^ e< �qpdldm„ Zdndo„ ZG dpdq„ dqƒZG drds„ dsee	ƒZG dtdu„ duee
ƒZG dvdw„ dwee
ƒZeeedxœZdSS )yz
C++ code printer
é    )Úchain)ÚTypeÚnoneé   )Úrequires)ÚC89CodePrinterÚC99CodePrinter)ÚcxxcodeúC++98ÚandZand_eqZasmÚautoZbitandZbitorÚboolÚbreakZcasezcatch,ÚcharÚclassZcomplÚconstZ
const_castÚcontinueÚdefaultÚdeleteZdoÚdoubleZdynamic_castÚelseÚenumÚexplicitÚexportÚexternÚfalseÚfloatÚforZfriendÚgotoÚifÚinlineÚintÚlongZmutableÚ	namespaceÚnewÚnotZnot_eqÚoperatorÚorZor_eqÚprivateZ	protectedÚpublicÚregisterZreinterpret_castÚreturnÚshortÚsignedÚsizeofZstaticZstatic_castÚstructÚswitchÚtemplateÚthisÚthrowÚtrueÚtryZtypedefZtypeidÚtypenameÚunionZunsignedZusingZvirtualÚvoidZvolatileZwchar_tÚwhileÚxorZxor_eqNZalignasZalignofZchar16_tZchar32_tZ	constexprÚdecltypeZnoexceptZnullptrZstatic_assertZthread_localúC++11úC++17ÚfmodÚceil)ZModZceilingÚgammaZtgammaÚbetaZexpintZriemann_zeta)rA   ZEiÚzeta)r
   r<   r=   )Z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/user/2202/pip-unpacked-wheel-qe3242ng/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_namera   Ú	meth_namerd   rb   r`   rc   Ú_attach_print_methodC   s    

rm   c                 C   s(   || j   ¡ D ]\}}t| ||ƒ qd S ©N)ÚstandardÚitemsrm   )rj   Zcontrk   Zcxx_namerb   rb   rc   Ú_attach_print_methodsM   s    rq   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 )Ú_CXXCodePrinterBaseZ_cxxcodezC++zstd::Nc                    s   t ƒ  |pi ¡ d S rn   )ÚsuperÚ__init__)r^   Úsettings©Ú	__class__rb   rc   rt   W   s    z_CXXCodePrinterBase.__init__Ú	algorithm)Úheadersc              	   C   sZ   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.miscellaneousrz   Úlenr\   r[   rX   )r^   r_   rz   rb   rb   rc   Ú
_print_MaxZ   s    ÿz_CXXCodePrinterBase._print_Maxc              	   C   sZ   ddl m} t|jƒdkr*|  |jd ¡S d| j|  |jd ¡|  ||jdd … Ž ¡f S )Nr   )ÚMinr   z%smin(%s, %s))r{   r~   r|   r\   r[   rX   )r^   r_   r~   rb   rb   rc   Ú
_print_Minb   s    ÿz_CXXCodePrinterBase._print_Minc                 C   s    |j tkrd|j S tdƒ‚d S )Nzusing %sz#C++98 does not support type aliases)Úaliasr   Útyperf   r]   rb   rb   rc   Ú_print_usingj   s    

z _CXXCodePrinterBase._print_usingc                 C   s   |j \}d|  |¡ S )Nzthrow %s)r\   r[   )r^   ÚrsÚargrb   rb   rc   Ú_print_Raisep   s    z _CXXCodePrinterBase._print_RaiseZ	stdexceptc                 C   s   |j \}d| j|  |¡f S )Nz%sruntime_error(%s))r\   rX   r[   )r^   ÚreÚmessagerb   rb   rc   Ú_print_RuntimeError_t   s    z(_CXXCodePrinterBase._print_RuntimeError_)N)Ú__name__Ú
__module__Ú__qualname__ZprintmethodÚlanguagerX   rt   r   r}   r   r‚   r…   rˆ   Ú__classcell__rb   rb   rv   rc   rr   R   s   




rr   c                   @   s   e Zd ZdZeed ƒZdS )ÚCXX98CodePrinterr
   N)r‰   rŠ   r‹   ro   ÚsetÚreservedÚreserved_wordsrb   rb   rb   rc   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<   Zint8Zint8_tZcstdintZint16Zint16_tZint32Zint32_tZint64Zint64_tZuint8Zuint8_tZuint16Zuint16_tZuint32Zuint32_tZuint64Zuint64_tZ	complex64zstd::complex<float>ÚcomplexZ
complex128zstd::complex<double>r   )r   Nc                    s,   |j tkrtƒ  |¡S d|j| jd� S d S )Nzusing %(alias)s = %(type)s)Úapply)r€   r   rs   r‚   Úkwargsr[   r]   rv   rb   rc   r‚   –   s    
zCXX11CodePrinter._print_using)r‰   rŠ   r‹   ro   r�   r�   r‘   Údictr   rŽ   Ztype_mappingsrp   r   r‚   r�   rb   rb   rv   rc   r’   ‚   s:              õþr’   c                   @   sF   e Zd ZdZeed ƒZeej	fe
d ŽZ	dd„ Zdd„ Zdd„ ZdS )	ÚCXX17CodePrinterr=   c                 C   s
   |   |¡S rn   ©Z_print_math_funcr]   rb   rb   rc   Ú_print_beta¥   s    zCXX17CodePrinter._print_betac                 C   s
   |   |¡S rn   r˜   r]   rb   rb   rc   Ú	_print_Ei¨   s    zCXX17CodePrinter._print_Eic                 C   s
   |   |¡S rn   r˜   r]   rb   rb   rc   Ú_print_zeta«   s    zCXX17CodePrinter._print_zetaN)r‰   rŠ   r‹   ro   r�   r�   r‘   r–   r   Z_kfÚ_math_functionsr™   rš   r›   rb   rb   rb   rc   r—   Ÿ   s   r—   )zc++98zc++11zc++17)rh   Ú	itertoolsr   Zsympy.codegen.astr   r   Zcodeprinterr   Úcr   r   Zsympy.printing.codeprinterr	   r�   Úremoverœ   rg   Úlowerrm   rq   rr   rŽ   r’   r—   Zcxx_code_printersrb   rb   rb   rc   Ú<module>   sò                                                                  õÿ        þ
þ ÿýø
(ý