B
    [^              K   @   s  d dl mZmZmZ d dlmZ d dlmZ d dlm	Z	m
Z
 ddlmZ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< qZW xdjD ]Ze ed] e< qzW dkdl Zdmdn ZG dodp dpeZG dqdr dreeZG dsdt dteeZG dudv dveeZeeedwZd{dydzZdRS )|    )absolute_importdivisionprint_function)wraps)chain)Typenone   )C89CodePrinterC99CodePrinterzC++98andZand_eqZasmautoZbitandZbitorboolbreakZcasezcatch,charclassZcomplZ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shortsignedZsizeofZstaticZstatic_castZstructZswitchtemplatethisthrowtruetryZtypedefZtypeidtypenameunionZunsignedZusingZvirtualZvoidZvolatileZwchar_twhilexorZxor_eqNZalignasZalignofZchar16_tZchar32_tZ	constexprZdecltypeZnoexceptZnullptrZstatic_assertZthread_localzC++11zC++17ZfmodZceil)ZModZceilingZgammaZtgammabetaZexpintZriemann_zeta)r,   ZEiZzeta)zC++98zC++11zC++17)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{0}{1}({2})z, )format_nsjoinmap_printargs)selfexpr)	func_name 5lib/python3.7/site-packages/sympy/printing/cxxcode.py_print_methodD   s    z+_attach_print_method.<locals>._print_methodzPrints code for %s)hasattr
ValueErrork__doc__setattr)cls
sympy_namer6   Z	meth_namer9   r7   )r6   r8   _attach_print_method@   s    

rA   c             C   s,   x&|| j   D ]\}}t| || qW d S )N)standarditemsrA   )r?   Zcontr@   Zcxx_namer7   r7   r8   _attach_print_methodsJ   s    rD   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 t| |pi  d S )N)superrE   __init__)r4   settings)	__class__r7   r8   rG   T   s    z_CXXCodePrinterBase.__init__c          	   C   sT   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))sympyrJ   lenr3   r2   r/   )r4   r5   rJ   r7   r7   r8   
_print_MaxW   s    z_CXXCodePrinterBase._print_Maxc          	   C   sT   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))rK   rN   rL   r3   r2   r/   )r4   r5   rN   r7   r7   r8   
_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   typer;   )r4   r5   r7   r7   r8   _print_usingc   s    

z _CXXCodePrinterBase._print_using)N)__name__
__module____qualname__ZprintmethodZlanguager/   rG   rM   rO   rR   __classcell__r7   r7   )rI   r8   rE   O   s   rE   c               @   s   e Zd ZdZeed ZdS )CXX98CodePrinterzC++98N)rS   rT   rU   rB   setreservedreserved_wordsr7   r7   r7   r8   rW   j   s   rW   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                s0   |j tkrtt| |S d|j| jd S d S )Nzusing %(alias)s = %(type)s)Zapply)rP   r   rF   r[   rR   kwargsr2   )r4   r5   )rI   r7   r8   rR      s    
zCXX11CodePrinter._print_using)rS   rT   rU   rB   rX   rY   rZ   dictr   rW   Ztype_mappingsrC   r   rR   rV   r7   r7   )rI   r8   r[   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 )	CXX17CodePrinterzC++17c             C   s
   |  |S )N)_print_math_func)r4   r5   r7   r7   r8   _print_beta   s    zCXX17CodePrinter._print_betac             C   s
   |  |S )N)r`   )r4   r5   r7   r7   r8   	_print_Ei   s    zCXX17CodePrinter._print_Eic             C   s
   |  |S )N)r`   )r4   r5   r7   r7   r8   _print_zeta   s    zCXX17CodePrinter._print_zetaN)rS   rT   rU   rB   rX   rY   rZ   r^   r   Z_kf_math_functionsra   rb   rc   r7   r7   r7   r8   r_      s   r_   )zc++98zc++11zc++17c++11c             K   s   t |  || |S )z( C++ equivalent of :func:`sympy.ccode`. )cxx_code_printerslowerZdoprint)r5   Z	assign_torB   rH   r7   r7   r8   cxxcode   s    rh   )Nre   )Z
__future__r   r   r   	functoolsr   	itertoolsr   Zsympy.codegen.astr   r   Zccoder
   r   rY   removerd   r<   rg   rA   rD   objectrE   rW   r[   r_   rf   rh   r7   r7   r7   r8   <module>   sR   



