o
    8Va2                     @   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 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-Z.d
d Z/dd 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/ ZAd0d1 ZBd2d3 ZCd4d5 ZDd6d7 ZEd8d9 ZFd:d; ZGd<d= ZHd>d? ZId@dA ZJdBdC ZKdDdE ZLdFdG ZMdHdI ZNdJdK ZOdLdM ZPdNS )O    )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)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*   A/usr/lib/python3/dist-packages/sympy/printing/tests/test_maple.pytest_Integer   s   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   r4   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   r3   yr   r   r   r   r   r*   r*   r*   r+   test_Relational   s   r6   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   r3   r   absr   r*   r*   r*   r+   test_Function'   s   r8   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 )Nr-   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)Zevaluater)   z
-2*x/(y*y))r'   r3   r5   r   r   r   r   r   )r:   r*   r*   r+   test_Pow-   s   *r=   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'   r3   r5   r*   r*   r*   r+   test_basic_ops<   s   r?   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'   r3   r   r   Halfr   r*   r*   r*   r+   test_1_over_x_and_sqrtC   s   ,0.,rA   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 )Nr-   z3*xzPi*xz3/xzPi/xz(1/3)*xzx/Pir>   z3*x*yz3*Pi*x*yzx/yz3*x/yzx*y/zzx*z/yr;   z1/(x*y)r9   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'   r3   r   r5   zr   r   r*   r*   r*   r+   test_mix_number_mult_symbolsQ   s0    *rD   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 )	Nr-   zPi^3r9   zx^2zx^(Pi^3)zx^yzx^(y^z)z(x^y)^z)r'   r   r3   r5   rC   r*   r*   r*   r+   test_mix_number_pow_symbolsl   s   rE   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IrB   z5*Ir-   r9   z(3/2)*I   z3 + 4*I)r   r'   )rF   r*   r*   r+   	test_imagw   s
   rH   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 )NZPiZinfinityz	-infinityZ	undefinedzexp(1)r;   )r'   r   r   r   ZNegativeInfinityZNaNZExp1r   r*   r*   r*   r+   test_constants   s   rI   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 )Nr9   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   rJ   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 && yzx || yz!xzx && y && zzx || y || zzz || x && yzz && (x || y))r'   r3   r5   rC   r*   r*   r*   r+   test_boolean   s   rK   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)r9   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)r-   )	r'   r    r   r3   r7   r   r   r   r5   Aexpectedr*   r*   r+   test_Matrices   s2   rP   c                   C   s   t ttddksJ d S )Nr9   z*Matrix([[1, 0], [0, 1]], storage = sparse))r'   r$   r"   r*   r*   r*   r+   test_SparseMatrices   s   rQ   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;   r9   r-   rB   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   r3   r   r'   TrN   r*   r*   r+   test_vector_entries_hadamard   s   $rT   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;   r9   r-   rB   zGMatrix([[1, sin(2/x), (3/5)*Pi/x], [1, 2, x*y]], storage = rectangular))r    r   r3   r   r5   r'   rM   r*   r*   r+   "test_Matrices_entries_not_hadamard   s   0rU   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)ZintegerrN   BzA.BzB.Ar9   z2*A.Bz2*B.Ar-   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"   r3   r   r@   )rV   rN   rW   r*   r*   r+   test_MatrixSymbol   s   rX   c                   C   s0   t dtd dksJ t ttdksJ d S )N   r-   z=6*Matrix([[1, 0, 0], [0, 1, 0], [0, 0, 1]], storage = sparse)zMatrix(x, shape = identity))r'   r"   r3   r*   r*   r*   r+   test_special_matrices   s   rZ   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;   r9   r-   rG   rB   rY   r.      r0   rL      z)[1, 2, 3, [4, 5, [6, 7]], 8, [9, 10], 11])r;   r9   )r-   rG   z[1, 2, [3, 4]]z[1])r;   r;   r9   r-   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	   r3   r5   r   r    r*   r*   r*   r+   test_containers   s   ""r^   c                  C   s*   t tt t ddd} d}| |ksJ d S )NmeF)	assign_toZinlinezme := (x + y)/Catalan)r'   r3   r5   r   )sourcerO   r*   r*   r+   test_maple_noninline   s   rb   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 )Nr]   ar`   z/a := Matrix([[1, 2, 3]], storage = rectangular)r;   r9   r-   rG   rN   z4A := Matrix([[1, 2], [3, 4]], storage = rectangular)r    r'   rS   r*   r*   r+   test_maple_matrix_assign_to   s   rf   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 )Nr]   rW   r;   r-   Cr9   rd   z/B := Matrix([[1, 2, 3]], storage = rectangular)c                      s   t  tdS Nrd   )r'   r3   r*   rS   r*   r+   <lambda>      z2test_maple_matrix_assign_to_more.<locals>.<lambda>c                      s   t  dS rh   r&   r*   rN   rg   r*   r+   ri     rj   )r    r!   r'   r   
ValueError)rW   r*   rk   r+    test_maple_matrix_assign_to_more   s   rm   c                  C   s$   t dgg} t| dddksJ d S )Nr-   rW   rd   z)B := Matrix([[3]], storage = rectangular)re   rS   r*   r*   r+   test_maple_matrix_1x1	  s   rn   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 )Nr9   r   r   )r   r;   )r   r9   zx^2 + x*y + 2AAr;   r-   z%sin(AA[1, 2]) + AA[1, 1]^2 + AA[1, 3]zAA[1, 1] + AA[1, 2] + AA[1, 3])r    r3   r5   r'   r!   r   sum)rN   rp   r*   r*   r+   test_maple_matrix_elements  s   ("rr   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   rs   rt   r*   r*   r*   r+   test_maple_boolean  s   ru   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 )NrB   rY   rL   )r9   r9      )r;   r9      )r;   r-      )r   r-   )r-   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$   r3   r5   r'   )Mr*   r*   r+   test_sparse!  s   rz   c                   C   s   t tjdks	J d S )Nz/# Not supported in maple:
# ComplexInfinity
zoo)r'   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 )	NrN   r;   r-   rW   ro   zA[1, 1]z	3*A[1, 1]zA[1, 1] - B[1, 1])r!   r'   )rN   rW   Fr*   r*   r+   test_MatrixElement_printing:  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 )NrN   r-   rW   vr;   hzA*Bz(A*B).vz	h.(A*B).vz(A*B).Az	x*y*(A*B))r!   r#   r'   r3   r5   )rN   rW   r~   r   rg   r*   r*   r+   test_hadamardG  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;   r9   Tzpiecewise(x < 1, x, x^2)rrd   zr := piecewise(x < 1, x, x^2)r-   rG   rB   z2piecewise(x < 1, x^2, x < 2, x^3, x < 3, x^4, x^5)zr := r   c                      s   t  S )Nr&   r*   exprr*   r+   ri   h  s    z&test_maple_piecewise.<locals>.<lambda>)r   r3   r'   r   r   rl   )rO   r*   r   r+   test_maple_piecewiseZ  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;   r9   Tz2*piecewise(x < 1, x, x^2)zpiecewise(x < 1, x, x^2)/xzpiecewise(x < 1, x, x^2)/(x*y)r-   z(1/3)*piecewise(x < 1, x, x^2))r   r3   r'   r5   )Zpwr*   r*   r+    test_maple_piecewise_times_constk  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)r9   zdiff(f(x), x$2))r   r'   r3   Zdiff)r   r*   r*   r+   test_maple_derivativest  s    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%   r3   r5   r*   r*   r*   r+   test_specfunz  s   r   N)QZ
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   Zsympy.testing.pytestr   Zsympy.utilities.lambdifyr   Zsympy.matricesr   r    r!   r"   r#   r$   Zsympy.functions.special.besselr%   Zsympyr'   r3   r5   rC   r,   r4   r6   r8   r=   r?   rA   rD   rE   rH   rI   rJ   rK   rP   rQ   rT   rU   rX   rZ   r^   rb   rf   rm   rn   rr   ru   rz   r{   r}   r   r   r   r   r   r*   r*   r*   r+   <module>   sV   D    			

	
		