o
    *ήcn                     @   s  d Z ddlmZ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 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,m-Z-m.Z. dd	l/m0Z0 dd
l1m2Z2 ddl3m4Z4 ddl5m6Z6 ddl7m8Z8m9Z9 ddl:m;Z; ddl5m<Z<m=Z= 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$Z>G d%d& d&e6Z?dS )'aq  
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:

http://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.
    )DictAny)defaultdict)chainN)
AssignmentDeclarationPointervalue_constfloat32float64float80	complex64
complex128int8int16int32int64intcrealintegerbool_complex_)allocatableisigndsigncmplxmerge
literal_dp	elementalpure	intent_in
intent_outintent_inout)SAddNFloatSymbol)Function)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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dddi ddddddd
Z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 Z-dGdH Z.dIdJ Z/dKdL Z0dMdN Z1dOdP Z2dQdR Z3dSdT Z4dUdV Z5dWdX Z6dYdZ Z7d[d\ Z8d]d^ Z9d_d` Z:dadb Z;dcdd Z<dedf Z=dgdh Z>didj Z?dkdl Z@dmdn ZAdodp ZBdqdr ZCdsdt ZDdudv ZEdwdx ZFdydz ZGd{d| ZHd}d~ ZIdd ZJdd ZKdd ZLdd ZMdd ZNdd ZOdd ZPdd ZQdd ZRdd ZSdd ZTdd ZUdd ZV  ZWS )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_intNauto   TFfixedM   )
order	full_prec	precisionuser_functionshumanallow_unknown_functionssource_formatcontractstandardname_manglingz.and.z.or.z.neqv.z.eqv.z.not. )andorxor
equivalentnotz!=z/=c                    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_mappingsrS   >     B   rO   Z   _     rX   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__ =/tmp/pip-target-vg8gfxp4/lib/python/sympy/printing/fortran.pyrl   z   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  )NrV   rN   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 )NrY   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 )NrR   )_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   )r>   r   )$sympy.functions.elementary.complexesr>   args
is_integerr   r   r)   
is_complexis_infiniter   r   r   r   )rt   r   r>   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
rX   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parentr-   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_imaginaryr,   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 )NrR   c                    s   g | ]}t | qS rz   )r%   )r   aprecrz   r{   
<listcomp>0      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 )NrX   )rb   rO   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_Mod7  s
   
zFCodePrinter._print_Modc                 C      dS )Nz
cmplx(0,1)rz   r   rz   rz   r{   _print_ImaginaryUnitD  s   z!FCodePrinter._print_ImaginaryUnitc                 C      t |S r   r   r   rz   rz   r{   
_print_intH     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   K  s
   zFCodePrinter._print_Mulc                 C   s   t |}|jdkrd| td| |j|f S |jdkr>|jjr6|jjr.d| |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))
r,   r<   r   r   r   baser   	is_Numberr+   
_print_Pow)rt   r   r   rz   rz   r{   r   T  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_Rationalg  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  k  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_Relationalr  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   z  r   z/FCodePrinter._print_Indexed.<locals>.<listcomp>%s(%s), )r   r   r   r   r   )rt   r   indsrz   r   r{   _print_Indexedy  s   zFCodePrinter._print_Indexedc                 C   s   |  |jS r   )r   r   r   rz   rz   r{   
_print_Idx}  s   zFCodePrinter._print_Idxc                    s>     |j}  |j} djt fdd||j|g S )Nz{0} = {0} {1} {2}c                    
     | S r   r  r   r   rz   r{   <lambda>     
 z9FCodePrinter._print_AugmentedAssignment.<locals>.<lambda>)r   r  r  r   r   r   binop)rt   r   r
  r  rz   r   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                    r  r   r  r  r   rz   r{   r    r  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   sP   |  |j}t|jtr|jj\}}}ntd|  |j}dj|||||dS )Nz*Only iterable currently supported is Rangez3do {target} = {start}, {stop}, {step}
{body}
end do)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t fdd|jdS )Nz{symbol}({idxs})r  c                    r  r   r  r  r   rz   r{   r    r  z-FCodePrinter._print_Element.<locals>.<lambda>)symbolidxs)r   r   r=  r   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t f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t fddjjg}|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.rX   rc   z"{t}{vc}{dim}{intent}{alloc} :: {s}z, parameterz, dimension(%s)r  c                    r  r   r  r  r   rz   r{   r    r  z1FCodePrinter._print_Declaration.<locals>.<lambda>z, allocatable)r   vcr  rF  allocsz = %sz0F77 init./parameter statem. req. multiple lines. c                    r  r   r  r  r   rz   r{   r    r  )variabler   attr_paramsr    r!   r"   countindexrq   r   r   r   rp   r   r   typer	   rE  r   r   r   r=  )rt   r   valr  intentsrF  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   rU  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)r_  my_alnummy_whiterz   r{   r    s   zDFCodePrinter._wrap_fortran.<locals>.split_pos_code.<locals>.<lambda>r   r   )r   )r_  endposra  splitrb  rc  )r_  r{   split_pos_code  s   z2FCodePrinter._wrap_fortran.<locals>.split_pos_coderV   r   z &r   r~   H   rM     r   Nr   rb   %s%sr|   A   r}   )rr   stringdigitsascii_lettersrp   r   r   r   rfindr^  r   r  )rt   r   rg  rU  trailingr_  ra  hunkrz   rf  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   rV   r   c                 S   s   g | ]}| d qS )z 	)r^  r   r_  rz   rz   r{   r   L  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   rr  )inc_keywordrz   r{   r   Q      c                    rw  rz   rx  rr  )dec_keywordrz   r{   r   S  r{  c                 S   s$   g | ]}t tt|jd dgqS )&z&
)r   ry  r   endswithrr  rz   rz   r{   r   U  s    r      )r   r   rM  rj     )
r   r   r   
splitlinesr   rp   r   r   r`  r   )rt   r|   
code_linesr   increasedecreasecontinuationlevelcont_paddingtabwidthnew_coder   r_  paddingrz   )r|  rz  r{   r   E  sN   







zFCodePrinter.indent_codec                    sH   |j rdjdt fdd|j |j dS |j\}d | S )Nzgo to ({labels}), {expr}r  c                    r  r   r  r  r   rz   r{   r  z  r  z*FCodePrinter._print_GoTo.<locals>.<lambda>)labelsr   zgo to %s)r   r   r   r   r  r   )rt   gotolblrz   r   r{   _print_GoTow  s   
zFCodePrinter._print_GoToc                    rX  )Nz"program {name}
{body}
end program
c                    r  r   r  r  r   rz   r{   r    r  z-FCodePrinter._print_Program.<locals>.<lambda>r/  rz   rY  )rt   progrz   r   r{   _print_Program  s
   zFCodePrinter._print_Programc                    rX  )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   rY  )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 )NstdoutrX   re   rJ   zstdint=>input_unit
input_unitstderrzstdint=>error_unit
error_unit*)r   rp   rs   r   )rt   strmrz   rz   r{   _print_Stream  s   
zFCodePrinter._print_Streamc                    s@   |j d kr |j }nd}dj|dt fdd|jdS )Nr  zprint {fmt}, {iolist}r  c                    r  r   r  r  r   rz   r{   r    r  z+FCodePrinter._print_Print.<locals>.<lambda>)fmtiolist)format_stringr   r   r   r   
print_args)rt   psr  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t fdd|j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   r=  )r   r   r   rz   r{   r     s    z&FCodePrinter._head.<locals>.<listcomp>z result(%s)r   c                    s     t| S r   )r   r   r  r   rz   r{   r    s    z$FCodePrinter._head.<locals>.<lambda>)entityr   	arg_namesrU  bindarg_declarations)	rO  rp   rn   r   r   r   r   
parametersr   )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   rE  r   r   r   r  r.   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                    r  r   r  r  r   rz   r{   r    r  z4FCodePrinter._print_SubroutineCall.<locals>.<lambda>)r   r   )r   r   r   r   r   subroutine_args)rt   scallrz   r   r{   _print_SubroutineCall  rA  z"FCodePrinter._print_SubroutineCallc                    s   dt t fdd|j S )Nz%s => %sc                    r  r   r  r  r   rz   r{   r    r  z0FCodePrinter._print_use_rename.<locals>.<lambda>)tupler   r   )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   userU  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t fdd|j S )NrX   re   z[%s]z(/%s/)r  c                    r  r   r  r  r   rz   r{   r    r  z6FCodePrinter._print_ArrayConstructor.<locals>.<lambda>)rp   r   r   elements)rt   acfmtstrrz   r   r{   _print_ArrayConstructor  s   z$FCodePrinter._print_ArrayConstructorr   )Xr  
__module____qualname____doc__printmethodlanguager   r   r   r   r   r   r_   r   r
   r   r   r   r   r   r   r`   r6  _default_settings
_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;  r@  rC  rV  rW  rZ  r[  r\  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{   rF   D   s    	
*'
		!	G2
		
rF   )@r  typingr   tDictr   collectionsr   	itertoolsr   rl  sympy.codegen.astr   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.relationalr)   
sympy.setsr*   sympy.printing.codeprinterr+   sympy.printing.precedencer,   r-   sympy.printing.printerr.   r/   r0   rm   rF   rz   rz   rz   r{   <module>   sf    P4	
