
    \h                         S SK rS SKrS SKJr  S SKJr  S SKJr  S SK	J
r
  S SKJr  S SKJr  S SKJr  S S	KJrJr  S SKr\" S
5      r " S S\\5      rS rg)    N)version_tuple)Iterable)Mul)S)Sqrt)import_module)
PRECEDENCE)AbstractPythonCodePrinterArrayPrinter
tensorflowc                     ^  \ rS rSrSrSr0 \R                  S_\R                  S_\R                  S_\R                  S_\R                  S_\R                  S	_\S
_\R                  S_\R                  S_\R                   S_\R"                  S_\R$                  S_\R&                  S_\R(                  S_\R*                  S_\R,                  S_\R.                  S_0 \R0                  S_\R2                  S_\R4                  S_\R6                  S_\R8                  S_\R:                  S_\R<                  S_\R>                  S_\R@                  S_\RB                  S_\RD                  S_\RF                  S _\RH                  S!_\RJ                  S"_\RL                  S#_\RN                  S$_\RP                  S%_E\RR                  S&\RT                  S'\RV                  S(\RX                  S)\RZ                  S*\R\                  S+0Er/\0" \1Rd                  S,S-9r2SAU 4S. jjr3U 4S/ jr4\4r5\4r6\4r7\4r8\4r9\4r:\4r;\4r<\4r=\4r>S0 r?S1 r@S2 rAS3 rBS4 rCS5 rDS6 rES7 rFS8 rGS9 rHS: rIS;rJS<rKS=rLS>rMS?rNS@rOS-rPU =rQ$ )BTensorflowPrinter   zx
Tensorflow printer which handles vectorized piecewise functions,
logical operators, max/min, and relational operators.
_tensorflowcodeztensorflow.math.absztensorflow.math.signztensorflow.math.ceilztensorflow.math.floorztensorflow.math.logztensorflow.math.exptensorflow.math.sqrtztensorflow.math.cosztensorflow.math.acosztensorflow.math.sinztensorflow.math.asinztensorflow.math.tanztensorflow.math.atanztensorflow.math.atan2ztensorflow.math.coshztensorflow.math.acoshztensorflow.math.sinhztensorflow.math.asinhztensorflow.math.tanhztensorflow.math.atanhztensorflow.math.realztensorflow.math.imagztensorflow.math.angleztensorflow.math.erfztensorflow.math.lgammaztensorflow.math.equalztensorflow.math.not_equalztensorflow.math.greaterztensorflow.math.lessztensorflow.math.less_equalztensorflow.math.greater_equalztensorflow.math.logical_andztensorflow.math.logical_orztensorflow.math.logical_notztensorflow.math.maximumztensorflow.math.minimumztensorflow.math.addztensorflow.math.multiplyztensorflow.linalg.traceztensorflow.linalg.detN)tensorflow_versionc                    > [         TU ]  U5        U R                  S   nUc  [        (       a  [        R                  nX l        g )Nr   )super__init__	_settingsr   __version__r   )selfsettingsversion	__class__s      Q/var/www/auris/envauris/lib/python3.13/site-packages/sympy/printing/tensorflow.pyr   TensorflowPrinter.__init__S   s9    "..!56?zz ,,G")    c                 H  > U R                   R                  [        U5      S 5      nUc  [        TU ]  U5      $ UR
                   Vs/ s H  o0R                  U5      PM     nn[        U5      S:X  a  U R                  U5      < SUS   < S3$ U R                  X$5      $ s  snf )N   (r   ))
mappinggettyper   _print_Basicargs_printlen_module_format_expand_fold_binary_op)r   expropargchildrenr   s        r   _print_Function!TensorflowPrinter._print_Function[   s    \\d4j$/:7'--04		:	KK$	:x=A##B' 
 ..r<< ;s   Bc                 x    U R                  S5      nSR                  X R                  UR                  5      5      $ )Nztensorflow.linalg.inv{}({}))r*   formatr(   r.   )r   r,   r-   s      r   _print_Inverse TensorflowPrinter._print_Inverset   s/      !89r;;txx#899r   c                     U R                   nU(       a*  [        U5      [        S5      :  a  U R                  S5      nOU R                  S5      nSR                  X0R	                  UR
                  5      5      $ )Nz1.14ztensorflow.matrix_transposez"tensorflow.linalg.matrix_transposer3   )r   r   r*   r4   r(   r.   )r   r,   r   r-   s       r   _print_Transpose"TensorflowPrinter._print_Transposex   s_    ))}W-f0EE$$%BCB$$%IJBr;;txx#899r   c                    ^ ^ UR                   n[        S U 5       5      (       a  [        S5      eU U4S jmT" UR                  U5      $ )Nc              3   B   #    U  H  n[        U[        5      v   M     g 7fN)
isinstancer   ).0is     r   	<genexpr>6TensorflowPrinter._print_Derivative.<locals>.<genexpr>   s     :	1z!X&&	s   z1derivation by multiple variables is not supportedc                    > U(       d  TR                  U 5      $ TR                  S5      < ST" XS S 5      < STR                  US   5      < S3$ )Nztensorflow.gradientsr!   , z)[0])r(   r*   )r,   r'   r   unfolds     r   rE   3TensorflowPrinter._print_Derivative.<locals>.unfold   sL    {{4((''(>?4cr+KKR) r   )	variablesanyNotImplementedErrorr,   )r   r,   rG   rE   s   `  @r   _print_Derivative#TensorflowPrinter._print_Derivative   sA    NN	:	:::%&YZZ	 dii++r   c                    U R                   nU(       a  [        U5      [        S5      :  a  SnOSnSSKJn  UR                  S   R                  u  pV[        UR                  5      S:X  aA  SR                  U R                  U5      U R                  U5      U R                  U5      S5      $ SR                  U R                  U5      U R                  U5      U R                  U5      U R                  U" UR                  SS  6 5      5      $ )Nz1.0ztensorflow.selectztensorflow.wherer   )	Piecewiser    z{}({}, {}, {}))	r   r   $sympy.functions.elementary.piecewiserM   r'   r)   r4   r*   r(   )r   r,   r   tensorflow_piecewiserM   econds          r   _print_Piecewise"TensorflowPrinter._print_Piecewise   s    ))}W-e0DD#6 #5 B))A,##tyy>Q#**##$89D!A	   && 45KKKKNKK	499QR=12	4 	4r   c                 :   UR                   u  p#UR                  [        R                  :X  a0  SR	                  U R                  S5      U R                  U5      5      $ SR	                  U R                  S5      U R                  U5      U R                  U5      5      $ )Nr3   r   z
{}({}, {})ztensorflow.math.pow)r'   expr   Halfr4   r*   r(   )r   r,   baserU   s       r   
_print_PowTensorflowPrinter._print_Pow   s     II	88qvv??##$:;T[[=NP P"" 56KKt{{3/1 	1r   c                 L   UR                   (       a  SOSnSSR                  UR                  5        VVs/ s H9  nSSR                  U Vs/ s H  o@R                  U5      PM     sn5      -   S-   PM;     snn5      -   S-   nU R	                  U5      < SU< S3$ s  snf s  snnf )Nztensorflow.Variableztensorflow.constant[rD   ]r!   r"   )free_symbolsjointolistr(   r*   )r   r,   tensorflow_fr?   jdatas         r   _print_MatrixBase#TensorflowPrinter._print_MatrixBase   s    040A0A,G\499VZVaVaVcdVcQRc$))Q,GQ[[^Q,G"HHLVcdeefii-
 	
 -Hds   B B%B B c                 ~   SSK Jn  UR                   Vs/ s H  n[        X25      (       d  M  UPM     nnUR                   Vs/ s H  o3U;  d  M
  UPM     nnU(       aD  U R	                  [
        R                  " U5      [        S   5      < SU R                  SU5      < 3$ U R                  SU5      $ s  snf s  snf )Nr   )
MatrixExprr   *tensorflow.linalg.matmul)	sympy.matrices.expressionsrf   r'   r=   parenthesizer   fromiterr	   r+   )r   r,   rf   r.   mat_argsr'   s         r   _print_MatMulTensorflowPrinter._print_MatMul   s    9#'99L9C
30KC9L#yy@yx,?y@!!#,,t"4j6GH++.:  ..*H6 6 M@s   B5B5	B:B:c                 V    U R                  SUR                  /UR                  -  5      $ )Nrh   )r+   rW   rU   )r   r,   s     r   _print_MatPowTensorflowPrinter._print_MatPow   s)    **&DHH(<> 	>r   c                     / nUR                    H#  nUR                  U R                  U5      5        M%     SR                  U5      $ )N
)r'   appendr(   r^   )r   r,   retsubexprs       r   _print_CodeBlock"TensorflowPrinter._print_CodeBlock   s8    yyGJJt{{7+, !yy~r   c                 <    SU R                   " UR                  6  S3$ )Nztensorflow.math.is_nan(r"   r(   r'   r   rU   s     r   _print_isnanTensorflowPrinter._print_isnan       (chh)?(@BBr   c                 <    SU R                   " UR                  6  S3$ )Nztensorflow.math.is_inf(r"   rz   r{   s     r   _print_isinfTensorflowPrinter._print_isinf   r~   r   r   zlinalg.einsumzmath.add	transposeoneszerosr<   )R__name__
__module____qualname____firstlineno____doc__printmethodsympyAbssignceilingfloorlogrU   r   cosacossinasintanatanatan2coshacoshsinhasinhtanhatanhreimr.   erfloggammaEqNeStrictGreaterThanStrictLessThanLessThanGreaterThanAndOrNotMaxMinMatAddHadamardProductTraceDeterminantr#   dictr
   _default_settingsr   r0   _print_Expr_print_Application_print_MatrixExpr_print_Relational
_print_Not
_print_And	_print_Or_print_HadamardProduct_print_Trace_print_Determinantr5   r8   rJ   rR   rX   rc   rm   rp   rw   r|   r   _module_einsum_add
_transpose_ones_zeros__static_attributes____classcell__)r   s   @r   r   r      sk    $K5		(5

*5
 	-5 	,5 			(5 			(5 	$5 			(5 	

*5 			(5 	

*5 			(5 	

*5  	,!5$ 	

*%5& 	,'5( 	

*)5* 	,+5, 	

*-5. 	,/52 	(354 	(556 			*75< 			(=5> 	0?5B 	)C5D 	-E5F 	!:G5H 	4I5J 	4K5L 	:M5P 			0Q5R 	.S5T 			0U5V 			,		, 	+9. 	3i5Gn !33
*= "K('' J JI,"L(::,4,	1
6>CC GGDJEFr   r   c                 :    [        U5      nUR                  U 5      $ r<   )r   doprint)r,   r   printers      r   tensorflow_coder      s    )G??4  r   )sympy.codegenr   sympy.codegen.cfunctionssympy.external.importtoolsr   collections.abcr   sympy.core.mulr   sympy.core.singletonr   r   sympy.externalr   sympy.printing.precedencer	   sympy.printing.pycoder
   r   r   r   r    r   r   <module>r      sG      4 $  " ) ( 0 I <(
K&? K\!r   