
    EdJ                        d dl mZ d dlmZ d dlmZ ddlmZmZm	Z	m
Z
mZmZ ddlmZ d                                Zd  ej                    D             Z eefi d	d
ddddddddddZdddddddZd e                                D             Zd e                                D             Z G d dee          ZeD ]Z eed e e
           eD ]Z eed e e	           i d!d!d"d"d#d$d%d&d'd(d)d*d+d+d,d,d-d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCZdDddEZdF e                                D             ZdG e                                D             Z G dH dIe          Z eD ]Z ee d e e
           eD ]Z ee d e e	           dJ e                                D             Z!dK e                                D             Z" G dL dMe          Z#e!D ]Z ee#d e e
           e"D ]Z ee#d e e	           dN e                                D             Z$dO e                                D             Z% G dP dQe          Z&e$D ]Z ee&d e e
           e%D ]Z ee&d e e	           dRS )S    )S)Lambda)Pow   )PythonCodePrinter_known_functions_math_print_known_const_print_known_func_unpack_integral_limitsArrayPrinter)CodePrinterz!erf erfc factorial gamma loggammac                 .    g | ]\  }}|t           v||fS  )_not_in_numpy.0kvs      4lib/python3.11/site-packages/sympy/printing/numpy.py
<listcomp>r   	   s*    XXX1-AWXaVXXX    arccosarccosharcsinarcsinharctanarctan2arctanhexp2sign	logaddexp
logaddexp2)acosacoshasinasinhatanatan2atanhr   r    r!   r"   epieuler_gammananPINFNINF)Exp1Pi
EulerGammaNaNInfinityNegativeInfinityc                      i | ]\  }}|d |z   S znumpy.r   r   s      r   
<dictcomp>r8       "    UUUda!X\UUUr   c                      i | ]\  }}|d |z   S r7   r   r   s      r   r8   r8   !   r9   r   c                   B    e Zd ZdZdZeZeZd+ fd	Z	d Z
d Zd Zd Zd	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z fdZd Zd Zd Zd,dZd Zd Z d Z!d Z"d Z#d  Z$d! Z%d" Z&d# Z'd$ Z(d% Z)d&Z*d'Z+d(Z,d)Z-d*Z.e/j0        Z1e/j0        Z2e/j0        Z3e/j0        Z4 xZ5S )-NumPyPrinterza
    Numpy printer which handles vectorized piecewise functions,
    logical operators, etc.
    numpyNc                     d                     | j                  | _        d                     | j                  | _        i t          j        | j        | _        t                                          |           dS )z
        `settings` is passed to CodePrinter.__init__()
        `module` specifies the array module to use, currently 'NumPy', 'CuPy'
        or 'JAX'.
        zPython with {}z_{}codesettingsN)format_modulelanguageprintmethodr   _kfsuper__init__selfr@   	__class__s     r   rG   zNumPyPrinter.__init__-   sl     )//==$++DL998'+8tx8(+++++r   c                 p     d}d                     |                     fd|D                                 S )z+General sequence printer: converts to tuple, z({},)c              3   B   K   | ]}                     |          V  d S N_print)r   itemrI   s     r   	<genexpr>z*NumPyPrinter._print_seq.<locals>.<genexpr>@   s/      ,O,O4T[[->->,O,O,O,O,O,Or   )rA   join)rI   seq	delimiters   `  r   
_print_seqzNumPyPrinter._print_seq;   s=     	~~inn,O,O,O,O3,O,O,OOOPPPr   c                     |                                 d         t          j        urj|                                 d         |                                 d         gz   }d                    d                     fd|D                                 S d                    d                     fd|j        D                                 S )zMatrix multiplication printerr   r   ({})z).dot(c              3   B   K   | ]}                     |          V  d S rN   rO   r   irI   s     r   rR   z-NumPyPrinter._print_MatMul.<locals>.<genexpr>F   s-      .Q.Q!t{{1~~.Q.Q.Q.Q.Q.Qr   c              3   B   K   | ]}                     |          V  d S rN   rO   rZ   s     r   rR   z-NumPyPrinter._print_MatMul.<locals>.<genexpr>G   s-      *M*Ma4;;q>>*M*M*M*M*M*Mr   )as_coeff_matricesr   OnerA   rS   args)rI   expr	expr_lists   `  r   _print_MatMulzNumPyPrinter._print_MatMulB   s    !!##A&ae3 	S..003d6L6L6N6Nq6Q4SSI==.Q.Q.Q.Qy.Q.Q.Q!Q!QRRR}}X]]*M*M*M*M49*M*M*MMMNNNr   c                     d                     |                     | j        dz             |                     |j        d                   |                     |j        d                             S )zMatrix power printerz
{}({}, {})z.linalg.matrix_powerr   r   rA   _module_formatrB   rP   r_   rI   r`   s     r   _print_MatPowzNumPyPrinter._print_MatPowI   s^    ""4#6#6t|F\7\#]#]KK	!%%t{{49Q<'@'@B B 	Br   c                     d                     |                     | j        dz             |                     |j        d                             S )zMatrix inverse printer{}({})z.linalg.invr   rd   rf   s     r   _print_InversezNumPyPrinter._print_InverseN   sD    t224<-3OPPKK	!%%' ' 	'r   c                    |j         \  }}|j        d         dk    r|j        }|j        d         dk    r|j        }|                     | j        dz             d|                     |          d|                     |          dS )Nr   r   z.dot(rL   ))r_   shapeTre   rB   rP   )rI   r`   arg1arg2s       r   _print_DotProductzNumPyPrinter._print_DotProductS   s     Y
d:a=A 	6D:a=A 	6D#224<&3HIIII#{{40000#{{400002 	2r   c                     |                      | j        dz             d|                     |j                  d|                     |j                  dS )Nz.linalg.solverl   rL   rm   )re   rB   rP   matrixvectorrf   s     r   _print_MatrixSolvezNumPyPrinter._print_MatrixSolve`   sX    #224</3QRRRR#{{4;7777#{{4;77779 	9r   c                     d                     |                     | j        dz             |                     |j                            S )Nri   z.zerosrA   re   rB   rP   rn   rf   s     r   _print_ZeroMatrixzNumPyPrinter._print_ZeroMatrixe   s@    t224<(3JKKKK
##% % 	%r   c                     d                     |                     | j        dz             |                     |j                            S )Nri   z.onesrx   rf   s     r   _print_OneMatrixzNumPyPrinter._print_OneMatrixi   s@    t224<'3IJJKK
##% % 	%r   c                     ddl m}m} |j        }t	          |t
                    st          ||f |||                    }d                                          j        dz             d	                     fd|j
        d         D                                            |j
        d                                        |j                            S )Nr   )r[   jz{}(lambda {}: {}, {})z.fromfunctionrL   c              3   B   K   | ]}                     |          V  d S rN   rO   r   argrI   s     r   rR   z5NumPyPrinter._print_FunctionMatrix.<locals>.<genexpr>s   s/      @@3dkk#&&@@@@@@r   r   )	sympy.abcr[   r}   lamda
isinstancer   rA   re   rB   rS   r_   rP   rn   )rI   r`   r[   r}   r   s   `    r   _print_FunctionMatrixz"NumPyPrinter._print_FunctionMatrixm   s    """"""""
%(( 	0Aq655A;;//E&--d.A.A$,Q`B`.a.aII@@@@%*Q-@@@@@KK
1&&DJ(?(?A A 	Ar   c                 8                           j        dz             d                     fd|j        d d         D                       d                                         |j        d                   dt          |j                  dz
  z            z   S )N	.multiply c              3   j   K   | ]-}d                                          |                    V  .dS z{}({}, NrA   rP   r   r   funcrI   s     r   rR   z6NumPyPrinter._print_HadamardProduct.<locals>.<genexpr>x   S       ' ' !''dkk#.>.>?? ' ' ' ' ' 'r   {}{}rm   r   re   rB   rS   r_   rA   rP   lenrI   r`   r   s   ` @r   _print_HadamardProductz#NumPyPrinter._print_HadamardProductv   s    ""4<+#=>>ww ' ' ' ' 'y"~' ' ' ' ')/t{{49R=7Q7Q3ty>>A%&*( *(( 	(r   c                 8                           j        dz             d                     fd|j        d d         D                       d                                         |j        d                   dt          |j                  dz
  z            z   S )Nz.kronr   c              3   j   K   | ]-}d                                          |                    V  .dS r   r   r   s     r   rR   z7NumPyPrinter._print_KroneckerProduct.<locals>.<genexpr>~   r   r   r   r   rm   r   r   r   s   ` @r   _print_KroneckerProductz$NumPyPrinter._print_KroneckerProduct|   s    ""4<'#9::ww ' ' ' ' 'y"~' ' ' ' ')/t{{49R=7Q7Q3ty>>A%&*( *(( 	(r   c                     d                     |                     | j        dz             |                     | j        dz             |                     |j        d                             S )Nz
{}({}({}))z
.conjugatez
.transposer   rd   rf   s     r   _print_AdjointzNumPyPrinter._print_Adjoint   s_    ""| ;<<| ;<<KK	!%%' ' 	'r   c                     d                     |                     | j        dz             |                     |j                            }d                     |                     | j        dz             |          S )Nri   z.diagz{}({}, (-1, 1))z.reshape)rA   re   rB   rP   r   )rI   r`   vects      r   _print_DiagonalOfzNumPyPrinter._print_DiagonalOf   su    w 677KK!!# # !''z 9::DB B 	Br   c                     d                     |                     | j        dz             |                     |j        d                             S )Nri   z	.diagflatr   rd   rf   s     r   _print_DiagMatrixzNumPyPrinter._print_DiagMatrix   sD    t224<+3MNNKK	!%%' ' 	'r   c           
      H   d                     |                     | j        dz             |                     |j                  |                     | j        dz             |                     |j        d                   |                     |j        d                             S )Nz{}({}, {}({}, {}))r   .eyer   r   )rA   re   rB   rP   r   rn   rf   s     r   _print_DiagonalMatrixz"NumPyPrinter._print_DiagonalMatrix   s    #**4+>+>t|k?Y+Z+ZKK!!4#6#6t|f7L#M#MKK
1&&DJqM(B(BD D 	Dr   c                     ddl mm  fdd                    d                     fd|j        D                                 }d                    d                    fd|j        D                                 }d                                          j        d	z             ||                     t          j
                            S )
zPiecewise function printerr   )ITEsimplify_logicc                     |                                r                     |                     S                     |           S )z$ Problem having an ITE in the cond. )hasrP   )condr   rI   r   s    r   
print_condz1NumPyPrinter._print_Piecewise.<locals>.print_cond   sC    xx}} ){{>>$#7#7888{{4(((r   z[{}],c              3   L   K   | ]}                     |j                  V  d S rN   )rP   r`   r   s     r   rR   z0NumPyPrinter._print_Piecewise.<locals>.<genexpr>   s1      &R&Rt{{38'<'<&R&R&R&R&R&Rr   c              3   8   K   | ]} |j                   V  d S rN   )r   )r   r   r   s     r   rR   z0NumPyPrinter._print_Piecewise.<locals>.<genexpr>   s/      &Q&Qzz#(';';&Q&Q&Q&Q&Q&Qr   z{}({}, {}, default={})z.select)sympy.logic.boolalgr   r   rA   rS   r_   re   rB   rP   r   r3   )rI   r`   exprscondsr   r   r   s   `   @@@r   _print_PiecewisezNumPyPrinter._print_Piecewise   s    ;;;;;;;;	) 	) 	) 	) 	) 	) 	) chh&R&R&R&R	&R&R&RRRSSchh&Q&Q&Q&Qty&Q&Q&QQQRR
 (..y 8995%KK    	 r   c                 T   ddddddd}|j         |v ru|                     |j                  }|                     |j                  }d                    |                     | j        d	z   ||j                  z             ||
          S t                                          |          S )z.Relational printer for Equality and Unequalityequal	not_equalless
less_equalgreatergreater_equal)z==z!=<z<=>z>=z{op}({lhs}, {rhs}).)oplhsrhs)	rel_oprP   r   r   rA   re   rB   rF   _print_Relational)rI   r`   r   r   r   rJ   s        r   r   zNumPyPrinter._print_Relational   s     !
 
 ;" 	A++dh''C++dh''C'..$2E2EdlUXFXY[\`\gYhFh2i2i36C / A A Aww((...r   c                      d                                           j        dz             d                     fd|j        D                                 S )Logical And printer{}.reduce(({}))z.logical_andr   c              3   B   K   | ]}                     |          V  d S rN   rO   rZ   s     r   rR   z*NumPyPrinter._print_And.<locals>.<genexpr>   sT        eH  eHxyeiepepqreses  eH  eH  eH  eH  eH  eHr   rA   re   rB   rS   r_   rf   s   ` r   
_print_AndzNumPyPrinter._print_And   s    
 !''(;(;DL><Y(Z(Z\_\d\d  eH  eH  eH  eH  ~B  ~G  eH  eH  eH  ]H  ]H  I  I  	Ir   c                      d                                           j        dz             d                     fd|j        D                                 S )Logical Or printerr   z.logical_orr   c              3   B   K   | ]}                     |          V  d S rN   rO   rZ   s     r   rR   z)NumPyPrinter._print_Or.<locals>.<genexpr>   sT        dG  dGwxdhdodopqdrdr  dG  dG  dG  dG  dG  dGr   r   rf   s   ` r   	_print_OrzNumPyPrinter._print_Or   s    
 !''(;(;DL=<X(Y(Y[^[c[c  dG  dG  dG  dG  }A  }F  dG  dG  dG  \G  \G  H  H  	Hr   c                      d                                           j        dz             d                     fd|j        D                                 S )zLogical Not printerri   z.logical_notr   c              3   B   K   | ]}                     |          V  d S rN   rO   rZ   s     r   rR   z*NumPyPrinter._print_Not.<locals>.<genexpr>   s4      [~[~op\`\g\ghi\j\j[~[~[~[~[~[~r   r   rf   s   ` r   
_print_NotzNumPyPrinter._print_Not   sV    
 t224<.3PQQSVS[S[[~[~[~[~txt}[~[~[~S~S~r   Fc                     |j         j        r:|j         j        r.t          |j        |j                                         d          }|                     ||| j        dz             S )NF)evaluatez.sqrt)rationalsqrt)exp
is_integeris_negativer   baseevalf_hprint_PowrB   )rI   r`   r   s      r   
_print_PowzNumPyPrinter._print_Pow   sa    8 	D48#7 	Dty$(.."2"2UCCCDxdlW>TUUUr   c                      d                                           j        dz             d                     fd|j        D                                 S )N{}(({}), axis=0)z.aminr   c              3   B   K   | ]}                     |          V  d S rN   rO   rZ   s     r   rR   z*NumPyPrinter._print_Min.<locals>.<genexpr>   T        _B  _Brs_c_j_jkl_m_m  _B  _B  _B  _B  _B  _Br   r   rf   s   ` r   
_print_MinzNumPyPrinter._print_Min       !(()<)<T\G=S)T)TVYV^V^  _B  _B  _B  _Bw{  xA  _B  _B  _B  WB  WB  C  C  	Cr   c                      d                                           j        dz             d                     fd|j        D                                 S )Nr   z.amaxr   c              3   B   K   | ]}                     |          V  d S rN   rO   rZ   s     r   rR   z*NumPyPrinter._print_Max.<locals>.<genexpr>   r   r   r   rf   s   ` r   
_print_MaxzNumPyPrinter._print_Max   r   r   c                     |                      | j        dz             d|                     |j        d                   dS )Nz.anglerl   r   rm   re   rB   rP   r_   rf   s     r   
_print_argzNumPyPrinter._print_arg   sD    ..t|h/FGGGGUYU^_`UaIbIbIbIbccr   c                     |                      | j        dz             d|                     |j        d                   dS )Nz.imagrl   r   rm   r   rf   s     r   	_print_imzNumPyPrinter._print_im   D    ..t|g/EFFFFTXT]^_T`HaHaHaHabbr   c                                             j        dz             dd                    t           fd|j                            dS )Nz.modrl   rL   c                 .                         |           S rN   rO   )r   rI   s    r   <lambda>z)NumPyPrinter._print_Mod.<locals>.<lambda>   s    DKK,, r   rm   )re   rB   rS   mapr_   rf   s   ` r   
_print_ModzNumPyPrinter._print_Mod   sb    ..t|f/DEEEEtyy,,,,di88H: H: H: H: ; 	;r   c                     |                      | j        dz             d|                     |j        d                   dS )Nz.realrl   r   rm   r   rf   s     r   	_print_rezNumPyPrinter._print_re   r   r   c                     |                      | j        dz             d|                     |j        d         t          j        z            dS )Nz.sincrl   r   rm   )re   rB   rP   r_   r   r1   rf   s     r   _print_sinczNumPyPrinter._print_sinc   sM    ..t|g/EFFFFTXT]^_T`abaeTeHfHfHfHfggr   c                     | j                             |j        j        d           }||                     | j        dz             }|d|                     |                                          dS )Nz.arrayrl   rm   )known_functionsgetrJ   __name__re   rB   rP   tolistr   s      r   _print_MatrixBasezNumPyPrinter._print_MatrixBase   sk    #''(?FF 	@&&t|h'>??D44T[[]]!;!;!;!;<<r   c                     |j         }t          d |D                       rA|                     | j        dz             d|                     |j         d                   dS t          d          )Nc              3   $   K   | ]}|j         V  d S rN   )
is_Integer)r   dims     r   rR   z/NumPyPrinter._print_Identity.<locals>.<genexpr>   s$      //#s~//////r   r   rl   r   rm   zFSymbolic matrix dimensions are not yet supported for identity matrices)rn   allre   rB   rP   NotImplementedError)rI   r`   rn   s      r   _print_IdentityzNumPyPrinter._print_Identity   sz    
/////// 	p#224<&3HIIII4;;W[WabcWdKeKeKeKeff%&nooor   c                     d                     |                     | j        dz             |                     |j        d                                                             S )Nri   z.blockr   )rA   re   rB   rP   r_   r   rf   s     r   _print_BlockMatrixzNumPyPrinter._print_BlockMatrix   sS    t224<(3JKK!%TYq\-@-@-B-B!C!CE E 	Er   c                 6   t          |j                  dk    r.| j        dz   |                     |j        d                   z   dz   S t          |j                  dk    r'|                     |                                          S t          j        | |          S )Nr   z.array(r   rm      )r   rn   rB   rP   r_   tomatrixr   _print_not_supportedrf   s     r   _print_NDimArrayzNumPyPrinter._print_NDimArray   s    tz??a 	N<)+dkk$)A,.G.GG#MMtz??a 	0;;t}}////d;;;r   addeinsum	transposeoneszerosrN   )F)6r   
__module____qualname____doc__rB   _numpy_known_functionsrE   _numpy_known_constants_kcrG   rV   rb   rg   rj   rr   rv   ry   r{   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  _add_einsum
_transpose_ones_zerosr   r   _print_lowergamma_print_uppergamma_print_fresnelc_print_fresnels__classcell__rJ   s   @r   r<   r<   #   s        
 G
 C
 C, , , , , ,Q Q QO O OB B B
' ' '
2 2 29 9 9
% % %% % %A A A( ( (( ( (' ' 'B B B' ' 'D D D
     &/ / / / /"I I IH H H@ @ @V V V VC C CC C Cd d dc c c; ; ;c c ch h h= = =p p pE E E< < < DGJEF#8#8!6O!6OOOOOr   r<   _print_erferfcbesseljjvbesselyyvbesseliivbesselkkvcosm1	factorialgammaloggammagammalndigammapsiRisingFactorialpochjacobieval_jacobi
gegenbauereval_gegenbauer
chebyshevteval_chebyt
chebyshevueval_chebyulegendreeval_legendreeval_hermiteeval_laguerreeval_genlaguerrebetalambertw)hermitelaguerreassoc_laguerrer9  LambertWgolden_ratio)GoldenRatior1   c                      i | ]\  }}|d |z   S )zscipy.special.r   r   s      r   r8   r8   5  s$    ffftq!!.2fffr   c                      i | ]\  }}|d |z   S )zscipy.constants.r   r   s      r   r8   r8   6  s$    jjjA!014jjjr   c                        e Zd Zi ej        eZi ej        eZd fd	Zd Z	e	Z
d Zd Zd Zd Zd Zd	 Zd
 Zd Zd Zd Zd Zd Z xZS )SciPyPrinterNc                 Z    t                                          |           d| _        d S )Nr?   zPython with SciPy and NumPy)rF   rG   rC   rH   s     r   rG   zSciPyPrinter.__init__=  s)    (+++5r   c                 N   g g g }}}|                                                                 D ]G\  \  }}}|                    |           |                    |           |                    |           Hd                    |                     d          ||||j                  S )Nz+{name}(({data}, ({i}, {j})), shape={shape})zscipy.sparse.coo_matrix)namedatar[   r}   rn   )todokitemsappendrA   re   rn   )rI   r`   r[   r}   rH  rcr   s           r   _print_SparseRepMatrixz#SciPyPrinter._print_SparseRepMatrixA  s    Rd1++-- 	 	IFQAHHQKKKHHQKKKKKNNNN<CC$$%>??atz D 
 
 	
r   c           	         d                     |                     d          |                     |j        d                   |                     |j        d                   |                     |j        d                             S )Nz{0}({2}, {1}, {3})zscipy.special.lpmvr   r   r   rA   re   rP   r_   rf   s     r   _print_assoc_legendrez"SciPyPrinter._print_assoc_legendreP  sk    #** 455KK	!%%KK	!%%KK	!%%	' ' 	'r   c           	          d                     |                     d          |                     d          |                     |j        d                   |                     |j        d                             S )N{0}({2})*{1}({2}, {3})scipy.special.gammazscipy.special.gammaincr   r   rP  rf   s     r   r  zSciPyPrinter._print_lowergammaW  sh    '.. 566 899KK	!%%KK	!%%	' ' 	'r   c           	          d                     |                     d          |                     d          |                     |j        d                   |                     |j        d                             S )NrS  rT  zscipy.special.gammainccr   r   rP  rf   s     r   r  zSciPyPrinter._print_uppergamma^  sh    '.. 566 9::KK	!%%KK	!%%	' ' 	'r   c                 &                          d          }                      d          } fd|j        D             }d| d|d          d|d          d|d          d	| d|d          d|d          d|d
          d| d|d          d|d          dS )Nscipy.special.betainczscipy.special.betac                 :    g | ]}                     |          S r   rO   r   s     r   r   z/SciPyPrinter._print_betainc.<locals>.<listcomp>h  s%    666SC  666r   rl   r   rL   r      z) - r   z))             * rm   )re   r_   )rI   r`   betaincr9  r_   s   `    r   _print_betainczSciPyPrinter._print_betaince  s   %%&=>>""#7886666DI666,7 , ,T!W , ,Q , ,47 , , , ,$q' , ,UYZ[U\ , ,`def`g , ,, ,1g, ,!%a, , , 	,r   c           
      J   d                     |                     d          |                     |j        d                   |                     |j        d                   |                     |j        d                   |                     |j        d                             S )Nz'{0}({1}, {2}, {4}) - {0}({1}, {2}, {3})rW  r   r   r   rY  rP  rf   s     r   _print_betainc_regularizedz'SciPyPrinter._print_betainc_regularizedl  s    8?? 788KK	!%%KK	!%%KK	!%%KK	!%%' ' 	'r   c                     d                     |                     d          |                     |j        d                             S )N	{}({})[0]scipy.special.fresnelr   rP  rf   s     r   r  zSciPyPrinter._print_fresnelst  A    !!##$;<<DIaL))+ + 	+r   c                     d                     |                     d          |                     |j        d                             S )N	{}({})[1]r`  r   rP  rf   s     r   r  zSciPyPrinter._print_fresnelcy  ra  r   c                     d                     |                     d          |                     |j        d                             S )Nr_  scipy.special.airyr   rP  rf   s     r   _print_airyaizSciPyPrinter._print_airyai~  A    !!##$899DIaL))+ + 	+r   c                     d                     |                     d          |                     |j        d                             S )Nrc  re  r   rP  rf   s     r   _print_airyaiprimezSciPyPrinter._print_airyaiprime  rg  r   c                     d                     |                     d          |                     |j        d                             S )Nz	{}({})[2]re  r   rP  rf   s     r   _print_airybizSciPyPrinter._print_airybi  rg  r   c                     d                     |                     d          |                     |j        d                             S )Nz	{}({})[3]re  r   rP  rf   s     r   _print_airybiprimezSciPyPrinter._print_airybiprime  rg  r   c           	          t          |          \  }}t          |          dk    rA                     d          }dt          t	           j        |d                             z  }nI                     d          }d                    d                     fd|D                                 }d	                    |d                    t	           j        |                                         |j        d                   |          S )
Nr   zscipy.integrate.quadz%s, %sr   zscipy.integrate.nquadrX   rL   c              3   b   K   | ])}d t          t          j        |                    z  V  *dS )z(%s, %s)N)tupler   rP   )r   lrI   s     r   rR   z/SciPyPrinter._print_Integral.<locals>.<genexpr>  sU       0I 0I<=
U3t{A#6#67770I 0I 0I 0I 0I 0Ir   z{}(lambda {}: {}, {})[0])	r   r   re   rp  r   rP   rA   rS   r_   )rI   r*   integration_varslimits
module_str	limit_strs   `     r   _print_IntegralzSciPyPrinter._print_Integral  s   #:1#=#= &v;;! 	J,,-CDDJ 5T[&))D)D#E#EEII,,-DEEJdii 0I 0I 0I 0IAG0I 0I 0I 'I 'I J JI *00		#dk+;<<==AF1I&&	  	r   rN   )r   r  r  r<   rE   _scipy_known_functionsr  _scipy_known_constantsrG   rN  _print_ImmutableSparseMatrixrQ  r  r  r[  r]  r  r  rf  ri  rk  rm  rv  r  r  s   @r   rD  rD  8  s.       
8\
8!7
8C
8\
8!7
8C6 6 6 6 6 6

 

 

 $: ' ' '' ' '' ' ', , ,' ' '+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
      r   rD  c                      i | ]\  }}|d |z   S zcupy.r   r   s      r   r8   r8     "    TTTTQWq[TTTr   c                      i | ]\  }}|d |z   S r{  r   r   s      r   r8   r8     r|  r   c                   0     e Zd ZdZdZeZeZd fd	Z	 xZ
S )CuPyPrinterz`
    CuPy printer which handles vectorized piecewise functions,
    logical operators, etc.
    cupyNc                 L    t                                          |           d S Nr?   rF   rG   rH   s     r   rG   zCuPyPrinter.__init__  $    (+++++r   rN   )r   r  r  r	  rB   _cupy_known_functionsrE   _cupy_known_constantsr  rG   r  r  s   @r   r  r    sX         
 G
C
C, , , , , , , , , ,r   r  c                      i | ]\  }}|d |z   S z
jax.numpy.r   r   s      r   r8   r8     #    WWW1<!+WWWr   c                      i | ]\  }}|d |z   S r  r   r   s      r   r8   r8     r  r   c                   <     e Zd ZdZdZeZeZd fd	Z	d Z
d Z xZS )
JaxPrinterz_
    JAX printer which handles vectorized piecewise functions,
    logical operators, etc.
    z	jax.numpyNc                 L    t                                          |           d S r  r  rH   s     r   rG   zJaxPrinter.__init__  r  r   c                      d                                           j        dz                                   j                  d                     fd|j        D                                 S )r   {}({}.asarray([{}]), axis=0)z.allr   c              3   B   K   | ]}                     |          V  d S rN   rO   rZ   s     r   rR   z(JaxPrinter._print_And.<locals>.<genexpr>  -      77T[[^^777777r   r   rf   s   ` r   r   zJaxPrinter._print_And  l    -44v 566--HH7777TY77777
 
 	
r   c                      d                                           j        dz                                   j                  d                     fd|j        D                                 S )r   r  z.anyr   c              3   B   K   | ]}                     |          V  d S rN   rO   rZ   s     r   rR   z'JaxPrinter._print_Or.<locals>.<genexpr>  r  r   r   rf   s   ` r   r   zJaxPrinter._print_Or  r  r   rN   )r   r  r  r	  rB   _jax_known_functionsrE   _jax_known_constantsr  rG   r   r   r  r  s   @r   r  r    sv          G
C
C, , , , , ,
 
 

 
 
 
 
 
 
r   r  N)'
sympy.corer   sympy.core.functionr   sympy.core.powerr   pycoder   r   r	   r
   r   r   codeprinterr   splitr   rJ  	_in_numpydict_known_functions_numpy_known_constants_numpyr
  r  r<   r   setattrconst_known_functions_scipy_special _known_constants_scipy_constantsrw  rx  rD  r  r  r  r  r  r  r   r   r   <module>r     s         & & & & & &             K  K  K  K  K  K  K  K  K  K  K  K  K  K  K  K $ $ $ $ $ $ 499;;XX ; 5 ; = =XXX	i  , ,    
   VU6L6R6R6T6TUUU UU6L6R6R6T6TUUU l7 l7 l7 l7 l7<!2 l7 l7 l7\ # ? ?DGL*D**,=>>>># A AEGL+E++-?@@@@"	5"
F" t" t	"
 t" t" W" " W" 	" u" v" m" #" -"  -!"" #"$ (-" " " 4 "
$ $   gf?]?c?c?e?efff jjAaAgAgAiAijjj j j j j j< j j jZ # ? ?DGL*D**,=>>>># A AEGL+E++-?@@@@ UT5K5Q5Q5S5STTT TT5K5Q5Q5S5STTT , , , , ,, , , , " > >DGK)4))+<====" @ @EGK*5**,>???? XW8N8T8T8V8VWWW WW8N8T8T8V8VWWW 
 
 
 
 
 
 
 
< ! = =DGJ($((*;<<<<! ? ?EGJ)%))+=>>>>? ?r   