o
    oh#p                     @  s  d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	Z	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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(m)Z)m*Z*m+Z+ dd	l,m-Z-m.Z.m/Z/m0Z0m1Z1 dd
l2m3Z3 ddl4m5Z5 ddl6m7Z7 ddl8m9Z9 ddl:m;Z; ddl<m=Z=m>Z> ddl?m@Z@ ddl:mAZAmBZB i dddddddddddddddddddddddddddd d!d"d#d$d%d&ZCG d'd( d(e;ZDdS ))ar  
Fortran code printer

The FCodePrinter converts single SymPy expressions into single Fortran
expressions, using the functions defined in the Fortran 77 standard where
possible. Some useful pointers to Fortran can be found on wikipedia:

https://en.wikipedia.org/wiki/Fortran

Most of the code below is based on the "Professional Programmer's Guide to
Fortran77" by Clive G. Page:

https://www.star.le.ac.uk/~cgp/prof77.html

Fortran is a case-insensitive language. This might cause trouble because
SymPy is case sensitive. So, fcode adds underscores to variable names when
it is necessary to make them different for Fortran.
    )annotations)Any)defaultdict)chainN)
AssignmentDeclarationPointervalue_constfloat32float64float80	complex64
complex128int8int16int32int64intcrealintegerbool_complex_nonestderrstdout)allocatableisigndsigncmplxmerge
literal_dp	elementalpure	intent_in
intent_outintent_inout)SAddNFloatSymbol)Function)equal_valued)Eq)Range)CodePrinter)
precedence
PRECEDENCE)printer_context)fcodeprint_fcodesincostanasinacosatanatan2sinhcoshtanhlogexperfAbsabs	conjugateconjgMaxmaxMinminc                      s  e Zd ZU dZdZdZeeee	e
eiZedede	dededed	ed
edededediZeddiiZeejfi di dddddZded< ddddddZddiZd fd!d"	Zed#d$ Z fd%d&Z d'd( Z!d)d* Z"d+d, Z#d-d. Z$d/d0 Z%d1d2 Z&d3d4 Z'd5d6 Z(d7d8 Z)d9d: Z*d;d< Z+d=d> Z,d?d@ Z-dAdB Z.dCdD Z/dEdF Z0dGdH Z1dIdJ Z2dKdL Z3dMdN Z4dOdP Z5dQdR Z6dSdT Z7dUdV Z8dWdX Z9dYdZ Z:d[d\ Z;d]d^ Z<d_d` Z=dadb Z>dcdd Z?dedf Z@dgdh ZAdidj ZBdkdl ZCdmdn ZDdodp ZEdqdr ZFdsdt ZGdudv ZHdwdx ZIdydz ZJd{d| ZKd}d~ ZLdd ZMdd ZNdd ZOdd ZPdd ZQdd ZRdd ZSdd ZTdd ZUdd ZVdd ZWdd ZXdd ZYdd ZZ  Z[S )FCodePrinterzAA printer to convert SymPy expressions to strings of Fortran code_fcodeFortranzinteger(c_int)zreal*4zreal*8zreal*10z	complex*8z
complex*16z	integer*1z	integer*2z	integer*4z	integer*8logicaliso_c_bindingc_int   fixedTM   )	precisionuser_functionssource_formatcontractstandardname_manglingzdict[str, Any]_default_settingsz.and.z.or.z.neqv.z.eqv.z.not. )andorxor
equivalentnotz!=z/=Nc                   s   |si }i | _ g | _tt| j |di  | _tt| j |di  | _t 	| tt
| _
|di }| j
| h d}| jd |vrWtd| jd  tt| _d S )Ntype_aliasestype_mappingsrT   >     B   rR   Z   _     rW   zUnknown Fortran standard: %s)mangled_symbols	used_namedictr   r_   itemspopr`   super__init__known_functionsgetupdate	_settings
ValueErrorr   setmodule_uses)selfsettings	userfuncs	standards	__class__ j/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/sympy/printing/fortran.pyrl   x   s(   
zFCodePrinter.__init__c                 C  sF   | j d dkrddddS | j d dkrddd	dS td
| j d  )NrU   rQ   z      z     @ zC     )codecontcommentfree z! zUnknown source format: %s)rp   rq   rt   rz   rz   r{   _lead   s
   zFCodePrinter._leadc                   s   | j d dkrA|| jvr;|j}| | jv r!|d7 }| | jv s| j|  ||jkr4|| j|< nt|| j|< || j}t 	|}|S )NrX   T_)
rp   rf   namelowerrg   appendr*   xreplacerk   _print_Symbol)rt   exprr   rx   rz   r{   r      s   

zFCodePrinter._print_Symbolc                 C  s
   | d S )N   rz   )rt   prz   rz   r{   _rate_index_position      
z!FCodePrinter._rate_index_positionc                 C  s   |S Nrz   )rt   
codestringrz   rz   r{   _get_statement      zFCodePrinter._get_statementc                 C  s
   d |S )Nz! {})format)rt   textrz   rz   r{   _get_comment   r   zFCodePrinter._get_commentc                 C  s   d || |S )Nzparameter ({} = {}))r   _print)rt   r   valuerz   rz   r{   _declare_number_const      z"FCodePrinter._declare_number_constc                 C  s(   | j |t|| jd f t|S )NrS   )_number_symbolsaddr)   evalfrp   strrt   r   rz   rz   r{   _print_NumberSymbol   s    z FCodePrinter._print_NumberSymbolc                 C  s   |  | |S r   )_wrap_fortranindent_code)rt   linesrz   rz   r{   _format_code   s   zFCodePrinter._format_codec                   s    |j \ } fddt|D S )Nc                 3  s&    | ]}t  D ]}||fV  qqd S r   )range).0jirowsrz   r{   	<genexpr>   s   $ z8FCodePrinter._traverse_matrix_indices.<locals>.<genexpr>)shaper   )rt   matcolsrz   r   r{   _traverse_matrix_indices   s   
z%FCodePrinter._traverse_matrix_indicesc                 C  s^   g }g }|D ]$}t | j|j|jd |jd g\}}}|d|||f  |d q||fS )N   zdo %s = %s, %send do)mapr   labelr   upperr   )rt   indices
open_linesclose_linesr   varstartstoprz   rz   r{   _get_loop_opening_ending   s   
z%FCodePrinter._get_loop_opening_endingc                 C  s   ddl m} |j\}|jrtdtd|t|d}n1|js |jr9tt	t
dt
d||| t||t
d}ntt
dtt
d|t|t
d}| |S )Nr   )rB   r   )$sympy.functions.elementary.complexesrB   args
is_integerr   r   r-   
is_complexis_infiniter   r    r   r   )rt   r   rB   argnew_exprrz   rz   r{   _print_sign   s   2$
zFCodePrinter._print_signc           
      C  s4  |j d jdkrtdg }|tr]t|j D ]:\}\}}|dkr-|d| |  n|t|j d kr@|dkr@|d n
|d| |  || | q|d	 d
	|S | j
d dkrd}| |j d j}t|j d d }|r| \}}| |}| |}	|j|||	d}|sz|S td)NTzAll 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.r   zif (%s) thenr   elsezelse if (%s) thenend if
rW   rd   zmerge({T}, {F}, {COND}))TFCONDzmUsing Piecewise as an expression using inline operators is not supported in standards earlier than Fortran95.)r   condrq   hasr   	enumerater   r   lenjoinrp   r   listrj   r   NotImplementedError)
rt   r   r   r   ecpatternr|   termsr   rz   rz   r{   _print_Piecewise   s2   




zFCodePrinter._print_Piecewisec                 C  s,   d | j|jtd dd|jd |jd S )Nz
{}({}, {})AtomT)strictr   )r   parenthesizeparentr1   r   r   r   rz   rz   r{   _print_MatrixElement   s
   z!FCodePrinter._print_MatrixElementc           
      C  s  g }g }g }|j D ]}|jr|jr|| q	|jr#|jr#|| q	|| q	|r~|rjt|}t| }| |}|drHd}	|dd  }nd}	t||k rTd| }d| t| | t	j
 t|  |	|f S d| t| | t	j
 t|  f S t| |S )N-r   +z(%s)zcmplx(%s,%s) %s %szcmplx(%s,%s))r   	is_numberis_realr   is_imaginaryr0   r'   r   
startswithr&   ImaginaryUnitr/   
_print_Add)
rt   r   	pure_realpure_imaginarymixedr   PRECtermtsignrz   rz   r{   r     s<   


zFCodePrinter._print_Addc                   sN   | j d   fdd|jD }|j| }t|ts| |S t| |j| S )NrS   c                   s   g | ]}t | qS rz   )r(   )r   aprecrz   r{   
<listcomp>.      z0FCodePrinter._print_Function.<locals>.<listcomp>)rp   r   func
isinstancer+   r   r/   _print_Function)rt   r   r   	eval_exprrz   r   r{   r   +  s   



zFCodePrinter._print_Functionc                 C  s<   | j d dv rd}t||j\}}d| || |S )NrW   )rb   rR   z]Python % operator and SymPy's Mod() function are not supported by Fortran 66 or 77 standards.z      modulo({}, {}))rp   r   r   r   r   )rt   r   msgxyrz   rz   r{   
_print_Mod5  s
   
zFCodePrinter._print_Modc                 C     dS )Nz
cmplx(0,1)rz   r   rz   rz   r{   _print_ImaginaryUnitB  s   z!FCodePrinter._print_ImaginaryUnitc                 C     t |S r   r   r   rz   rz   r{   
_print_intF     zFCodePrinter._print_intc                 C  s.   |j r|jrd| tj |  S t| |S )Nzcmplx(0,%s))r   r   r   r&   r   r/   
_print_Mulr   rz   rz   r{   r   I  s
   zFCodePrinter._print_Mulc                 C  s   t |}t|jdrd| td| |j|f S t|jdr@|jjr8|jjr0d| |j S d| |j S d| |j S t	
| |S )Nr   z%s/%sr   g      ?zsqrt(%s.0d0)zsqrt(dble(%s))zsqrt(%s))r0   r,   r@   r   r    r   baser   	is_Numberr/   
_print_Pow)rt   r   r   rz   rz   r{   r   R  s   zFCodePrinter._print_Powc                 C  s"   t |jt |j}}d||f S )Nz%d.0d0/%d.0d0)intr   q)rt   r   r   r  rz   rz   r{   _print_Rationale  s   zFCodePrinter._print_Rationalc                 C  sF   t | |}|d}|dkrd|d | ||d d  f S d| S )Nr   r   z%sd%sr   z%sd0)r/   _print_Floatfind)rt   r   printedr   rz   rz   r{   r  i  s
   
 zFCodePrinter._print_Floatc                 C  sD   |  |j}|  |j}|j}|| jvr|n| j| }d|||S )Nz{} {} {})r   lhsrhsrel_op_relationalsr   )rt   r   lhs_coderhs_codeoprz   rz   r{   _print_Relationalp  s
   zFCodePrinter._print_Relationalc                   s0    fdd|j D }d |jjd|f S )Nc                      g | ]}  |qS rz   r   )r   r   r   rz   r{   r   x  r   z/FCodePrinter._print_Indexed.<locals>.<listcomp>%s(%s), )r   r   r   r   r   )rt   r   indsrz   r   r{   _print_Indexedw  s   zFCodePrinter._print_Indexedc                 C  s   |  |jS r   )r   r   r   rz   rz   r{   
_print_Idx{  s   zFCodePrinter._print_Idxc              	   C  s@   |  |j}|  |j}| d|  ||  |j|  |S )Nz{0} = {0} {1} {2})r   r  r  r   r   binop)rt   r   r
  r  rz   rz   r{   _print_AugmentedAssignment~  s
   z'FCodePrinter._print_AugmentedAssignmentc                 C  s^   |  |j}|jd kr|d|  |j 7 }|jd kr$|d|  |j 7 }d|jjd|f S )Nr  z, mask=r  r   )r   arraydimmaskry   __name__rstrip)rt   smparamsrz   rz   r{   _print_sum_  s   

zFCodePrinter._print_sum_c                 C  s
   |  |S r   )r  )rt   prodrz   rz   r{   _print_product_  r   zFCodePrinter._print_product_c                   s\   dg}|j dkr|d d}nd}d| d jdd|jrdndi|j fd	d
|dS )N
concurrentr   stepr   , {step}z*do {concurrent}{counter} = {first}, {last}z
{body}
end do
zconcurrent c                   
     | S r   r  r   r   rz   r{   <lambda>     
 z(FCodePrinter._print_Do.<locals>.<lambda>)applyexcluderz   )r"  r   r   r!  kwargs)rt   doexclr"  rz   r   r{   	_print_Do  s   


zFCodePrinter._print_Doc                   s:   |j dkrdnd}d| d jd	i |j fdddS )
Nr   r   r#  z$({expr}, {counter} = {first}, {last})c                   r$  r   r  r%  r   rz   r{   r&    r'  z3FCodePrinter._print_ImpliedDoLoop.<locals>.<lambda>r(  rz   )r"  r   r*  )rt   idlr"  rz   r   r{   _print_ImpliedDoLoop  s   z!FCodePrinter._print_ImpliedDoLoopc                 C  sT   |  |j}t|jtr|jj\}}}ntd|  |j}dj|||d ||dS )Nz*Only iterable currently supported is Rangez3do {target} = {start}, {stop}, {step}
{body}
end dor   )targetr   r   r"  body)	r   r2  r   iterabler.   r   r   r3  r   )rt   r   r2  r   r   r"  r3  rz   rz   r{   
_print_For  s   zFCodePrinter._print_Forc                 C  sP   | j ||}| j||j}| j|}|r&|D ]\}}| j| | q|S r   )r_   rn   r`   r   type_modulesrs   r   )rt   type_type_strrs   kvrz   rz   r{   _print_Type  s   zFCodePrinter._print_Typec                   ,   dj  |jd fdd|jD dS )N{symbol}({idxs})r  c                 3      | ]}  |V  qd S r   r  r   r   r   rz   r{   r         z.FCodePrinter._print_Element.<locals>.<genexpr>symbolidxs)r   r   rB  r   r   rt   elemrz   r   r{   _print_Element     
zFCodePrinter._print_Elementc                 C  r   r   r   )rt   extrz   rz   r{   _print_Extent  r   zFCodePrinter._print_Extentc              	     sN  |j j}d}fddtttfD }|ddkr!d}n|ddkr4dg d	|d  }ntd
  t	t
rCtd jd dkrdj jtjv rXdnd|ridd fdd|D  nd|tjv rrdnd jd}|d kr|d | 7 }|S tjv s|rtdd fddjjfD }|S )N	dimensionc                   s   g | ]}| j v qS rz   )attrs)r   intent)r   rz   r{   r     r   z3FCodePrinter._print_Declaration.<locals>.<listcomp>Tr   r   r   z, intent(%s))inoutinoutz!Multiple intents specified for %sz1Pointers are not available by default in Fortran.rW   rc   z"{t}{vc}{dim}{intent}{alloc} :: {s}z, parameterz, dimension(%s)r  c                 3  r>  r   r  r?  r   rz   r{   r     r@  z2FCodePrinter._print_Declaration.<locals>.<genexpr>z, allocatable)r   vcr  rL  allocsz = %sz0F77 init./parameter statem. req. multiple lines. c                 3  r>  r   r  r?  r   rz   r{   r     r@  )variabler   attr_paramsr#   r$   r%   countindexrq   r   r   r   rp   r   r   typer	   rK  r   r   rB  )rt   r   valr  intentsrL  resultrz   )rt   r   r{   _print_Declaration  s6   


"
 zFCodePrinter._print_Declarationc                 C  s   d|  td S )Nz(huge(%s) + 1)r   )r   r    r   rz   rz   r{   _print_Infinity  r   zFCodePrinter._print_Infinityc                       dj di |j fdddS )Nz$do while ({condition})
{body}
end doc                   r$  r   r  r%  r   rz   r{   r&    r'  z+FCodePrinter._print_While.<locals>.<lambda>r/  rz   r   r*  r   rz   r   r{   _print_While  s   

zFCodePrinter._print_Whilec                 C  r   )Nz.true.rz   r   rz   rz   r{   _print_BooleanTrue  r   zFCodePrinter._print_BooleanTruec                 C  r   )Nz.false.rz   r   rz   rz   r{   _print_BooleanFalse  r   z FCodePrinter._print_BooleanFalsec                 C  sR   g }|D ]"}| dr|| jd |dd     q|| jd |  q|S )N!r~   r   r|   )r   r   r   lstrip)rt   r   r[  linerz   rz   r{   _pad_leading_columns  s   
"z!FCodePrinter._pad_leading_columnsc                   s  t dtj tj  t d fdd}g }| jd dkr!d}nd}|D ]}|| jd	 rt|d
kr|ddd
}|dkrBd
}|d| }||d 	 }|
| |r|ddd}|dksht|dk rjd}|d| }||d 	 }|
d| jd	 |f  |sWq%|
| q%|| jd r||d
}|d|  }||d 	 }|r||7 }|
| |r||d}|d|  }||d 	 }|r||7 }|
d| jd |f  |sq%|
| q%|S )zWrap long Fortran lines

           Argument:
             lines  --  a list of lines (without \n character)

           A comment line is split at white space. Code lines are split with a more
           complex rule to give nice results.
        z_+-.z 	()c                   sP   t  |kr
t  S |} fdd}||s&|d8 }|dkr"|S ||r|S )Nc                   sp    |  v r | d  vp7 |  vo | d  v p7 |  v o) | d  vp7 |  vo7 | d  v S )Nr   rz   )pos)re  my_alnummy_whiterz   r{   r&    s   zDFCodePrinter._wrap_fortran.<locals>.split_pos_code.<locals>.<lambda>r   r   )r   )re  endposrg  splitrh  ri  )re  r{   split_pos_code  s   z2FCodePrinter._wrap_fortran.<locals>.split_pos_coderU   r   z &r   r~   H   rS     r   Nr   rb   %s%sr|   A   r}   )rr   stringdigitsascii_lettersrp   r   r   r   rfindrd  r   r  )rt   r   rm  r[  trailingre  rg  hunkrz   rl  r{   r     sX   




zFCodePrinter._wrap_fortranc                   s<  t |tr| |d}d|S | jd dk}dd |D }dd fd	d|D } fd
d|D }dd |D }d}d}d}	g }
t|D ]K\}}|dv rW|
| qI||| 8 }|rhd||	 |  }nd| |	 }d||f }|s~| |gd }|
| || rd|	 }nd}||| 7 }qI|s| 	|
S |
S )z0Accepts a string of code or a list of code linesTr   rU   r   c                 S  s   g | ]}| d qS )z 	)rd  r   re  rz   rz   r{   r   I  r   z,FCodePrinter.indent_code.<locals>.<listcomp>)zdo zif(zif zdo
r   program	interface)r   enddor   endifr   zend programzend interfacec                       g | ]}t tt|j qS rz   r   anyr   r   rx  )inc_keywordrz   r{   r   N      c                   r}  rz   r~  rx  )dec_keywordrz   r{   r   P  r  c                 S  s$   g | ]}t tt|jd dgqS )&z&
)r   r  r   endswithrx  rz   rz   r{   r   R  s    r      )r   r   rS  rp     )
r   r   r   
splitlinesr   rp   r   r   rf  r   )rt   r|   
code_linesr   increasedecreasecontinuationlevelcont_paddingtabwidthnew_coder   re  paddingrz   )r  r  r{   r   B  sN   







zFCodePrinter.indent_codec                   sH   |j rdjd fdd|jD  |j dS |j\}d | S )Nzgo to ({labels}), {expr}r  c                 3  r>  r   r  r?  r   rz   r{   r   w  r@  z+FCodePrinter._print_GoTo.<locals>.<genexpr>)labelsr   zgo to %s)r   r   r   r  r   )rt   gotolblrz   r   r{   _print_GoTot  s   
zFCodePrinter._print_GoToc                   r^  )Nz"program {name}
{body}
end program
c                   r$  r   r  r%  r   rz   r{   r&    r'  z-FCodePrinter._print_Program.<locals>.<lambda>r/  rz   r_  )rt   progrz   r   r{   _print_Program~  s
   zFCodePrinter._print_Programc                   r^  )NzAmodule {name}
{declarations}

contains

{definitions}
end module
c                   r$  r   r  r%  r   rz   r{   r&    r'  z,FCodePrinter._print_Module.<locals>.<lambda>r/  rz   r_  )rt   modrz   r   r{   _print_Module  s
   zFCodePrinter._print_Modulec                 C  sl   |j dkr| jd dkr| jd d dS |j dkr,| jd dkr,| jd d d	S |j dkr3d
S |j S )Nr   rW   re   rN   zstdint=>input_unit
input_unitr   zstdint=>error_unit
error_unit*)r   rp   rs   r   )rt   strmrz   rz   r{   _print_Stream  s   
zFCodePrinter._print_Streamc                   sb   |j tkr
d}d}nddtdtdi|jdi } |j }|j|d fdd	|j	D d
S )Nzprint {fmt}, {iolist}r  z3write(%(out)s, fmt="{fmt}", advance="no"), {iolist}rN  06r  c                 3  r>  r   r  r?  r   rz   r{   r     r@  z,FCodePrinter._print_Print.<locals>.<genexpr>)fmtiolist)
format_stringr   r   r   rn   filer   r   r   
print_args)rt   pstemplater  rz   r   r{   _print_Print  s   

zFCodePrinter._print_Printc                 C  s&   |j \}dj| jdd| |dS )Nz{result_name} = {arg}result_namesympy_result)r  r   )r   r   _contextrn   r   )rt   rsr   rz   rz   r{   _print_Return  s
   zFCodePrinter._print_Returnc                 C  s   |j \}|rd| | S dS )Nz	return %sreturn)r   r   )rt   frsr   rz   rz   r{   _print_FortranReturn  s   z!FCodePrinter._print_FortranReturnc                   s   | d}|d u rd}n
|rd|d  nd} jdd }dj| |jd fd	d
|jD |r7d| nd|d fdd|jD dS )Nbind_Cr   z bind(C, name="%s")r   z bind(C)r  z<{entity}{name}({arg_names}){result}{bind}
{arg_declarations}r  c                   s   g | ]}  |jqS rz   )r   rB  r?  r   rz   r{   r     s    z&FCodePrinter._head.<locals>.<listcomp>z result(%s)r   c                 3  s    | ]
}  t|V  qd S r   )r   r   r?  r   rz   r{   r     s    z%FCodePrinter._head.<locals>.<genexpr>)entityr   	arg_namesr[  bindarg_declarations)rU  rp   rn   r   r   r   r   
parameters)rt   r  fpr*  bind_C_paramsr  r  rz   r   r{   _head  s   

zFCodePrinter._headc                 C  s&   d | |j}dj | ||dS )N{} function z4interface
{function_head}
end function
end interface)function_head)r   r   return_typer  )rt   r  r  rz   rz   r{   _print_FunctionPrototype  s   z%FCodePrinter._print_FunctionPrototypec                 C  s   t |jv rd}n
t|jv rd}nd}d| |j}t| |jd dj|| ||| |j	dW  d    S 1 s=w   Y  d S )Nz
elemental zpure r   r  )r  z,{prefix}{function_head}
{body}
end function
)prefixr  r3  )
r!   rK  r"   r   r   r  r2   r   r  r3  )rt   fdr  r  rz   rz   r{   _print_FunctionDefinition  s   



$z&FCodePrinter._print_FunctionDefinitionc                 C  s   dj | d|| |jdS )Nz({subroutine_head}
{body}
end subroutine
zsubroutine )subroutine_headr3  )r   r  r   r3  )rt   subrz   rz   r{   _print_Subroutine  s
   

zFCodePrinter._print_Subroutinec                   r<  )Nzcall {name}({args})r  c                 3  r>  r   r  r?  r   rz   r{   r     r@  z5FCodePrinter._print_SubroutineCall.<locals>.<genexpr>)r   r   )r   r   r   r   subroutine_args)rt   scallrz   r   r{   _print_SubroutineCall  rG  z"FCodePrinter._print_SubroutineCallc                   s   dt  fdd|jD  S )Nz%s => %sc                 3  r>  r   r  r?  r   rz   r{   r     r@  z1FCodePrinter._print_use_rename.<locals>.<genexpr>)tupler   )rt   rnmrz   r   r{   _print_use_rename  s   zFCodePrinter._print_use_renamec                   sl   d  |j }|jd kr|dd fdd|jD  7 }|jd kr4|dd fdd|jD  7 }|S )Nzuse %sr  c                   r  rz   r  )r   r  r   rz   r{   r     r   z+FCodePrinter._print_use.<locals>.<listcomp>z, only: c                   r  rz   r  )r   nlyr   rz   r{   r     r   )r   	namespacerenamer   only)rt   user[  rz   r   r{   
_print_use  s   
"
"zFCodePrinter._print_usec                 C  r   )Nexitrz   rt   r   rz   rz   r{   _print_BreakToken   r   zFCodePrinter._print_BreakTokenc                 C  r   )Ncyclerz   r  rz   rz   r{   _print_ContinueToken  r   z!FCodePrinter._print_ContinueTokenc                   s4    j d dkr	dnd}|d fdd|jD  S )NrW   re   z[%s]z(/%s/)r  c                 3  r>  r   r  r?  r   rz   r{   r     r@  z7FCodePrinter._print_ArrayConstructor.<locals>.<genexpr>)rp   r   elements)rt   acfmtstrrz   r   r{   _print_ArrayConstructor  s   z$FCodePrinter._print_ArrayConstructorc                   r<  )Nr=  r  c                 3  r>  r   r  r?  r   rz   r{   r     r@  z3FCodePrinter._print_ArrayElement.<locals>.<genexpr>rA  )r   r   r   r   r   rD  rz   r   r{   _print_ArrayElement
  rG  z FCodePrinter._print_ArrayElementr   )\r  
__module____qualname____doc__printmethodlanguager   r   r   r   r   r   r_   r   r
   r   r   r   r   r   r   r`   r6  rh   r/   rY   __annotations__
_operatorsr	  rl   propertyr   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  r   r-  r1  r5  r;  rF  rI  r\  r]  r`  ra  rb  rf  r   r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  __classcell__rz   rz   rx   r{   rJ   F   s   
 

	
*'
		!	G2
		
rJ   )Er  
__future__r   typingr   collectionsr   	itertoolsr   rr  sympy.codegen.astr   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   sympy.codegen.fnodesr   r   r   r   r   r    r!   r"   r#   r$   r%   
sympy.corer&   r'   r(   r)   r*   sympy.core.functionr+   sympy.core.numbersr,   sympy.core.relationalr-   
sympy.setsr.   sympy.printing.codeprinterr/   sympy.printing.precedencer0   r1   sympy.printing.printerr2   r3   r4   rm   rJ   rz   rz   rz   r{   <module>   sj    \4	
