o
    oh                     @   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andand_eqasmautobitandbitorboolbreakcasezcatch,charclasscomplconst
const_castcontinuedefaultdeletedodoubledynamic_castelseenumexplicitexportexternfalsefloatforfriendgotoifinlineintlongmutable	namespacenewnotnot_eqoperatororor_eqprivate	protectedpublicregisterreinterpret_castreturnshortsignedsizeofstaticstatic_caststructswitchtemplatethisthrowtruetrytypedeftypeidtypenameunionunsignedusingvirtualvoidvolatilewchar_twhilexorxor_eqN)
alignasalignofchar16_tchar32_t	constexprdecltypenoexceptnullptrstatic_assertthread_localC++11C++17r8   fmodceil)Modceilinggammatgammabetaexpintriemann_zeta)rf   Eizeta)r
   r^   r_   )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 f/var/www/html/construction_image-detection-poc/venv/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_namer   	meth_namer   r   r   r   _attach_print_methodC   s   

r   c                 C   s(   || j   D ]
\}}t| || qd S N)standarditemsr   )r   contr   cxx_namer   r   r   _attach_print_methodsM   s   r   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 )_CXXCodePrinterBase_cxxcodezC++zstd::Nc                    s   t  |pi  d S r   )super__init__)r   settings	__class__r   r   r   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   r   )r   r   r   r   r   r   
_print_MaxZ      z_CXXCodePrinterBase._print_Maxc              	   C   r   )Nr   )Minr   z%smin(%s, %s))r   r   r   r   r   r   )r   r   r   r   r   r   
_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   typer   r   r   r   r   _print_usingj   s   

z _CXXCodePrinterBase._print_usingc                 C   s   |j \}d| | S )Nzthrow %s)r   r   )r   rsargr   r   r   _print_Raisep   s   z _CXXCodePrinterBase._print_Raise	stdexceptc                 C   s   |j \}d| j| |f S )Nz%sruntime_error(%s))r   r   r   )r   remessager   r   r   _print_RuntimeError_t   s   z(_CXXCodePrinterBase._print_RuntimeError_r   )__name__
__module____qualname__printmethodlanguager   r   r   r   r   r   r   r   __classcell__r   r   r   r   r   R   s    




r   c                   @   s   e Zd ZdZeed ZdS )CXX98CodePrinterr
   N)r   r   r   r   setreservedreserved_wordsr   r   r   r   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^   int8int8_tcstdintint16int16_tint32int32_tint64int64_tuint8uint8_tuint16uint16_tuint32uint32_tuint64uint64_t	complex64zstd::complex<float>complex
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   r   r   kwargsr   r   r   r   r   r      s   
zCXX11CodePrinter._print_using)r   r   r   r   r   r   r   dictr   r   type_mappingsr   r   r   r   r   r   r   r   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 r   _print_math_funcr   r   r   r   _print_beta      
zCXX17CodePrinter._print_betac                 C   r   r   r   r   r   r   r   	_print_Ei   r   zCXX17CodePrinter._print_Eic                 C   r   r   r   r   r   r   r   _print_zeta   r   zCXX17CodePrinter._print_zetaN)r   r   r   r   r   r   r   r   r   _kf_math_functionsr   r   r   r   r   r   r   r      s    r   )zc++98zc++11zc++17)r   	itertoolsr   sympy.codegen.astr   r   codeprinterr   cr   r   sympy.printing.codeprinterr	   r   remover   r   lowerr   r   r   r   r   r   cxx_code_printersr   r   r   r   <module>   sF    
(
