U
    ZÊ¹jë  ã                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_eqÚasmÚautoZbitandZbitorÚboolÚbreakÚcasezcatch,ÚcharÚclassZcomplÚconstZ
const_castÚcontinueÚdefaultÚdeleteÚdoÚdoubleZdynamic_castÚelseÚenumÚexplicitZexportZexternÚfalseÚfloatÚforZfriendZgotoÚifÚinlineÚintÚlongZmutableÚ	namespaceÚnewÚnotZnot_eqÚoperatorÚorZor_eqÚprivateZ	protectedÚpublicÚregisterZreinterpret_castÚreturnÚshortÚsignedZsizeofZstaticZstatic_castÚstructÚswitchÚtemplateÚthisÚthrowÚtrueÚtryZtypedefZtypeidÚtypenameÚunionZunsignedÚ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)ÚModZceilingÚgammaZtgammaÚbetaZexpintZriemann_zeta)rB   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© úQ/var/www/html/bwave/python/venv/lib/python3.8/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_namerb   Ú	meth_namere   rc   ra   rd   Ú_attach_print_methodC   s    

rn   c                 C   s(   || j   ¡ D ]\}}t| ||ƒ qd S ©N)ÚstandardÚitemsrn   )rk   Úcontrl   Zcxx_namerc   rc   rd   Ú_attach_print_methodsM   s    rs   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 ro   )ÚsuperÚ__init__)r_   Úsettings©Ú	__class__rc   rd   rv   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.miscellaneousr|   Úlenr]   r\   rY   )r_   r`   r|   rc   rc   rd   Ú
_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\   rY   )r_   r`   r€   rc   rc   rd   Ú
_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   Útyperg   r^   rc   rc   rd   Ú_print_usingj   s    

z _CXXCodePrinterBase._print_usingc                 C   s   |j \}d|  |¡ S )Nzthrow %s)r]   r\   )r_   ÚrsÚargrc   rc   rd   Ú_print_Raisep   s    z _CXXCodePrinterBase._print_RaiseZ	stdexceptc                 C   s   |j \}d| j|  |¡f S )Nz%sruntime_error(%s))r]   rY   r\   )r_   ÚreÚmessagerc   rc   rd   Ú_print_RuntimeError_t   s    z(_CXXCodePrinterBase._print_RuntimeError_)N)Ú__name__Ú
__module__Ú__qualname__ZprintmethodÚlanguagerY   rv   r   r   r�   r„   r‡   rŠ   Ú__classcell__rc   rc   rx   rd   rt   R   s   




rt   c                   @   s   e Zd ZdZeed ƒZdS )ÚCXX98CodePrinterr
   N)r‹   rŒ   r�   rp   ÚsetÚreservedÚreserved_wordsrc   rc   rc   rd   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   ru   r„   Úkwargsr\   r^   rx   rc   rd   r„   –   s    
zCXX11CodePrinter._print_using)r‹   rŒ   r�   rp   r‘   r’   r“   Údictr   r�   Ztype_mappingsrq   r   r„   r�   rc   rc   rx   rd   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 ro   ©Z_print_math_funcr^   rc   rc   rd   Ú_print_beta¥   s    zCXX17CodePrinter._print_betac                 C   s
   |   |¡S ro   rš   r^   rc   rc   rd   Ú	_print_Ei¨   s    zCXX17CodePrinter._print_Eic                 C   s
   |   |¡S ro   rš   r^   rc   rc   rd   Ú_print_zeta«   s    zCXX17CodePrinter._print_zetaN)r‹   rŒ   r�   rp   r‘   r’   r“   r˜   r   Z_kfÚ_math_functionsr›   rœ   r�   rc   rc   rc   rd   r™   Ÿ   s   r™   )zc++98zc++11zc++17)ri   Ú	itertoolsr   Zsympy.codegen.astr   r   Zcodeprinterr   Úcr   r   Zsympy.printing.codeprinterr	   r’   Úremoverž   rh   Úlowerrn   rs   rt   r�   r”   r™   Zcxx_code_printersrc   rc   rc   rd   Ú<module>   sò                                                                  õÿ        þ
þ ÿýø
(ý