o
    0 i                     @   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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enumZ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returnZ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_eqN)
ZalignasZalignofZchar16_tZchar32_tZ	constexprdecltypeZnoexceptZnullptrZstatic_assertZthread_localC++11C++17r*   fmodceil)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 ^/home/app/PaddleOCR-VL-test/.venv_paddleocr/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_namera   	meth_namerd   rb   r`   rc   _attach_print_methodC   s   

rm   c                 C   s(   || j   D ]
\}}t| || qd S N)standarditemsrm   )rj   contrk   Zcxx_namerb   rb   rc   _attach_print_methodsM   s   rr   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   ru   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[   rX   )r^   r_   r|   rb   rb   rc   
_print_MaxZ      z_CXXCodePrinterBase._print_Maxc              	   C   r{   )Nr   )Minr   z%smin(%s, %s))r}   r   r~   r\   r[   rX   )r^   r_   r   rb   rb   rc   
_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   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_rn   )__name__
__module____qualname__ZprintmethodlanguagerX   ru   r   r   r   r   r   r   __classcell__rb   rb   rw   rc   rs   R   s    




rs   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 )Nzusing %(alias)s = %(type)s)apply)r   r   rt   r   kwargsr[   r]   rw   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   rw   rc   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 rn   Z_print_math_funcr]   rb   rb   rc   _print_beta      
zCXX17CodePrinter._print_betac                 C   r   rn   r   r]   rb   rb   rc   	_print_Ei   r   zCXX17CodePrinter._print_Eic                 C   r   rn   r   r]   rb   rb   rc   _print_zeta   r   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   rr   rs   r   r   r   Zcxx_code_printersrb   rb   rb   rc   <module>   sF    
(
