o
    oh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   67z-1)r)   r    r-   r-   s/var/www/html/construction_image-detection-poc/venv/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   r8   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   r7   yr   r   r   r   r   r-   r-   r-   r.   test_Relational   s   r:   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   r7   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 )Nr1   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)   r7   r9   r   r    r   r   r   )r>   r-   r-   r.   test_Pow-   s   *rB   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)   r7   r9   r-   r-   r-   r.   test_basic_ops<   s   rD   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)   r7   r   r   Halfr   r-   r-   r-   r.   test_1_over_x_and_sqrtC   s   ,0.,rF   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 )Nr1   z3*xzPi*xz3/xzPi/xz(1/3)*xzx/PirC   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)   r7   r   r9   zr   r   r-   r-   r-   r.   test_mix_number_mult_symbolsQ   s0    *rI   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 )	Nr1   zPi^3r=   zx^2zx^(Pi^3)zx^yzx^(y^z)z(x^y)^z)r)   r   r7   r9   rH   r-   r-   r-   r.   test_mix_number_pow_symbolsl   s   rJ   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IrG   z5*Ir1   r=   z(3/2)*I   z3 + 4*I)r   r)   )rK   r-   r-   r.   	test_imagw   s
   rM   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NaNExp1r   r-   r-   r-   r.   test_constants   s   rT   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   rU   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)   r7   r9   rH   r-   r-   r-   r.   test_boolean   s   rV   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)r1   )	r)   r"   r   r7   r;   r   r   r   r9   Aexpectedr-   r-   r.   test_Matrices   s2   r[   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   r\   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=   r1   rG   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   r7   r   r)   TrY   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=   r1   rG   zGMatrix([[1, sin(2/x), (3/5)*Pi/x], [1, 2, x*y]], storage = rectangular))r"   r   r7   r   r9   r)   rX   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)integerrY   BzA.BzB.Ar=   z2*A.Bz2*B.Ar1   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$   r7   r   rE   )ra   rY   rc   r-   r-   r.   test_MatrixSymbol   s   rd   c                   C   s0   t dtd dksJ t ttdksJ d S )N   r1   z=6*Matrix([[1, 0, 0], [0, 1, 0], [0, 0, 1]], storage = sparse)zMatrix(x, shape = identity))r)   r$   r7   r-   r-   r-   r.   test_special_matrices   s   rf   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=   r1   rL   rG   re   r2      r4   rW      z)[1, 2, 3, [4, 5, [6, 7]], 8, [9, 10], 11])r?   r=   )r1   rL   z[1, 2, [3, 4]]z[1])r?   r?   r=   r1   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	   r7   r9   r!   r"   r-   r-   r-   r.   test_containers   s   ""rj   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)   r7   r9   r   )sourcerZ   r-   r-   r.   test_maple_noninline   s   ro   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 )Nri   arl   z/a := Matrix([[1, 2, 3]], storage = rectangular)r?   r=   r1   rL   rY   z4A := Matrix([[1, 2], [3, 4]], storage = rectangular)r"   r)   r^   r-   r-   r.   test_maple_matrix_assign_to   s   rs   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 )Nri   rc   r?   r1   Cr=   rq   z/B := Matrix([[1, 2, 3]], storage = rectangular)c                      s   t  tdS Nrq   )r)   r7   r-   r^   r-   r.   <lambda>      z2test_maple_matrix_assign_to_more.<locals>.<lambda>c                      s   t  dS ru   r(   r-   rY   rt   r-   r.   rv     rw   )r"   r#   r)   r   
ValueError)rc   r-   rx   r.    test_maple_matrix_assign_to_more   s   rz   c                  C   s$   t dgg} t| dddksJ d S )Nr1   rc   rq   z)B := Matrix([[3]], storage = rectangular)rr   r^   r-   r-   r.   test_maple_matrix_1x1	  s   r{   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?   r1   z%sin(AA[1, 2]) + AA[1, 1]^2 + AA[1, 3]zAA[1, 1] + AA[1, 2] + AA[1, 3])r"   r7   r9   r)   r#   r   sum)rY   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 )NrG   re   rW   )r=   r=      )r?   r=      )r?   r1      )r   r1   )r1   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&   r7   r9   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   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 )	NrY   r?   r1   rc   r|   zA[1, 1]z	3*A[1, 1]zA[1, 1] - B[1, 1])r#   r)   )rY   rc   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 )NrY   r1   rc   vr?   hzA*Bz(A*B).vz	h.(A*B).vz(A*B).Az	x*y*(A*B))r#   r%   r)   r7   r9   )rY   rc   r   r   rt   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)rrq   zr := piecewise(x < 1, x, x^2)r1   rL   rG   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.   rv   d  s    z&test_maple_piecewise.<locals>.<lambda>)r   r7   r)   r   r   ry   )rZ   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)r1   z(1/3)*piecewise(x < 1, x, x^2))r   r7   r)   r9   )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)   r7   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   r7   r   r-   r-   r-   r.   test_automatic_rewritesv  r0   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'   r7   r9   r-   r-   r-   r.   test_specfun{  s   r   N)T
sympy.corer   r   r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   sympy.functionsr   r   r   r   r   r   r   r   sympy.testing.pytestr   sympy.utilities.lambdifyr    sympy.matricesr!   r"   r#   r$   r%   r&   sympy.functions.special.besselr'   sympy.printing.mapler)   r7   r9   rH   r/   r8   r:   r<   rB   rD   rF   rI   rJ   rM   rT   rU   rV   r[   r\   r_   r`   rd   rf   rj   ro   rs   rz   r{   r   r   r   r   r   r   r   r   r   r   r   r-   r-   r-   r.   <module>   sX   D  ( 			

	
	