o
    GZh3                     @   s  d dl mZmZmZmZmZmZmZmZm	Z	m
Z
mZmZmZmZmZ d dl mZmZmZmZmZmZ d dlmZmZmZmZmZmZmZ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 dl,m-Z- ed	\Z.Z/Z0d
d Z1dd Z2dd Z3dd Z4dd Z5dd Z6dd Z7dd Z8dd Z9dd Z:dd Z;d d! Z<d"d# Z=d$d% Z>d&d' Z?d(d) Z@d*d+ ZAd,d- ZBd.d/ ZCd0d1 ZDd2d3 ZEd4d5 ZFd6d7 ZGd8d9 ZHd:d; ZId<d= ZJd>d? ZKd@dA ZLdBdC ZMdDdE ZNdFdG ZOdHdI ZPdJdK ZQdLdM ZRdNdO ZSdPS )Q    )SpioosymbolsFunctionRationalIntegerTupleSymbolEqNeLeLtGtGe)
EulerGammaGoldenRatioCatalanLambdaMulPow)	Piecewisesqrtceilingexpsincossinclucas)raises)implemented_function)eyeMatrixMatrixSymbolIdentityHadamardProductSparseMatrix)besseli
maple_codezx,y,zc                   C   s,   t tddks
J t tddksJ d S )NC   Z67z-1)r)   r    r,   r,   N/var/www/auris/lib/python3.10/site-packages/sympy/printing/tests/test_maple.pytest_Integer      r.   c                   C   s   t tdddksJ t tdddksJ t tdddks!J t td	ddks,J t ttdd d
ks9J t tddt dksFJ d S )N      z3/7   	   2iz-3/7zx + 3/7z(3/7)*x)r)   r   xr,   r,   r,   r-   test_Rational   s   r7   c                   C   s   t tttdksJ t tttdksJ t tttdks!J t tttdks,J t tttdks7J t tttdksBJ d S )Nzx = yzx <> yzx <= yzx < yzx > yzx >= y)	r)   r   r6   yr   r   r   r   r   r,   r,   r,   r-   test_Relational   s   r9   c                   C   sH   t tttt dksJ t ttdksJ t ttdks"J d S )Nzsin(x)^cos(x)zabs(x)zceil(x))r)   r   r6   r   absr   r,   r,   r,   r-   test_Function'   s   r;   c               
   C   s   t td dks
J t ttd  dksJ t td t dks"J t ttdd dks/J tdttdt } t d| td	 ttt    td t  d
ksSJ t tdtttttddddddddkskJ d S )Nr0   zx^3zx^(y^3)z(x^3)^y   zx^(2/3)g   g      @z(3.5*2*x)^(-x + y^x)/(x^2 + y)F)evaluater+   z
-2*x/(y*y))r)   r6   r8   r   r    r   r   r   )r=   r,   r,   r-   test_Pow-   s   *rA   c                   C   sR   t tt dks
J t tt dksJ t tt dksJ t t dks'J d S )Nx*yzx + yzx - yz-x)r)   r6   r8   r,   r,   r,   r-   test_basic_ops<   s   rC   c                   C   s"  t dt dks
J t td t td   krdks J  J t dtt dks,J t ttj  t td   krAdksDJ  J t ttdksNJ t ttj t td   krbdkseJ  J t dt d	ksoJ t td t td   krd	ksJ  J t td d
ksJ d S )Nr>   z1/xr+   g      z	1/sqrt(x)g      zsqrt(x)g      ?z1/Piz
1/sqrt(Pi))r)   r6   r   r   Halfr   r,   r,   r,   r-   test_1_over_x_and_sqrtC   s   ,0.,rE   c                   C   sJ  t dt dks
J t tt dksJ t dt dksJ t tt dks(J t td dks2J t tt dks<J t tt dksFJ t dt t d	ksRJ t dt t t d
ks`J t tt dksjJ t dt t dksvJ t tt t dksJ t tt t dksJ t dt t dksJ t dt t t t dksJ t dt t dksJ t tdd dksJ t tdd t dksJ t tt t dksJ t tt t dksJ t tt tt  dksJ t tt t dksJ t td t dksJ t tdd t t t dks#J d S )Nr0   z3*xzPi*xz3/xzPi/xz(1/3)*xzx/PirB   z3*x*yz3*Pi*x*yzx/yz3*x/yzx*y/zzx*z/yr>   z1/(x*y)r<   z2*Pi*x/(y*z)z3*Pi/x   z3/5z(3/5)*xzx/(y*z)z	(x + y)/zz(x + y)/(x + z)z(x + y)/gammaz
(1/3)*x/Piz(3/5)*x*y/Pi)r)   r6   r   r8   zr   r   r,   r,   r,   r-   test_mix_number_mult_symbolsQ   s0    *rH   c                   C   s   t td dks
J t td dksJ t ttd  dks J t tt dks*J t ttt  dks6J t tt t dksBJ d S )	Nr0   zPi^3r<   zx^2zx^(Pi^3)zx^yzx^(y^z)z(x^y)^z)r)   r   r6   r8   rG   r,   r,   r,   r-   test_mix_number_pow_symbolsl   s   rI   c                  C   sd   t d} t| dksJ td|  dksJ tt dd |  dks$J tdd|   dks0J d S )	NIrF   z5*Ir0   r<   z(3/2)*I   z3 + 4*I)r   r)   )rJ   r,   r,   r-   	test_imagw   s
   rL   c                   C   s   t tdksJ t tdksJ t t dksJ t tjdks"J t tjdks+J t tjdks4J t tddks>J d S )NPiinfinityz	-infinity	undefinedzexp(1)r>   )r)   r   r   r   NegativeInfinityNaNZExp1r   r,   r,   r,   r-   test_constants   s   rR   c                   C   s@   t dt dks
J t dt dksJ t dt dksJ d S )Nr<   z2*(1/2 + (1/2)*sqrt(5))z	2*Catalanz2*gamma)r)   r   r   r   r,   r,   r,   r-   test_constants_other   s   rS   c                   C   s   t tt@ dks
J t ttB dksJ t t dksJ t tt@ t@ dks)J t ttB tB dks5J t tt@ tB dksAJ t ttB t@ dksMJ d S )Nzx and yzx or yznot xzx and y and zzx or y or zzz or x and yzz and (x or y))r)   r6   r8   rG   r,   r,   r,   r-   test_boolean   s   rT   c                  C   s   t tdddgdksJ tdttd ttgddtgdtdttgg} d}t | |ks1J t | d d df dks?J t | dd d f dksMJ t tttt t ggd	ks^J t tddg d
ksjJ t tddg d
ksvJ d S )Nr>   
   z%Matrix([[10]], storage = rectangular)r<   r   z\Matrix([[1, sin((1/2)*x), abs(x)], [0, 1, Pi], [0, exp(1), ceil(x)]], storage = rectangular)z.Matrix([[1], [0], [0]], storage = rectangular)z:Matrix([[1, sin((1/2)*x), abs(x)]], storage = rectangular)z/Matrix([[x, x - y, -y]], storage = rectangular)z!Matrix([], storage = rectangular)r0   )	r)   r"   r   r6   r:   r   r   r   r8   Aexpectedr,   r,   r-   test_Matrices   s2   rY   c                   C   s   t ttddksJ d S )Nr<   z*Matrix([[1, 0], [0, 1]], storage = sparse))r)   r&   r$   r,   r,   r,   r-   test_SparseMatrices   s   rZ   c                  C   sJ   t dtdt dt t d gg} t| dksJ t| jdks#J d S )Nr>   r<   r0   rF   z:Matrix([[1, sin(2/x), (3/5)*Pi/x]], storage = rectangular)z>Matrix([[1], [sin(2/x)], [(3/5)*Pi/x]], storage = rectangular))r"   r   r6   r   r)   TrW   r,   r,   r-   test_vector_entries_hadamard   s   $r]   c                  C   sH   t dtdt dt t d gddtt gg} d}t| |ks"J d S )Nr>   r<   r0   rF   zGMatrix([[1, sin(2/x), (3/5)*Pi/x], [1, 2, x*y]], storage = rectangular))r"   r   r6   r   r8   r)   rV   r,   r,   r-   "test_Matrices_entries_not_hadamard   s   0r^   c                  C   s   t ddd} td| | }td| | }t|| dksJ t|| dks&J td| | d	ks2J t|d | d
ks>J t||dt|    dksNJ t|td  dksZJ t|d dksdJ t|tj dksoJ d S )NnT)integerrW   BzA.BzB.Ar<   z2*A.Bz2*B.Ar0   z%A.(3*Matrix(n, shape = identity) + B)zMatrixPower(A, x^2)zMatrixPower(A, 3)zMatrixPower(A, 1/2))r
   r#   r)   r$   r6   r   rD   )r_   rW   ra   r,   r,   r-   test_MatrixSymbol   s   rb   c                   C   s0   t dtd dksJ t ttdksJ d S )N   r0   z=6*Matrix([[1, 0, 0], [0, 1, 0], [0, 0, 1]], storage = sparse)zMatrix(x, shape = identity))r)   r$   r6   r,   r,   r,   r-   test_special_matrices   s   rd   c                   C   s   t dddddddggdd	d
gdgdksJ t ddksJ t dgdks'J t ddks/J t tg d dks;J t dtt dtd ffdksLJ t dtdtddg g fdks^J d S )Nr>   r<   r0   rK   rF   rc   r1      r3   rU      z)[1, 2, 3, [4, 5, [6, 7]], 8, [9, 10], 11])r>   r<   )r0   rK   z[1, 2, [3, 4]]z[1])r>   r>   r<   r0   z	[1, 2, 3]z[1, x*y, [3, x^2]]r   zl[1, Matrix([[1, 0, 0], [0, 1, 0], [0, 0, 1]], storage = rectangular), Matrix([], storage = rectangular), []])r)   r	   r6   r8   r!   r"   r,   r,   r,   r-   test_containers   s   ""rh   c                  C   s*   t tt t ddd} d}| |ksJ d S )NmeF)	assign_toinlinezme := (x + y)/Catalan)r)   r6   r8   r   )sourcerX   r,   r,   r-   test_maple_noninline   s   rm   c                  C   sN   t g dg} t| dddksJ t ddgddgg} t| d	dd
ks%J d S )Nrg   arj   z/a := Matrix([[1, 2, 3]], storage = rectangular)r>   r<   r0   rK   rW   z4A := Matrix([[1, 2], [3, 4]], storage = rectangular)r"   r)   r\   r,   r,   r-   test_maple_matrix_assign_to   s   rq   c                     sd   t g dg tddd} tdddt | ddksJ tt fd	d
 tt fdd
 d S )Nrg   ra   r>   r0   Cr<   ro   z/B := Matrix([[1, 2, 3]], storage = rectangular)c                      s   t  tdS Nro   )r)   r6   r,   r\   r,   r-   <lambda>      z2test_maple_matrix_assign_to_more.<locals>.<lambda>c                      s   t  dS rs   r(   r,   rW   rr   r,   r-   rt     ru   )r"   r#   r)   r   
ValueError)ra   r,   rv   r-    test_maple_matrix_assign_to_more   s   rx   c                  C   s$   t dgg} t| dddksJ d S )Nr0   ra   ro   z)B := Matrix([[3]], storage = rectangular)rp   r\   r,   r,   r-   test_maple_matrix_1x1	  s   ry   c                  C   s   t tdtt gg} t| d d | d  | d  dksJ tddd}t|dks,J t|d d t|d  |d  d	ksBJ tt|d
ksLJ d S )Nr<   r   r   )r   r>   )r   r<   zx^2 + x*y + 2AAr>   r0   z%sin(AA[1, 2]) + AA[1, 1]^2 + AA[1, 3]zAA[1, 1] + AA[1, 2] + AA[1, 3])r"   r6   r8   r)   r#   r   sum)rW   r{   r,   r,   r-   test_maple_matrix_elements  s   ("r}   c                   C   sH   t ddksJ t tjdksJ t ddksJ t tjdks"J d S )NTtrueFfalse)r)   r   r~   r   r,   r,   r,   r-   test_maple_boolean  s   r   c                  C   sL   t ddi } d| d< d| d< d| d< d	| d
< tt | d< t| dks$J d S )NrF   rc   rU   )r<   r<      )r>   r<      )r>   r0      )r   r0   )r0   r   zMatrix([[0, 0, 0, 30, 0, 0], [0, 0, 20, 22, 0, 0], [0, 0, 10, 0, 0, 0], [x*y, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]], storage = sparse))r&   r6   r8   r)   )Mr,   r,   r-   test_sparse!  s   r   c                   C   s8   t t ttj W d    d S 1 sw   Y  d S N)r   NotImplementedErrorr)   r   ZComplexInfinityr,   r,   r,   r-   test_maple_not_supported1  s   
"r   c                  C   sd   t ddd} t ddd}t| d dksJ td| d  dks"J | | }t|d dks0J d S )	NrW   r>   r0   ra   rz   zA[1, 1]z	3*A[1, 1]zA[1, 1] - B[1, 1])r#   r)   )rW   ra   Fr,   r,   r-   test_MatrixElement_printing6  s   r   c                  C   s   t ddd} t ddd}t ddd}t ddd}t| |}t|dks%J t|| dks/J t|| | d	ks;J t||  d
ksEJ t|t t dksQJ d S )NrW   r0   ra   vr>   hzA*Bz(A*B).vz	h.(A*B).vz(A*B).Az	x*y*(A*B))r#   r%   r)   r6   r8   )rW   ra   r   r   rr   r,   r,   r-   test_hadamardC  s   
r   c                     s   t ttdk ftd df t dksJ t dddksJ t td tdk ftd tdk ftd	 tdk ftd
 df d} t | ksFJ t ddd|  ksRJ t ttdk ftd tdkftttdkf tt fdd d S )Nr>   r<   Tzpiecewise(x < 1, x, x^2)rro   zr := piecewise(x < 1, x, x^2)r0   rK   rF   z2piecewise(x < 1, x^2, x < 2, x^3, x < 3, x^4, x^5)zr := r   c                      s   t  S r   r(   r,   exprr,   r-   rt   d  s    z&test_maple_piecewise.<locals>.<lambda>)r   r6   r)   r   r   rw   )rX   r,   r   r-   test_maple_piecewiseV  s   
:,r   c                  C   sr   t ttdk ftd df} td|  dksJ t| t dks!J t| tt  dks-J t| d dks7J d S )	Nr>   r<   Tz2*piecewise(x < 1, x, x^2)zpiecewise(x < 1, x, x^2)/xzpiecewise(x < 1, x, x^2)/(x*y)r0   z(1/3)*piecewise(x < 1, x, x^2))r   r6   r)   r8   )pwr,   r,   r-    test_maple_piecewise_times_constg  s
   r   c                  C   sB   t d} t| ttdksJ t| ttddksJ d S )Nfzdiff(f(x), x)r<   zdiff(f(x), x$2))r   r)   r6   diff)r   r,   r,   r-   test_maple_derivativesp  s    r   c                   C   s,   t ttdks
J t ttdksJ d S )Nz,(2^(-x)*((1 - sqrt(5))^x + (1 + sqrt(5))^x))z (piecewise(x <> 0, sin(x)/x, 1)))r)   r   r6   r   r,   r,   r,   r-   test_automatic_rewritesv  r/   r   c                   C   s*   t ddksJ t tttdksJ d S )Nzasin(x)z	arcsin(x)zBesselI(x, y))r)   r'   r6   r8   r,   r,   r,   r-   test_specfun{  s   r   N)TZ
sympy.corer   r   r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   Zsympy.functionsr   r   r   r   r   r   r   r   Zsympy.testing.pytestr   Zsympy.utilities.lambdifyr    Zsympy.matricesr!   r"   r#   r$   r%   r&   Zsympy.functions.special.besselr'   Zsympy.printing.mapler)   r6   r8   rG   r.   r7   r9   r;   rA   rC   rE   rH   rI   rL   rR   rS   rT   rY   rZ   r]   r^   rb   rd   rh   rm   rq   rx   ry   r}   r   r   r   r   r   r   r   r   r   r   r,   r,   r,   r-   <module>   sX   D  ( 			

	
	