ó
    Š*£hK)  ã                   ó¾  • S r SSKJr  SSKJrJrJr  SSKJr  SSK	J
r
Jr  SSKrSr0 SS	_S
S_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_S S!_S"S#_S$S%_S&S'_S(S)_S*S+S,S-S.S/S0S1S2S3S4S5S6S7S8.Er\ H  r\\\'   M
     \R                   S9\R"                  S:\R$                  S;\R&                  S<\R(                  S=0rS>S?S@.r\R.                  /r " SA SB\5      rSESC jrSD rg)Fa	  
Maple code printer

The MapleCodePrinter converts single SymPy expressions into single
Maple expressions, using the functions defined in the Maple objects where possible.


FIXME: This module is still under actively developed. Some functions may be not completed.
é    )ÚS)ÚIntegerÚIntegerConstantÚequal_valued)ÚCodePrinter)Ú
precedenceÚ
PRECEDENCEN) ÚsinÚcosÚtanÚsecÚcscÚcotÚsinhÚcoshÚtanhÚsechÚcschÚcothÚexpÚfloorÚ	factorialÚ	bernoulliÚeulerÚ	fibonacciÚgcdÚlcmÚ	conjugateÚCiÚChiÚEiÚLiÚSiÚShiÚerfÚerfcÚharmonicÚLambertWÚsqrtÚAbsÚabsÚlogÚlnÚasinÚarcsinÚacosÚarccosÚatanÚarctanÚasecÚarcsecÚacscÚarccscÚacotÚarccotÚasinhÚarcsinhÚacoshÚarccoshÚatanhÚarctanhÚasechÚarcsechÚacschÚarccschÚacothÚarccothÚceilingÚceilÚMaxÚmaxÚMinÚminÚdoublefactorialÚ
pochhammerÚBesselIÚBesselJÚBesselKÚBesselYÚHankelH1ÚHankelH2ÚAiryAiÚAiryBiÚAppellF1ÚFresnelCÚFresnelSÚLerchPhi)Ú
factorial2ÚRisingFactorialÚbesseliÚbesseljÚbesselkÚbesselyÚhankelh1Úhankelh2ÚairyaiÚairybiÚappellf1ÚfresnelcÚfresnelsÚlerchphiÚPizexp(1)ÚCatalanÚgammaz(1/2 + (1/2)*sqrt(5))Ú=z<>)z==z!=c                   ó  ^ • \ rS rSrSrSrSrSSSS.r\" \	R                  40 S	S	S
.D6r
S(U 4S jjrS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS)S jrS rS  r S! r!S" r"S# r#S$ r$S% r%S& r&S'r'U =r($ )*ÚMapleCodePrinteréT   z>
Printer which converts a SymPy expression into a maple code.
Ú_mapleÚmapleÚandÚorznot )rq   rr   ÚnotT)ÚinlineÚallow_unknown_functionsc                 ó°   >• Uc  0 n[         TU ]  U5        [        [        5      U l        UR	                  S0 5      nU R                  R                  U5        g )NÚuser_functions)ÚsuperÚ__init__ÚdictÚknown_functionsÚgetÚupdate)ÚselfÚsettingsÚ	userfuncsÚ	__class__s      €ÚQ/home/mande/repo/quber/.venv/lib/python3.13/site-packages/sympy/printing/maple.pyry   ÚMapleCodePrinter.__init__f   sM   ø€ ØÑØˆHÜ‰Ñ˜Ô"Ü#¤OÓ4ˆÔØ—L‘LÐ!1°2Ó6ˆ	Ø×Ñ×#Ñ# IÕ.ó    c                 ó   • SU-  $ )Nz%s;© )r~   Ú
codestrings     r‚   Ú_get_statementÚMapleCodePrinter._get_statementn   s   € Ø�zÑ!Ð!r„   c                 ó$   • SR                  U5      $ )Nz# {})Úformat)r~   Útexts     r‚   Ú_get_commentÚMapleCodePrinter._get_commentq   s   € Ø�}‰}˜TÓ"Ð"r„   c                 ó^   • SR                  UUR                  U R                  S   5      5      $ )Nz	{} := {};Ú	precision)r‹   ÚevalfÚ	_settings)r~   ÚnameÚvalues      r‚   Ú_declare_number_constÚ&MapleCodePrinter._declare_number_constt   s.   € Ø×!Ñ! $Ø$)§K¡K°·±¸{Ñ0KÓ$LóNð 	Nr„   c                 ó   • U$ ©Nr†   )r~   Úliness     r‚   Ú_format_codeÚMapleCodePrinter._format_codex   s   € Øˆr„   c                 ó6   • U R                  [        U5      5      $ r˜   ©Ú_printÚlist©r~   Úexprs     r‚   Ú_print_tupleÚMapleCodePrinter._print_tuple{   ó   € Ø�{‰{œ4 ›:Ó&Ð&r„   c                 ó6   • U R                  [        U5      5      $ r˜   r�   r    s     r‚   Ú_print_TupleÚMapleCodePrinter._print_Tuple~   r¤   r„   c                 óŒ   • U R                  UR                  5      nU R                  UR                  5      nSR                  X#S9$ )Nz{lhs} := {rhs})ÚlhsÚrhs)rž   r©   rª   r‹   )r~   r¡   r©   rª   s       r‚   Ú_print_AssignmentÚ"MapleCodePrinter._print_Assignment�   s:   € Ø�k‰k˜$Ÿ(™(Ó#ˆØ�k‰k˜$Ÿ(™(Ó#ˆØ×&Ñ&¨3Ð&Ð8Ð8r„   c                 óø  • [        U5      n[        UR                  S5      (       a  SU R                  UR                  U5      -  $ [        UR                  S5      (       a  SU R                  UR                  5      -  $ [        UR                  S5      (       a  SU R                  UR                  5      -  $ SR                  U R                  UR                  U5      U R                  UR                  U5      S9$ )	Néÿÿÿÿz1/%sg      à?zsqrt(%s)g      à¿z
1/sqrt(%s)z{base}^{exp})Úbaser   )r   r   r   Úparenthesizer¯   rž   r‹   )r~   r¡   ÚkwargsÚPRECs       r‚   Ú
_print_PowÚMapleCodePrinter._print_Pow†   sË   € Ü˜$ÓˆÜ˜Ÿ™ "×%Ñ%Ø˜T×.Ñ.¨t¯y©y¸$Ó?Ñ@Ð@Ü˜$Ÿ(™( C×(Ñ(Ø §¡¨D¯I©IÓ 6Ñ6Ð6Ü˜$Ÿ(™( D×)Ñ)Ø $§+¡+¨d¯i©iÓ"8Ñ8Ð8à!×(Ñ(Ø×&Ñ& t§y¡y°$Ó7Ø×%Ñ% d§h¡h°Ó5ð )ð 7ð 7r„   c           
      óö  • UR                   S   R                  SLa6  UR                   S   R                  [        R                  :w  a  [	        S5      eUR                    VVs/ s Hi  u  p#USLaA  U[        R                  La.  SR                  U R                  U5      U R                  U5      S9OSR                  U R                  U5      S9PMk     nnnSR                  U5      nS	R                  US
9$ s  snnf )Nr®   Tz¼All Piecewise expressions must contain an (expr, True) statement to be used as a default condition. Without one, the generated expression may not evaluate to anything under some condition.z{c}, {e})ÚcÚez{e})r·   z, zpiecewise({_inbrace}))Ú_inbrace)ÚargsÚcondr   ÚBooleanTrueÚ
ValueErrorr‹   rž   Újoin)r~   r¡   r·   r¶   Ú
_coup_listr¸   s         r‚   Ú_print_PiecewiseÚ!MapleCodePrinter._print_Piecewise“   sù   € Ø�I‰I�b‰M×Ñ dÒ*°·±¸2±×1CÑ1CÄqÇ}Á}Ó1Tô ð /ó 0ð 0ð Ÿ	š	ô	#ò "‘�ð 56¸T²MÀaÌqÏ}É}ÒF\ð ×Ñ §¡¨Q£Ø!%§¡¨Q£ð ñ 1Øbg×bnÑbnØ—+‘+˜a“.ð coð c"ò"ñ "ð	 	ñ #ð
 —9‘9˜ZÓ(ˆØ&×-Ñ-°xÐ-Ð@Ð@ùó#s   Á"A0C5c                 ó˜   • [        UR                  5      [        UR                  5      p2SR                  [	        U5      [	        U5      S9$ )Nz{p}/{q})ÚpÚq)ÚintrÂ   rÃ   r‹   Ústr)r~   r¡   rÂ   rÃ   s       r‚   Ú_print_RationalÚ MapleCodePrinter._print_Rational¤   s7   € Ü�4—6‘6‹{œC §¡›Kˆ1Ø×Ñ¤# a£&¬C°«FÐÐ3Ð3r„   c                 óæ   • [        U5      nU R                  UR                  U5      nU R                  UR                  U5      nUR                  nU[
        ;   a	  [
        U   nSR                  X5US9$ )Nz{lhs} {rel_op} {rhs})r©   Úrel_oprª   )r   r°   r©   rª   rÉ   Úspec_relational_opsr‹   )r~   r¡   r²   Úlhs_codeÚrhs_codeÚops         r‚   Ú_print_RelationalÚ"MapleCodePrinter._print_Relational¨   sj   € Ü˜ÓˆØ×$Ñ$ T§X¡X¨tÓ4ˆØ×$Ñ$ T§X¡X¨tÓ4ˆØ�[‰[ˆØÔ$Ó$Ü$ RÑ(ˆBØ%×,Ñ,°È(Ð,ÐSÐSr„   c                 ó   • [         U   $ r˜   )Únumber_symbolsr    s     r‚   Ú_print_NumberSymbolÚ$MapleCodePrinter._print_NumberSymbol±   s   € Ü˜dÑ#Ð#r„   c                 ó   • g)Nz	-infinityr†   r    s     r‚   Ú_print_NegativeInfinityÚ(MapleCodePrinter._print_NegativeInfinity´   ó   € Ør„   c                 ó   • g)NÚinfinityr†   r    s     r‚   Ú_print_InfinityÚ MapleCodePrinter._print_Infinity·   s   € Ør„   c                 ó   • g)NÚtruer†   r    s     r‚   Ú_print_BooleanTrueÚ#MapleCodePrinter._print_BooleanTrueº   s   € Ør„   c                 ó   • g)NÚfalser†   r    s     r‚   Ú_print_BooleanFalseÚ$MapleCodePrinter._print_BooleanFalse½   s   € Ør„   c                 ó   • U(       a  S$ S$ )NrÝ   rá   r†   r    s     r‚   Ú_print_boolÚMapleCodePrinter._print_boolÀ   s   € ÞˆvÐ* 7Ð*r„   c                 ó   • g)NÚ	undefinedr†   r    s     r‚   Ú
_print_NaNÚMapleCodePrinter._print_NaNÃ   r×   r„   c                 óâ   • [         R                  UR                  ;   a  SR                  U(       a  SOSS9nU$ SR                  U R	                  UR                  5       5      U(       a  SOSS9nU$ )NzMatrix([], storage = {storage})ÚsparseÚrectangular)Ústoragez#Matrix({list}, storage = {storage}))rŸ   rî   )r   ÚZeroÚshaper‹   rž   Útolist)r~   r¡   rì   Ú_strMs       r‚   Ú_get_matrixÚMapleCodePrinter._get_matrixÆ   sm   € Ü�6‰6�T—Z‘ZÓØ5×<Ñ<Þ$*™°ð =ð ?ˆEð ˆð :×@Ñ@Ø—[‘[ §¡£Ó/Þ$*™°ð Að ?ˆEð ˆr„   c                 óÔ   • SR                  U R                  UR                  [        S   SS9U R	                  UR
                  S-   5      U R	                  UR                  S-   5      S9$ )Nz{parent}[{i_maple}, {j_maple}]ÚAtomT)Ústricté   )ÚparentÚi_mapleÚj_maple)r‹   r°   rù   r	   rž   ÚiÚjr    s     r‚   Ú_print_MatrixElementÚ%MapleCodePrinter._print_MatrixElementÐ   s`   € Ø/×6Ñ6Ø×$Ñ$ T§[¡[´*¸VÑ2DÈTÐ$ÐRØ—K‘K §¡¨¡
Ó+Ø—K‘K §¡¨¡
Ó+ð 7ð -ð 	-r„   c                 ó"   • U R                  USS9$ )NF©rì   ©ró   r    s     r‚   Ú_print_MatrixBaseÚ"MapleCodePrinter._print_MatrixBaseÖ   s   € Ø×Ñ ¨UÐÐ3Ð3r„   c                 ó"   • U R                  USS9$ )NTr  r  r    s     r‚   Ú_print_SparseRepMatrixÚ'MapleCodePrinter._print_SparseRepMatrixÙ   s   € Ø×Ñ ¨TÐÐ2Ð2r„   c                 óæ   • [        UR                  [        [        45      (       a%  U R	                  [
        R                  " U5      5      $ SR                  U R	                  UR                  5      S9$ )Nz$Matrix({var_size}, shape = identity))Úvar_size)Ú
isinstanceÚrowsr   r   rž   ÚsympyÚSparseMatrixr‹   r    s     r‚   Ú_print_IdentityÚ MapleCodePrinter._print_IdentityÜ   sV   € Ü�d—i‘i¤'¬?Ð!;×<Ñ<Ø—;‘;œu×1Ò1°$Ó7Ó8Ð8à9×@Ñ@È$Ï+É+ÐVZ×V_ÑV_ÓJ`Ð@ÐaÐar„   c                 óš  ^ ^• [        U5      m[        UR                  5      nS n[        US   [        R
                  [        R                  [        R                  [        R                  45      (       d	  US   USS  p#Ub  US:X  a  SR                  UU 4S jU 5       5      $ SR                  USR                  UU 4S jU 5       5      S9$ )Nr   rø   Ú.c              3   óH   >#   • U  H  nTR                  UT5      v •  M     g 7fr˜   ©r°   ©Ú.0Ú_mr²   r~   s     €€r‚   Ú	<genexpr>Ú1MapleCodePrinter._print_MatMul.<locals>.<genexpr>ë   s!   øé € ÐMÂ*¸B˜D×-Ñ-¨b°$×7Ð7Â*ùó   ƒ"z{c}*{m}c              3   óH   >#   • U  H  nTR                  UT5      v •  M     g 7fr˜   r  r  s     €€r‚   r  r  í   s$   øé € Ð8jÒ_iÐY[¸×9JÑ9JÈ2Èt×9TÐ9TÒ_iùr  )r¶   Úm)r   rŸ   r¹   r
  r  Ú
MatrixBaseÚ
MatrixExprÚMatrixSliceÚMatrixSymbolr½   r‹   )r~   r¡   Ú
_fact_listÚ_constr²   s   `   @r‚   Ú_print_MatMulÚMapleCodePrinter._print_MatMulâ   s²   ù€ Ü˜ÓˆÜ˜$Ÿ)™)“_ˆ
ØˆÜ˜* Q™-¬%×*:Ñ*:¼E×<LÑ<LÜ*/×*;Ñ*;¼U×=OÑ=Oð*Q÷ Rñ Rà!+¨A¡°
¸1¸2°�Jà‰>˜V q›[Ø—8‘8ÕMÁ*ÓMÓMÐMà×#Ñ# f°·±Õ8jÑ_iÓ8jÓ0jÐ#ÐkÐkr„   c                 ó†   • SR                  U R                  UR                  5      U R                  UR                  5      S9$ )NzMatrixPower({A}, {n}))ÚAÚn)r‹   rž   r¯   r   r    s     r‚   Ú_print_MatPowÚMapleCodePrinter._print_MatPowï   s5   € à&×-Ñ-°·±¸D¿I¹IÓ0FÈ$Ï+É+ÐVZ×V^ÑV^ÓJ_Ð-Ð`Ð`r„   c                 ó~   ^ ^• [        U5      m[        UR                  5      nSR                  UU 4S jU 5       5      $ )NÚ*c              3   óH   >#   • U  H  nTR                  UT5      v •  M     g 7fr˜   r  r  s     €€r‚   r  Ú:MapleCodePrinter._print_HadamardProduct.<locals>.<genexpr>ö   s!   øé € ÐIºj¸˜×)Ñ)¨"¨d×3Ð3ºjùr  )r   rŸ   r¹   r½   )r~   r¡   r   r²   s   `  @r‚   Ú_print_HadamardProductÚ'MapleCodePrinter._print_HadamardProductó   s/   ù€ Ü˜$ÓˆÜ˜$Ÿ)™)“_ˆ
Ø�x‰xÕI¹jÓIÓIÐIr„   c                 ó  • UR                   u  nu  p4US:w  a/  SR                  U R                  U5      U R                  U5      S9nOSR                  U R                  U5      S9nSR                  U R                  U5      US9$ )Nrø   z{var}${order})ÚvarÚorderz{var})r0  zdiff({func_expr}, {sec_arg}))Ú	func_exprÚsec_arg)r¹   r‹   rž   )r~   r¡   Ú_fÚ_varÚ_orderÚ_second_args         r‚   Ú_print_DerivativeÚ"MapleCodePrinter._print_Derivativeø   s€   € Ø!ŸY™YÑˆ‰NˆTà�Q‹;Ø)×0Ñ0°T·[±[ÀÓ5FØ7;·{±{À6Ó7Jð 1ð L‰Kð "Ÿ.™.¨T¯[©[¸Ó->˜.Ð?ˆKØ-×4Ñ4¸t¿{¹{È2»ÐXcÐ4ÐdÐdr„   )r{   r˜   )F))Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__ÚprintmethodÚlanguageÚ
_operatorsrz   r   Ú_default_settingsry   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'  r-  r8  Ú__static_attributes__Ú__classcell__)r�   s   @r‚   rm   rm   T   så   ø† ñð €KØ€Hð ØØñ€Jñ ˜[×:Ñ:ñ ØØ#'ñ?ñ Ð÷
/ò"ò#òNòò'ò'ò9ò
7òAò"4òTò$òòòòò+òôò-ò4ò3òbòlòaòJ÷
eð er„   rm   c                 ó6   • [        U5      R                  X5      $ )aÙ  Converts ``expr`` to a string of Maple code.

Parameters
==========

expr : Expr
    A SymPy expression to be converted.
assign_to : optional
    When given, the argument is used as the name of the variable to which
    the expression is assigned.  Can be a string, ``Symbol``,
    ``MatrixSymbol``, or ``Indexed`` type.  This can be helpful for
    expressions that generate multi-line statements.
precision : integer, optional
    The precision for numbers such as pi  [default=16].
user_functions : dict, optional
    A dictionary where keys are ``FunctionClass`` instances and values are
    their string representations.  Alternatively, the dictionary value can
    be a list of tuples i.e. [(argument_test, cfunction_string)].  See
    below for examples.
human : bool, optional
    If True, the result is a single string that may contain some constant
    declarations for the number symbols.  If False, the same information is
    returned in a tuple of (symbols_to_declare, not_supported_functions,
    code_text).  [default=True].
contract: bool, optional
    If True, ``Indexed`` instances are assumed to obey tensor contraction
    rules and the corresponding nested loops over indices are generated.
    Setting contract=False will not generate loops, instead the user is
    responsible to provide values for the indices in the code.
    [default=True].
inline: bool, optional
    If True, we try to create single-statement code instead of multiple
    statements.  [default=True].

)rm   Údoprint)r¡   Ú	assign_tor   s      r‚   Ú
maple_coderH    s   € ôH ˜HÓ%×-Ñ-¨dÓ>Ð>r„   c                 ó.   • [        [        U 40 UD65        g)a  Prints the Maple representation of the given expression.

See :func:`maple_code` for the meaning of the optional arguments.

Examples
========

>>> from sympy import print_maple_code, symbols
>>> x, y = symbols('x y')
>>> print_maple_code(x, assign_to=y)
y := x
N)ÚprintrH  )r¡   r   s     r‚   Úprint_maple_coderK  *  s   € ô 
Œ*�TÑ
&˜XÑ
&Õ'r„   r˜   )r>  Ú
sympy.corer   Úsympy.core.numbersr   r   r   Úsympy.printing.codeprinterr   Úsympy.printing.precedencer   r	   r  Ú_known_func_same_namer{   Ú_funcrh   ÚExp1ri   Ú
EulerGammaÚGoldenRatiorÑ   rÊ   ÚComplexInfinityÚnot_supported_symbolrm   rH  rK  r†   r„   r‚   Ú<module>rW     s¶  ðñõ ß EÑ EÝ 2ß <ã ðÐ ð"à	ˆ5ð"ð 
ˆ4ð"ð ˆHð	"ð
 ˆHð"ð ˆHð"ð ˆHð"ð ˆHð"ð ˆHð"ð ˆYð"ð ˆYð"ð ˆYð"ð ˆYð"ð ˆYð"ð ˆYð"ð  ˆvð!"ð" 
ˆEð#"ð$ 
ˆEð%"ð( $Ø#ØØØØØØØØØØØØòC"€óH #€EØ"€O�EÓñ #ð
 ‡D�Dˆ$Ø‡F�FˆHØ‡I�IˆyØ‡L�L�'Ø‡M�MÐ*ð€ð Ø
ñÐ ð ×ÑðÐ ôle�{ô leô^$?óN(r„   