o
    8Va!                     @   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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< qTdD ]
Ze ed e< qad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   )C89CodePrinterC99CodePrinter)cxxcodeC++98)JandZand_eqZasmautoZbitandZbitorboolbreakcasezcatch,charclassZcomplconstZ
const_castcontinuedefaultdeleteZdoZdoubleZdynamic_castelseenumZexplicitZexportZexternZfalsefloatforZfriendZgotoifZinlineintZlongZmutable	namespacenewnotZnot_eqoperatororZor_eqZprivateZ	protectedZpublicregisterZreinterpret_castreturnZshortZsignedZsizeofZstaticZstatic_caststructZswitchtemplatethisthrowtruetryZtypedefZtypeidtypenameunionZunsignedZusingZvirtualZvoidZvolatileZwchar_twhilexorZxor_eqN)
ZalignasZalignofZchar16_tZchar32_tZ	constexprZdecltypeZnoexceptZnullptrZstatic_assertZthread_localC++11C++17r    ZfmodZceil)ZModZceilingZgammaZtgammabetaZexpintZriemann_zeta)r.   ZEiZzeta)r	   r,   r-   )ZAbsZexplogZlog10ZsqrtZsinZcosZtanZasinZacosZatanZatan2ZsinhZcoshZtanhZfloor)ZasinhZacoshZatanhZerfZ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 4/usr/lib/python3/dist-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:   Z	meth_namer=   r;   r9   r<   _attach_print_methodB   s   

rE   c                 C   s(   || j   D ]
\}}t| || qd S N)standarditemsrE   )rC   ZcontrD   Zcxx_namer;   r;   r<   _attach_print_methodsL   s   rI   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 rF   )super__init__)r7   Zsettings	__class__r;   r<   rL   V   s   z_CXXCodePrinterBase.__init__c              	   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))sympyrP   lenr5   r4   r1   )r7   r8   rP   r;   r;   r<   
_print_MaxY      z_CXXCodePrinterBase._print_Maxc              	   C   rO   )Nr   )Minr   z%smin(%s, %s))rQ   rU   rR   r5   r4   r1   )r7   r8   rU   r;   r;   r<   
_print_Min`   rT   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?   r6   r;   r;   r<   _print_usingg   s   

z _CXXCodePrinterBase._print_usingrF   )__name__
__module____qualname__Zprintmethodlanguager1   rL   rS   rV   rY   __classcell__r;   r;   rM   r<   rJ   Q   s    rJ   c                   @   s   e Zd ZdZeed ZdS )CXX98CodePrinterr	   N)rZ   r[   r\   rG   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 )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 )Nzusing %(alias)s = %(type)s)Zapply)rW   r   rK   rY   kwargsr4   r6   rM   r;   r<   rY      s   
zCXX11CodePrinter._print_using)rZ   r[   r\   rG   r`   ra   rb   dictr   r_   Ztype_mappingsrH   r   rY   r^   r;   r;   rM   r<   rc   v   s(    rc   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 rF   Z_print_math_funcr6   r;   r;   r<   _print_beta      
zCXX17CodePrinter._print_betac                 C   rh   rF   ri   r6   r;   r;   r<   	_print_Ei   rk   zCXX17CodePrinter._print_Eic                 C   rh   rF   ri   r6   r;   r;   r<   _print_zeta   rk   zCXX17CodePrinter._print_zetaN)rZ   r[   r\   rG   r`   ra   rb   rf   r   Z_kf_math_functionsrj   rl   rm   r;   r;   r;   r<   rg      s    rg   )zc++98zc++11zc++17)rA   	itertoolsr   Zsympy.codegen.astr   r   cr   r   Zsympy.printing.codeprinterr   ra   removern   r@   lowerrE   rI   rJ   r_   rc   rg   Zcxx_code_printersr;   r;   r;   r<   <module>   sD    

