B
    edg              K   @   s  d Z ddlmZ ddlmZ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.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQgJiZed dRdR dSdTdUdVdWdXdYdZd[d\g
 ed]< ed] dRdR ed^< ed^ d6 d_d`dadbdcidddedfdgdhZxdiD ]Ze ed e< qJW xdjD ]Ze ed] e< qjW dkdl Zdmdn ZG dodp dpZG dqdr dreeZG dsdt dteeZG dudv dveeZeeedwZdRS )xz
C++ code printer
    )chain)Typenone   )C89CodePrinterC99CodePrinter)cxxcodez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long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_localzC++11zC++17fmodceil)ModZceilinggammaZtgammabetaZexpintZriemann_zeta)r?   ZEizeta)zC++98zC++11zC++17)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 _/work/yifan.wang/ringdown/master-ringdown-env/lib/python3.7/site-packages/sympy/printing/cxx.py_print_methodF   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_methodB   s    

ri   c             C   s,   x&|| j   D ]\}}t| || qW d S )N)standarditemsri   )rf   contrg   Zcxx_namer^   r^   r_   _attach_print_methodsL   s    rm   c                   sB   e Zd ZdZdZdZd fdd	Zdd Zd	d
 Zdd Z	  Z
S )_CXXCodePrinterBaseZ_cxxcodezC++zstd::Nc                s   t  |pi  d S )N)super__init__)r[   settings)	__class__r^   r_   rp   V   s    z_CXXCodePrinterBase.__init__c          	   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.miscellaneousrs   lenrZ   rY   rV   )r[   r\   rs   r^   r^   r_   
_print_MaxY   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))rt   rw   ru   rZ   rY   rV   )r[   r\   rw   r^   r^   r_   
_print_Min`   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   typerb   )r[   r\   r^   r^   r_   _print_usingg   s    

z _CXXCodePrinterBase._print_using)N)__name__
__module____qualname__ZprintmethodlanguagerV   rp   rv   rx   r{   __classcell__r^   r^   )rr   r_   rn   Q   s   rn   c               @   s   e Zd ZdZeed ZdS )CXX98CodePrinterzC++98N)r|   r}   r~   rj   setreservedreserved_wordsr^   r^   r^   r_   r   n   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 )CXX11CodePrinterzC++11Z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)ry   r   ro   r{   kwargsrY   )r[   r\   )rr   r^   r_   r{      s    
zCXX11CodePrinter._print_using)r|   r}   r~   rj   r   r   r   dictr   r   Ztype_mappingsrk   r   r{   r   r^   r^   )rr   r_   r   v   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 )	CXX17CodePrinterzC++17c             C   s
   |  |S )N)_print_math_func)r[   r\   r^   r^   r_   _print_beta   s    zCXX17CodePrinter._print_betac             C   s
   |  |S )N)r   )r[   r\   r^   r^   r_   	_print_Ei   s    zCXX17CodePrinter._print_Eic             C   s
   |  |S )N)r   )r[   r\   r^   r^   r_   _print_zeta   s    zCXX17CodePrinter._print_zetaN)r|   r}   r~   rj   r   r   r   r   r   Z_kf_math_functionsr   r   r   r^   r^   r^   r_   r      s   r   )zc++98zc++11zc++17)rd   	itertoolsr   Zsympy.codegen.astr   r   cr   r   Zsympy.printing.codeprinterr   r   remover   rc   lowerri   rm   rn   r   r   r   Zcxx_code_printersr^   r^   r^   r_   <module>   sP   



