U
    L?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 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absZconjgmaxmin)r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   Abs	conjugateZMaxZ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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 codeZ_fcodeFortranzinteger(c_int)zreal*4zreal*8zreal*10z	complex*8z
complex*16z	integer*1z	integer*2z	integer*4z	integer*8Zlogicaliso_c_bindingZc_int   fixedTM   )	precisionuser_functionssource_formatZcontractstandardname_manglingzdict[str, Any]_default_settingsz.and.z.or.z.neqv.z.eqv.z.not. )andorxorZ
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
| dddddd	h}| jd
 |krtd| jd
  tt| _d S )Ntype_aliasestype_mappingsrN   B   rL   Z   _     i  rP   zUnknown Fortran standard: %s)mangled_symbols	used_namedictr   rW   itemspoprX   super__init__known_functionsgetupdate	_settings
ValueErrorr   setmodule_uses)selfsettingsZ	userfuncsZ	standards	__class__ H/var/www/html/venv/lib/python3.8/site-packages/sympy/printing/fortran.pyrc   x   s(    
zFCodePrinter.__init__c                 C  sJ   | j d dkrddddS | j d dkr4ddd	dS td
| j d  d S )NrO   rK   z      z     @ zC     )codecontcommentfree z! zUnknown source format: %s)rg   rh   rk   ro   ro   rp   _lead   s
    zFCodePrinter._leadc                   s   | j d dkrv|| jkrj|j}| | jkr6|d7 }q| j|  ||jkr\|| j|< nt|| j|< || j}t 	|}|S )NrQ   T_)
rg   r]   namelowerr^   appendr*   Zxreplacerb   _print_Symbol)rk   exprry   rm   ro   rp   r|      s    


zFCodePrinter._print_Symbolc                 C  s
   | d S )N   ro   )rk   pro   ro   rp   _rate_index_position   s    z!FCodePrinter._rate_index_positionc                 C  s   |S Nro   )rk   Z
codestringro   ro   rp   _get_statement   s    zFCodePrinter._get_statementc                 C  s
   d |S )Nz! {})format)rk   textro   ro   rp   _get_comment   s    zFCodePrinter._get_commentc                 C  s   d || |S )Nzparameter ({} = {}))r   _print)rk   ry   valuero   ro   rp   _declare_number_const   s    z"FCodePrinter._declare_number_constc                 C  s(   | j |t|| jd f t|S )NrM   )Z_number_symbolsaddr)   Zevalfrg   strrk   r}   ro   ro   rp   _print_NumberSymbol   s     z FCodePrinter._print_NumberSymbolc                 C  s   |  | |S r   )_wrap_fortranindent_code)rk   linesro   ro   rp   _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rowsro   rp   	<genexpr>   s     
  z8FCodePrinter._traverse_matrix_indices.<locals>.<genexpr>)shaper   )rk   Zmatcolsro   r   rp   _traverse_matrix_indices   s    
z%FCodePrinter._traverse_matrix_indicesc                 C  s^   g }g }|D ]H}t | j|j|jd |jd g\}}}|d|||f  |d q||fS )N   zdo %s = %s, %send do)mapr   labelrz   upperr{   )rk   indicesZ
open_linesZclose_linesr   varstartstopro   ro   rp   _get_loop_opening_ending   s    
z%FCodePrinter._get_loop_opening_endingc                 C  s   ddl m} |j\}|jr4tdtd|t|d}nb|js@|jrrtt	t
dt
d||| t||t
d}n$tt
dtt
d|t|t
d}| |S )Nr   )rE   r   )Z$sympy.functions.elementary.complexesrE   args
is_integerr   r   r-   Z
is_complexis_infiniter   r    r   r   )rk   r}   rE   argZnew_exprro   ro   rp   _print_sign   s    2$zFCodePrinter._print_signc           
      C  s:  |j d jdkrtdg }|trt|j D ]t\}\}}|dkrZ|d| |  n:|t|j d kr|dkr|d n|d| |  || | q0|d	 d
	|S | j
d dkr.d}| |j d j}t|j d d }|r*| \}}| |}| |}	|j|||	d}q|S tdd S )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
rP   r[   zmerge({T}, {F}, {COND}))TFZCONDzmUsing Piecewise as an expression using inline operators is not supported in standards earlier than Fortran95.)r   condrh   hasr   	enumerater{   r   lenjoinrg   r}   listra   r   NotImplementedError)
rk   r}   r   r   ecpatternrq   Ztermsr   ro   ro   rp   _print_Piecewise   s0    




zFCodePrinter._print_Piecewisec                 C  s,   d | j|jtd dd|jd |jd S )Nz
{}({}, {})ZAtomT)strictr   )r   parenthesizeparentr1   r   r   r   ro   ro   rp   _print_MatrixElement   s      z!FCodePrinter._print_MatrixElementc           
      C  s  g }g }g }|j D ]>}|jr.|jr.|| q|jrF|jrF|| q|| q|r |rt|}t| }| |}|drd}	|dd  }nd}	t||k rd| }d| t| | t	j
 t|  |	|f S d| t| | t	j
 t|  f S nt| |S d S )N-r   +z(%s)zcmplx(%s,%s) %s %szcmplx(%s,%s))r   	is_numberZis_realr{   is_imaginaryr0   r'   r   
startswithr&   ImaginaryUnitr/   
_print_Add)
rk   r}   Z	pure_realZpure_imaginarymixedr   PRECtermtsignro   ro   rp   r     s>    


 zFCodePrinter._print_Addc                   sR   | j d   fdd|jD }|j| }t|ts<| |S t| |j| S d S )NrM   c                   s   g | ]}t | qS ro   )r(   )r   aprecro   rp   
<listcomp>.  s     z0FCodePrinter._print_Function.<locals>.<listcomp>)rg   r   func
isinstancer+   r   r/   _print_Function)rk   r}   r   Z	eval_exprro   r   rp   r   +  s    



zFCodePrinter._print_Functionc                 C  sB   | j d dkrd}t|n"|j\}}d| || |S d S )NrP   )rY   rL   z]Python % operator and SymPy's Mod() function are not supported by Fortran 66 or 77 standards.z      modulo({}, {}))rg   r   r   r   r   )rk   r}   msgxyro   ro   rp   
_print_Mod5  s
    

zFCodePrinter._print_Modc                 C  s   dS )Nz
cmplx(0,1)ro   r   ro   ro   rp   _print_ImaginaryUnitB  s    z!FCodePrinter._print_ImaginaryUnitc                 C  s   t |S r   r   r   ro   ro   rp   
_print_intF  s    zFCodePrinter._print_intc                 C  s2   |j r"|jr"d| tj |  S t| |S d S )Nzcmplx(0,%s))r   r   r   r&   r   r/   
_print_Mulr   ro   ro   rp   r   I  s
    zFCodePrinter._print_Mulc                 C  s   t |}t|jdr4d| td| |j|f S t|jdr|jjrr|jjr`d| |j S d| |j S qd| |j S nt	
| |S d S )Nr   z%s/%sr   g      ?zsqrt(%s.0d0)zsqrt(dble(%s))zsqrt(%s))r0   r,   r@   r   r    r   baser   Z	is_Numberr/   
_print_Pow)rk   r}   r   ro   ro   rp   r   R  s    zFCodePrinter._print_Powc                 C  s"   t |jt |j }}d||f S )Nz%d.0d0/%d.0d0)intr   q)rk   r}   r   r   ro   ro   rp   _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)rk   r}   Zprintedr   ro   ro   rp   r   i  s
    
 zFCodePrinter._print_Floatc                 C  sD   |  |j}|  |j}|j}|| jkr,|n| j| }d|||S )Nz{} {} {})r   lhsrhsZrel_op_relationalsr   )rk   r}   lhs_coderhs_codeopro   ro   rp   _print_Relationalp  s
    zFCodePrinter._print_Relationalc                   s0    fdd|j D }d |jjd|f S )Nc                   s   g | ]}  |qS ro   r   )r   r   rv   ro   rp   r   x  s     z/FCodePrinter._print_Indexed.<locals>.<listcomp>%s(%s), )r   r   r   r   r   )rk   r}   Zindsro   rv   rp   _print_Indexedw  s    zFCodePrinter._print_Indexedc                 C  s   |  |jS r   )r   r   r   ro   ro   rp   
_print_Idx{  s    zFCodePrinter._print_Idxc              	   C  s@   |  |j}|  |j}| d|  ||  |j|  |S )Nz{0} = {0} {1} {2})r   r   r   r   r   Zbinop)rk   r}   r   r   ro   ro   rp   _print_AugmentedAssignment~  s     
 z'FCodePrinter._print_AugmentedAssignmentc                 C  s^   |  |j}|jd kr*|d|  |j 7 }|jd krH|d|  |j 7 }d|jjd|f S )Nr   z, mask=r   rx   )r   arraydimmaskrn   __name__rstrip)rk   smparamsro   ro   rp   _print_sum_  s    

zFCodePrinter._print_sum_c                 C  s
   |  |S r   )r   )rk   prodro   ro   rp   _print_product_  s    zFCodePrinter._print_product_c                   s\   dg}|j dkr |d d}nd}d| d jf d|jr>dndi|j fd	d
|dS )N
concurrentr   stepru   , {step}z*do {concurrent}{counter} = {first}, {last}z
{body}
end do
zconcurrent c                   s
     | S r   r   r   rv   ro   rp   <lambda>      z(FCodePrinter._print_Do.<locals>.<lambda>)applyexclude)r   r{   r   r   kwargs)rk   doZexclr   ro   rv   rp   	_print_Do  s    


zFCodePrinter._print_Doc                   s6   |j dkrdnd}d| d jf |j fdddS )	Nr   ru   r   z$({expr}, {counter} = {first}, {last})c                   s
     | S r   r   r   rv   ro   rp   r     r   z3FCodePrinter._print_ImpliedDoLoop.<locals>.<lambda>r   )r   r   r   )rk   idlr   ro   rv   rp   _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   r  r   iterabler.   r   r   r  r   )rk   r}   r  r   r   r   r  ro   ro   rp   
_print_For  s       zFCodePrinter._print_Forc                 C  sP   | j ||}| j||j}| j|}|rL|D ]\}}| j| | q2|S r   )rW   re   rX   ry   type_modulesrj   r   )rk   type_Ztype_strrj   kvro   ro   rp   _print_Type  s    zFCodePrinter._print_Typec                   s,   dj  |jd fdd|jD dS )N{symbol}({idxs})r   c                 3  s   | ]}  |V  qd S r   r   r   r   rv   ro   rp   r     s     z.FCodePrinter._print_Element.<locals>.<genexpr>symbolZidxs)r   r   r  r   r   rk   elemro   rv   rp   _print_Element  s    
zFCodePrinter._print_Elementc                 C  s   t |S r   r   )rk   extro   ro   rp   _print_Extent  s    zFCodePrinter._print_Extentc              	     sV  |j j}d}fddtttfD }|ddkrBd}n4|ddkrjdd	d
dg|d  }ntd  t	t
rtd jd dkrdj jtjkrdnd|rdd fdd|D  nd|tjkrdnd jd}|d krR|d | 7 }n:tjks*|r2tdd fddjjfD }|S )N	dimensionc                   s   g | ]}| j kqS ro   )attrs)r   intent)r   ro   rp   r     s     z3FCodePrinter._print_Declaration.<locals>.<listcomp>Tr   ru   r   z, intent(%s)inoutZinoutz!Multiple intents specified for %sz1Pointers are not available by default in Fortran.rP   rZ   z"{t}{vc}{dim}{intent}{alloc} :: {s}z, parameterz, dimension(%s)r   c                 3  s   | ]}  |V  qd S r   r   r  rv   ro   rp   r     s     z2FCodePrinter._print_Declaration.<locals>.<genexpr>z, allocatable)r   vcr   r  Zallocsz = %sz0F77 init./parameter statem. req. multiple lines. c                 3  s   | ]}  |V  qd S r   r   r  rv   ro   rp   r     s     )variabler   attr_paramsr#   r$   r%   countindexrh   r   r   r   rg   r   r   typer	   r  r   r   r  )rk   r}   valr   Zintentsr  resultro   )rk   r   rp   _print_Declaration  s4    


"

 zFCodePrinter._print_Declarationc                 C  s   d|  td S )Nz(huge(%s) + 1)r   )r   r    r   ro   ro   rp   _print_Infinity  s    zFCodePrinter._print_Infinityc                   s   dj f |j fdddS )Nz$do while ({condition})
{body}
end doc                   s
     | S r   r   r   rv   ro   rp   r     r   z+FCodePrinter._print_While.<locals>.<lambda>r  r   r   r   ro   rv   rp   _print_While  s    

zFCodePrinter._print_Whilec                 C  s   dS )Nz.true.ro   r   ro   ro   rp   _print_BooleanTrue  s    zFCodePrinter._print_BooleanTruec                 C  s   dS )Nz.false.ro   r   ro   ro   rp   _print_BooleanFalse  s    z FCodePrinter._print_BooleanFalsec                 C  sR   g }|D ]D}| dr8|| jd |dd     q|| jd |  q|S )N!rs   r   rq   )r   r{   rw   lstrip)rk   r   r'  linero   ro   rp   _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rBd}nd}|D ]}|| jd	 r t|d
kr|ddd
}|dkrd
}|d| }||d 	 }|
| |r|ddd}|dkst|dk rd}|d| }||d 	 }|
d| jd	 |f  qn
|
| qJ|| jd r||d
}|d|  }||d 	 }|rj||7 }|
| |r||d}|d|  }||d 	 }|r||7 }|
d| jd |f  qtqJ|
| qJ|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                   sJ   t  |krt  S |} fdd}||sF|d8 }|dkr(|S q(|S )Nc                   sp    |  kr | d  kpn |  kr8 | d  kpn |  krT | d  kpn |  kon | d  kS )Nr   ro   )pos)r0  my_alnummy_whitero   rp   r     s    zDFCodePrinter._wrap_fortran.<locals>.split_pos_code.<locals>.<lambda>r   r   )r   )r0  endposr2  splitr3  r4  )r0  rp   split_pos_code  s    z2FCodePrinter._wrap_fortran.<locals>.split_pos_coderO   rt   z &ru   rs   H   r      r   Nr   rY   %s%srq   A   rr   )ri   stringdigitsascii_lettersrg   r   rw   r   rfindr/  r{   r   )rk   r   r8  r'  Ztrailingr0  r2  Zhunkro   r7  rp   r     sP    





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 ]\}}|dkr|
| q||| 8 }|rd||	 |  }nd| |	 }d||f }|s| |gd }|
| || rd|	 }nd}||| 7 }q|s<| 	|
S |
S )z0Accepts a string of code or a list of code linesTru   rO   rt   c                 S  s   g | ]}| d qS )z 	)r/  r   r0  ro   ro   rp   r   I  s     z,FCodePrinter.indent_code.<locals>.<listcomp>)zdo zif(zif zdo
r   programZ	interface)r   Zenddor   endifr   zend programzend interfacec                   s    g | ]}t tt|j qS ro   r   anyr   r   rA  )inc_keywordro   rp   r   N  s   c                   s    g | ]}t tt|j qS ro   rD  rA  )dec_keywordro   rp   r   P  s   c                 S  s$   g | ]}t tt|jd dgqS )&z&
)r   rE  r   endswithrA  ro   ro   rp   r   R  s   r      )ru   r   r   r;     )
r   r   r   
splitlinesr   rg   r   r{   r1  r   )rk   rq   Z
code_linesrt   ZincreaseZdecreaseZcontinuationlevelZcont_paddingZtabwidthZnew_coder   r0  paddingro   )rG  rF  rp   r   B  sN    








zFCodePrinter.indent_codec                   sL   |j r2djd fdd|jD  |j dS |j\}d | S d S )Nzgo to ({labels}), {expr}r   c                 3  s   | ]}  |V  qd S r   r   r  rv   ro   rp   r   w  s     z+FCodePrinter._print_GoTo.<locals>.<genexpr>)labelsr}   zgo to %s)r}   r   r   rO  r   )rk   ZgotoZlblro   rv   rp   _print_GoTot  s    
zFCodePrinter._print_GoToc                   s   dj f |j fdddS )Nz"program {name}
{body}
end program
c                   s
     | S r   r   r   rv   ro   rp   r     r   z-FCodePrinter._print_Program.<locals>.<lambda>r  r*  )rk   progro   rv   rp   _print_Program~  s    zFCodePrinter._print_Programc                   s   dj f |j fdddS )NzAmodule {name}
{declarations}

contains

{definitions}
end module
c                   s
     | S r   r   r   rv   ro   rp   r     r   z,FCodePrinter._print_Module.<locals>.<lambda>r  r*  )rk   modro   rv   rp   _print_Module  s    zFCodePrinter._print_Modulec                 C  sp   |j dkr,| jd dkr,| jd d dS |j dkrX| jd dkrX| jd d d	S |j dkrfd
S |j S d S )Nr   rP   r\   rI   zstdint=>input_unitZ
input_unitr   zstdint=>error_unitZ
error_unit*)ry   rg   rj   r   )rk   strmro   ro   rp   _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}rU  z3write(%(out)s, fmt="{fmt}", advance="no"), {iolist}r  06r   c                 3  s   | ]}  |V  qd S r   r   r  rv   ro   rp   r     s     z,FCodePrinter._print_Print.<locals>.<genexpr>)fmtZiolist)
format_stringr   r   r   re   filer   r   r   Z
print_args)rk   ZpstemplaterZ  ro   rv   rp   _print_Print  s    
 
zFCodePrinter._print_Printc                 C  s&   |j \}dj| jdd| |dS )Nz{result_name} = {arg}result_nameZsympy_result)r_  r   )r   r   _contextre   r   )rk   rsr   ro   ro   rp   _print_Return  s
    zFCodePrinter._print_Returnc                 C  s"   |j \}|rd| | S dS d S )Nz	return %sreturn)r   r   )rk   Zfrsr   ro   ro   rp   _print_FortranReturn  s    z!FCodePrinter._print_FortranReturnc                   s   | d}|d krd}n|r(d|d  nd} jdd }dj| |jd fd	d
|jD |rnd| nd|d fdd|jD dS )NZbind_Cru   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 ro   )r   r  r  rv   ro   rp   r     s     z&FCodePrinter._head.<locals>.<listcomp>z result(%s)r   c                 3  s   | ]}  t|V  qd S r   )r   r   r  rv   ro   rp   r     s     z%FCodePrinter._head.<locals>.<genexpr>)entityry   	arg_namesr'  bindZarg_declarations)r"  rg   re   r   r   ry   r   
parameters)rk   re  fpr   Zbind_C_paramsrg  r_  ro   rv   rp   _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_typerj  )rk   ri  re  ro   ro   rp   _print_FunctionPrototype  s
    
z%FCodePrinter._print_FunctionPrototypec              
   C  s|   t |jkrd}nt|jkr d}nd}d| |j}t| |jd. dj|| ||| |j	dW  5 Q R  S Q R X d S )Nz
elemental zpure ru   rk  )r_  z,{prefix}{function_head}
{body}
end function
)prefixrl  r  )
r!   r  r"   r   r   rm  r2   ry   rj  r  )rk   fdro  re  ro   ro   rp   _print_FunctionDefinition  s    



z&FCodePrinter._print_FunctionDefinitionc                 C  s   dj | d|| |jdS )Nz({subroutine_head}
{body}
end subroutine
zsubroutine )Zsubroutine_headr  )r   rj  r   r  )rk   subro   ro   rp   _print_Subroutine  s
    

zFCodePrinter._print_Subroutinec                   s,   dj  |jd fdd|jD dS )Nzcall {name}({args})r   c                 3  s   | ]}  |V  qd S r   r   r  rv   ro   rp   r     s     z5FCodePrinter._print_SubroutineCall.<locals>.<genexpr>)ry   r   )r   r   ry   r   Zsubroutine_args)rk   Zscallro   rv   rp   _print_SubroutineCall  s    
z"FCodePrinter._print_SubroutineCallc                   s   dt  fdd|jD  S )Nz%s => %sc                 3  s   | ]}  |V  qd S r   r   r  rv   ro   rp   r     s     z1FCodePrinter._print_use_rename.<locals>.<genexpr>)tupler   )rk   rnmro   rv   rp   _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rh|dd fdd|jD  7 }|S )Nzuse %sr   c                   s   g | ]}  |qS ro   r   )r   rv  rv   ro   rp   r     s     z+FCodePrinter._print_use.<locals>.<listcomp>z, only: c                   s   g | ]}  |qS ro   r   )r   Znlyrv   ro   rp   r     s     )r   	namespacerenamer   only)rk   Zuser'  ro   rv   rp   
_print_use  s    
"
"zFCodePrinter._print_usec                 C  s   dS )Nexitro   rk   rx   ro   ro   rp   _print_BreakToken   s    zFCodePrinter._print_BreakTokenc                 C  s   dS )Ncyclero   r}  ro   ro   rp   _print_ContinueToken  s    z!FCodePrinter._print_ContinueTokenc                   s4    j d dkrdnd}|d fdd|jD  S )NrP   r\   z[%s]z(/%s/)r   c                 3  s   | ]}  |V  qd S r   r   r  rv   ro   rp   r     s     z7FCodePrinter._print_ArrayConstructor.<locals>.<genexpr>)rg   r   elements)rk   acZfmtstrro   rv   rp   _print_ArrayConstructor  s    z$FCodePrinter._print_ArrayConstructorc                   s,   dj  |jd fdd|jD dS )Nr  r   c                 3  s   | ]}  |V  qd S r   r   r  rv   ro   rp   r     s     z3FCodePrinter._print_ArrayElement.<locals>.<genexpr>r  )r   r   ry   r   r   r  ro   rv   rp   _print_ArrayElement
  s    
z FCodePrinter._print_ArrayElement)N)\r   
__module____qualname____doc__Zprintmethodlanguager   r   r   r   r   r   rW   r   r
   r   r   r   r   r   r   rX   r  r_   r/   rR   __annotations__
_operatorsr   rc   propertyrw   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  r  r
  r  r  r  r(  r)  r+  r,  r-  r1  r   r   rP  rR  rT  rW  r^  rb  rd  rj  rn  rq  rs  rt  rw  r{  r~  r  r  r  __classcell__ro   ro   rm   rp   rG   F   s   
               
	 
*'
		!	G2
		
rG   )Er  
__future__r   typingr   collectionsr   	itertoolsr   r=  Zsympy.codegen.astr   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Zsympy.codegen.fnodesr   r   r   r   r   r    r!   r"   r#   r$   r%   Z
sympy.corer&   r'   r(   r)   r*   Zsympy.core.functionr+   Zsympy.core.numbersr,   Zsympy.core.relationalr-   Z
sympy.setsr.   Zsympy.printing.codeprinterr/   Zsympy.printing.precedencer0   r1   Zsympy.printing.printerr2   r3   r4   rd   rG   ro   ro   ro   rp   <module>   sF   \4