§
    «³ÙgóI  ã                   óV  — d Z ddlmZmZmZmZmZmZmZm	Z	m
Z
 ddlmZ ddlmZ ddlmZ ddlmZ ddlmZmZ ddlmZ dd	lmZ dd
lmZmZ ddlmZ  ed¦  «        Z ed¦  «        Z  ed¦  «        Z! ed¦  «        Z" ed¦  «        Z# ed¦  «        Z$ G d„ de¦  «        Z% G d„ de¦  «        Z&d„ Z' G d„ de¦  «        Z( G d„ de¦  «        Z) G d„ de¦  «        Z* G d„ de¦  «        Z+ G d„ d e¦  «        Z, G d!„ d"e¦  «        Z- G d#„ d$e¦  «        Z. G d%„ d&e¦  «        Z/ e/¦   «         Z0d'„ Z1 e1d(¦  «        Z2dQd*d)d)d+œd,„Z3d-„ Z4d.„ Z5dRd/„Z6dRd0„Z7dQd1„Z8dRd2„Z9dRd3„Z:dQd4„Z; G d5„ d6e¦  «        Z< G d7„ d8e¦  «        Z= G d9„ d:e¦  «        Z> G d;„ d<e>¦  «        Z? G d=„ d>e>¦  «        Z@ G d?„ d@e>¦  «        ZA G dA„ dBe>¦  «        ZB G dC„ dDe>¦  «        ZC G dE„ dFe?¦  «        ZD G dG„ dHe¦  «        ZE G dI„ dJeE¦  «        ZF G dK„ dLeE¦  «        ZG G dM„ dNee¦  «        ZH G dO„ dPee¦  «        ZId)S )Sz¬
AST nodes specific to Fortran.

The functions defined in this module allows the user to express functions such as ``dsign``
as a SymPy function for symbolic manipulation.
é    )	Ú	AttributeÚ	CodeBlockÚFunctionCallÚNodeÚnoneÚStringÚTokenÚ	_mk_TupleÚVariable)ÚBasic©ÚTuple)ÚExpr)ÚFunction)ÚFloatÚInteger)ÚStr)Úsympify©ÚtrueÚfalse)ÚiterableÚpureÚ	elementalÚ	intent_inÚ
intent_outÚintent_inoutÚallocatablec                   ó6   — e Zd ZdZdxZZeZ ed„ ¦  «        Z	dS )ÚProgramaf   Represents a 'program' block in Fortran.

    Examples
    ========

    >>> from sympy.codegen.ast import Print
    >>> from sympy.codegen.fnodes import Program
    >>> prog = Program('myprogram', [Print([42])])
    >>> from sympy import fcode
    >>> print(fcode(prog, source_format='free'))
    program myprogram
        print *, 42
    end program

    )ÚnameÚbodyc                 ó   — t          | Ž S ©N©r   ©r"   s    úJ/granary/edev/quantum/lib/python3.11/site-packages/sympy/codegen/fnodes.pyú<lambda>zProgram.<lambda>3   ó   € µ	¸4Ð0@€ ó    N)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__Ú_fieldsr   Ú_construct_nameÚstaticmethodÚ_construct_body© r*   r'   r    r    !   s<   € € € € € ðð ð +Ð*€I�Ø€OØ"�lÐ#@Ð#@ÑAÔA€O€O€Or*   r    c                   ó"   — e Zd ZdZdxZZeZeZdS )Ú
use_renameaÊ   Represents a renaming in a use statement in Fortran.

    Examples
    ========

    >>> from sympy.codegen.fnodes import use_rename, use
    >>> from sympy import fcode
    >>> ren = use_rename("thingy", "convolution2d")
    >>> print(fcode(ren, source_format='free'))
    thingy => convolution2d
    >>> full = use('signallib', only=['snr', ren])
    >>> print(fcode(full, source_format='free'))
    use signallib, only: snr, thingy => convolution2d

    )ÚlocalÚoriginalN)	r+   r,   r-   r.   r/   r0   r   Ú_construct_localÚ_construct_originalr4   r*   r'   r6   r6   6   s2   € € € € € ðð ð 0Ð/€I�ØÐØ ÐÐÐr*   r6   c                 óN   — t          | d¦  «        r| j        S t          | ¦  «        S )Nr!   )Úhasattrr!   r   ©Úargs    r'   Ú_namer?   J   s'   € Ýˆs�FÑÔð ØŒxˆå�c‰{Œ{Ðr*   c                   ój   — e Zd ZdZdxZZeedœZ ee	¦  «        Z
 ed„ ¦  «        Z ed„ ¦  «        ZdS )ÚuseaÑ   Represents a use statement in Fortran.

    Examples
    ========

    >>> from sympy.codegen.fnodes import use
    >>> from sympy import fcode
    >>> fcode(use('signallib'), source_format='free')
    'use signallib'
    >>> fcode(use('signallib', [('metric', 'snr')]), source_format='free')
    'use signallib, metric => snr'
    >>> fcode(use('signallib', only=['snr', 'convolution2d']), source_format='free')
    'use signallib, only: snr, convolution2d'

    )Ú	namespaceÚrenameÚonly)rC   rD   c                 ó(   — t          d„ | D ¦   «         Ž S )Nc                 óN   — g | ]"}t          |t          ¦  «        r|nt          |Ž ‘Œ#S r4   )Ú
isinstancer6   ©Ú.0r>   s     r'   ú
<listcomp>z use.<lambda>.<locals>.<listcomp>c   sF   € ð  :Dð  :Dð  :DÐwzÅÈCÕQ[ÑA\ÔA\Ð:r¸#¸#ÕblÐnqÐbrð  :Dð  :Dð  :Dr*   r   ©Úargss    r'   r(   zuse.<lambda>c   s1   € µ%ð  :Dð  :Dð  Cð  :Dñ  :Dô  :Dð  3E€ r*   c                 ó(   — t          d„ | D ¦   «         Ž S )Nc                 óZ   — g | ](}t          |t          ¦  «        r|nt          |¦  «        ‘Œ)S r4   )rG   r6   r?   rH   s     r'   rJ   z use.<lambda>.<locals>.<listcomp>d   s6   € Ð7{Ð7{Ð7{Ðor½zÈ#ÍzÑ?ZÔ?ZÐ8j¸¸Õ`eÐfiÑ`jÔ`jÐ7{Ð7{Ð7{r*   r   rK   s    r'   r(   zuse.<lambda>d   s   € µÐ7{Ð7{ÐvzÐ7{Ñ7{Ô7{Ð0|€ r*   N)r+   r,   r-   r.   r/   r0   r   Údefaultsr2   r?   Ú_construct_namespaceÚ_construct_renameÚ_construct_onlyr4   r*   r'   rA   rA   P   st   € € € € € ðð ð :Ð9€I�Ø¨Ð-Ð-€HØ'˜<¨Ñ.Ô.ÐØ$˜ð  &Eð  &Eñ  Fô  FÐØ"�lÐ#|Ð#|Ñ}Ô}€O€O€Or*   rA   c                   ód   — e Zd ZdZdxZZd e¦   «         iZeZ	e
d„ ¦   «         Z ed„ ¦  «        ZdS )ÚModulea\   Represents a module in Fortran.

    Examples
    ========

    >>> from sympy.codegen.fnodes import Module
    >>> from sympy import fcode
    >>> print(fcode(Module('signallib', ['implicit none'], []), source_format='free'))
    module signallib
    implicit none
    <BLANKLINE>
    contains
    <BLANKLINE>
    <BLANKLINE>
    end module

    )r!   ÚdeclarationsÚdefinitionsrU   c                 ó,   — d„ |D ¦   «         }t          |Ž S )Nc                 óZ   — g | ](}t          |t          ¦  «        rt          |¦  «        n|‘Œ)S r4   )rG   Ústrr   rH   s     r'   rJ   z2Module._construct_declarations.<locals>.<listcomp>   s1   € ÐJÐJÐJ¸c�J s­CÑ0Ô0Ð9•�C‘”�°cÐJÐJÐJr*   r%   )ÚclsrL   s     r'   Ú_construct_declarationszModule._construct_declarations}   s    € àJÐJÀTÐJÑJÔJˆÝ˜$ÐÐr*   c                 ó   — t          | Ž S r$   r%   r=   s    r'   r(   zModule.<lambda>‚   s
   € µiÀ°o€ r*   N)r+   r,   r-   r.   r/   r0   r   rO   r   r1   Úclassmethodr[   r2   Ú_construct_definitionsr4   r*   r'   rT   rT   g   sk   € € € € € ðð ð" BÐA€I�Ø  ¡¤Ð(€HØ€Oàð ð  ñ „[ð ð *˜\Ð*EÐ*EÑFÔFÐÐÐr*   rT   c                   ó\   — e Zd ZdZdZeej        z   ZeZ e	d„ ¦  «        Z
ed„ ¦   «         ZdS )Ú
Subroutineaê   Represents a subroutine in Fortran.

    Examples
    ========

    >>> from sympy import fcode, symbols
    >>> from sympy.codegen.ast import Print
    >>> from sympy.codegen.fnodes import Subroutine
    >>> x, y = symbols('x y', real=True)
    >>> sub = Subroutine('mysub', [x, y], [Print([x**2 + y**2, x*y])])
    >>> print(fcode(sub, source_format='free', standard=2003))
    subroutine mysub(x, y)
    real*8 :: x
    real*8 :: y
    print *, x**2 + y**2, x*y
    end subroutine

    )r!   Ú
parametersr"   c                 óD   — t          t          t          j        | ¦  «        Ž S r$   )r   Úmapr   Údeduced)Úparamss    r'   r(   zSubroutine.<lambda>›   s   € ½½sÅ8ÔCSÐU[Ñ?\Ô?\Ð8]€ r*   c                 óB   — t          |t          ¦  «        r|S t          |Ž S r$   )rG   r   )rZ   Úitrs     r'   r3   zSubroutine._construct_body�   s#   € å�c�9Ñ%Ô%ð 	#ØˆJå˜c�?Ð"r*   N)r+   r,   r-   r.   r/   r   r0   r   r1   r2   Ú_construct_parametersr]   r3   r4   r*   r'   r`   r`   …   sc   € € € € € ðð ð$ /€IØ˜$œ,Ñ&€GØ€OØ(˜LÐ)]Ð)]Ñ^Ô^Ðàð#ð #ñ „[ð#ð #ð #r*   r`   c                   óF   — e Zd ZdZdxZZ ee¦  «        Z ee	¦  «        Z
dS )ÚSubroutineCallzü Represents a call to a subroutine in Fortran.

    Examples
    ========

    >>> from sympy.codegen.fnodes import SubroutineCall
    >>> from sympy import fcode
    >>> fcode(SubroutineCall('mysub', 'x y'.split()))
    '       call mysub(x, y)'

    )r!   Úsubroutine_argsN)r+   r,   r-   r.   r/   r0   r2   r?   r1   r
   Ú_construct_subroutine_argsr4   r*   r'   rj   rj   ¤   sE   € € € € € ð
ð 
ð 6Ð5€I�Ø"�l 5Ñ)Ô)€OØ!- ¨iÑ!8Ô!8ÐÐÐr*   rj   c                   ó¾   — e Zd ZdZdxZZ ed¦  «        edœZ e	d„ ¦  «        Z
 e	e¦  «        Z e	e¦  «        Z e	e¦  «        Z e	e¦  «        Z e	d„ ¦  «        ZdS )ÚDoa�   Represents a Do loop in in Fortran.

    Examples
    ========

    >>> from sympy import fcode, symbols
    >>> from sympy.codegen.ast import aug_assign, Print
    >>> from sympy.codegen.fnodes import Do
    >>> i, n = symbols('i n', integer=True)
    >>> r = symbols('r', real=True)
    >>> body = [aug_assign(r, '+', 1/i), Print([i, r])]
    >>> do1 = Do(body, i, 1, n)
    >>> print(fcode(do1, source_format='free'))
    do i = 1, n
        r = r + 1d0/i
        print *, i, r
    end do
    >>> do2 = Do(body, i, 1, n, 2)
    >>> print(fcode(do2, source_format='free'))
    do i = 1, n, 2
        r = r + 1d0/i
        print *, i, r
    end do

    )r"   ÚcounterÚfirstÚlastÚstepÚ
concurrenté   )rr   rs   c                 ó   — t          | Ž S r$   r%   r&   s    r'   r(   zDo.<lambda>Ò   r)   r*   c                 ó"   — | rt           nt          S r$   r   r=   s    r'   r(   zDo.<lambda>×   s   € ¸SÐ5KµT°TÅe€ r*   N)r+   r,   r-   r.   r/   r0   r   r   rO   r2   r3   r   Ú_construct_counterÚ_construct_firstÚ_construct_lastÚ_construct_stepÚ_construct_concurrentr4   r*   r'   rn   rn   µ   s¡   € € € € € ðð ð4 UÐT€I�Ø˜ ™
œ
°%Ð8Ð8€HØ"�lÐ#@Ð#@ÑAÔA€OØ%˜ gÑ.Ô.ÐØ#�| GÑ,Ô,ÐØ"�l 7Ñ+Ô+€OØ"�l 7Ñ+Ô+€OØ(˜LÐ)KÐ)KÑLÔLÐÐÐr*   rn   c                   ó0   — e Zd ZdZdxZZ ee¦  «        ZdS )ÚArrayConstructoraT   Represents an array constructor.

    Examples
    ========

    >>> from sympy import fcode
    >>> from sympy.codegen.fnodes import ArrayConstructor
    >>> ac = ArrayConstructor([1, 2, 3])
    >>> fcode(ac, standard=95, source_format='free')
    '(/1, 2, 3/)'
    >>> fcode(ac, standard=2003, source_format='free')
    '[1, 2, 3]'

    )ÚelementsN)	r+   r,   r-   r.   r/   r0   r2   r
   Ú_construct_elementsr4   r*   r'   r}   r}   Ú   s6   € € € € € ðð ð (Ð'€I�Ø&˜, yÑ1Ô1ÐÐÐr*   r}   c                   ó¢   — e Zd ZdZdxZZd ed¦  «        iZ ee	¦  «        Z
 ee	¦  «        Z ee	¦  «        Z ee	¦  «        Z ee	¦  «        ZdS )ÚImpliedDoLoopaÉ   Represents an implied do loop in Fortran.

    Examples
    ========

    >>> from sympy import Symbol, fcode
    >>> from sympy.codegen.fnodes import ImpliedDoLoop, ArrayConstructor
    >>> i = Symbol('i', integer=True)
    >>> idl = ImpliedDoLoop(i**3, i, -3, 3, 2)  # -27, -1, 1, 27
    >>> ac = ArrayConstructor([-28, idl, 28]) # -28, -27, -1, 1, 27, 28
    >>> fcode(ac, standard=2003, source_format='free')
    '[-28, (i**3, i = -3, 3, 2), 28]'

    )Úexprro   rp   rq   rr   rr   rt   N)r+   r,   r-   r.   r/   r0   r   rO   r2   r   Ú_construct_exprrw   rx   ry   rz   r4   r*   r'   r�   r�   í   s„   € € € € € ðð ð GÐF€I�Ø˜˜ ™
œ
Ð#€HØ"�l 7Ñ+Ô+€OØ%˜ gÑ.Ô.ÐØ#�| GÑ,Ô,ÐØ"�l 7Ñ+Ô+€OØ"�l 7Ñ+Ô+€O€O€Or*   r�   c                   ó   — e Zd ZdZd„ Zd„ ZdS )ÚExtentaC   Represents a dimension extent.

    Examples
    ========

    >>> from sympy.codegen.fnodes import Extent
    >>> e = Extent(-3, 3)  # -3, -2, -1, 0, 1, 2, 3
    >>> from sympy import fcode
    >>> fcode(e, source_format='free')
    '-3:3'
    >>> from sympy.codegen.ast import Variable, real
    >>> from sympy.codegen.fnodes import dimension, intent_out
    >>> dim = dimension(e, e)
    >>> arr = Variable('x', real, attrs=[dim, intent_out])
    >>> fcode(arr.as_Declaration(), source_format='free', standard=2003)
    'real*8, dimension(-3:3, -3:3), intent(out) :: x'

    c                 ó8  — t          |¦  «        dk    r5|\  }}t          j        | t          |¦  «        t          |¦  «        ¦  «        S t          |¦  «        dk    st          |¦  «        dk    r|d         dv rt          j        | ¦  «        S t	          d¦  «        ‚)Né   r   rt   )ú:Nz5Expected 0 or 2 args (or one argument == None or ':'))Úlenr   Ú__new__r   Ú
ValueError)rZ   rL   ÚlowÚhighs       r'   rŠ   zExtent.__new__  s„   € Ýˆt‰9Œ9˜Š>ˆ>Ø‰IˆC�Ý”= ¥g¨c¡l¤lµG¸D±M´MÑBÔBÐBÝ�‰YŒY˜!Š^ˆ^¥ D¡	¤	¨Q¢ °4¸´7¸kÐ3IÐ3IÝ”= Ñ%Ô%Ð%åÐTÑUÔUÐUr*   c                 ó~   — t          | j        ¦  «        dk    rdS d                     d„ | j        D ¦   «         ¦  «        S )Nr   rˆ   c              3   ó4   K  — | ]}t          |¦  «        V — Œd S r$   )rY   rH   s     r'   ú	<genexpr>z#Extent._sympystr.<locals>.<genexpr>$  s(   è è € Ð6Ð6 S�˜C™œÐ6Ð6Ð6Ð6Ð6Ð6r*   )r‰   rL   Újoin)ÚselfÚprinters     r'   Ú	_sympystrzExtent._sympystr!  s=   € ÝˆtŒy‰>Œ>˜QÒÐØ�3Ø�xŠxÐ6Ð6¨D¬IÐ6Ñ6Ô6Ñ6Ô6Ð6r*   N)r+   r,   r-   r.   rŠ   r”   r4   r*   r'   r…   r…     s?   € € € € € ðð ð$Vð Vð Vð7ð 7ð 7ð 7ð 7r*   r…   c                  ój  — t          | ¦  «        dk    rt          d¦  «        ‚g }| D ]Û}t          |t          ¦  «        r|                     |¦  «         Œ-t          |t
          ¦  «        rK|dk    r"|                     t          ¦   «         ¦  «         Œj|                     t          |¦  «        ¦  «         Œ�t          |¦  «        r|                     t          |Ž ¦  «         Œ¹|                     t          |¦  «        ¦  «         ŒÜt          | ¦  «        dk    rt          d¦  «        ‚t          d|¦  «        S )aú   Creates a 'dimension' Attribute with (up to 7) extents.

    Examples
    ========

    >>> from sympy import fcode
    >>> from sympy.codegen.fnodes import dimension, intent_in
    >>> dim = dimension('2', ':')  # 2 rows, runtime determined number of columns
    >>> from sympy.codegen.ast import Variable, integer
    >>> arr = Variable('a', integer, attrs=[dim, intent_in])
    >>> fcode(arr.as_Declaration(), source_format='free', standard=2003)
    'integer*4, dimension(2, :), intent(in) :: a'

    é   z0Fortran only supports up to 7 dimensional arraysrˆ   r   zNeed at least one dimensionÚ	dimension)
r‰   r‹   rG   r…   ÚappendrY   r   r   r   r   )rL   ra   r>   s      r'   r—   r—   )  s&  € õ ˆ4�y„y�1‚}€}ÝÐKÑLÔLÐLØ€JØð ,ð ,ˆÝ�c�6Ñ"Ô"ð 
	,Ø×Ò˜cÑ"Ô"Ð"Ð"Ý˜�SÑ!Ô!ð 	,Ø�cŠzˆzØ×!Ò!¥&¡(¤(Ñ+Ô+Ð+Ð+à×!Ò!¥&¨¡+¤+Ñ.Ô.Ð.Ð.Ý�c‰]Œ]ð 	,Ø×Ò�f c˜lÑ+Ô+Ð+Ð+à×Ò�g c™lœlÑ+Ô+Ð+Ð+Ý
ˆ4�y„y�A‚~€~ÝÐ6Ñ7Ô7Ð7Ý�[ *Ñ-Ô-Ð-r*   Ú*Nr4   )ÚattrsÚvalueÚtypec                ó¼  — t          |t          ¦  «        r8t          |j        ¦  «        dk    rt	          dt          |¦  «        z  ¦  «        ‚n	t          |Ž }t          |¦  «        |gz   }|�F|t          t          t          fvrt          t          t          dœ|         }| 
                    |¦  «         |€t          j        | ||¬¦  «        S t          | |||¬¦  «        S )aë   Convenience function for creating a Variable instance for a Fortran array.

    Parameters
    ==========

    symbol : symbol
    dim : Attribute or iterable
        If dim is an ``Attribute`` it need to have the name 'dimension'. If it is
        not an ``Attribute``, then it is passed to :func:`dimension` as ``*dim``
    intent : str
        One of: 'in', 'out', 'inout' or None
    \*\*kwargs:
        Keyword arguments for ``Variable`` ('type' & 'value')

    Examples
    ========

    >>> from sympy import fcode
    >>> from sympy.codegen.ast import integer, real
    >>> from sympy.codegen.fnodes import array
    >>> arr = array('a', '*', 'in', type=integer)
    >>> print(fcode(arr.as_Declaration(), source_format='free', standard=2003))
    integer*4, dimension(*), intent(in) :: a
    >>> x = array('x', [3, ':', ':'], intent='out', type=real)
    >>> print(fcode(x.as_Declaration(value=1), source_format='free', standard=2003))
    real*8, dimension(3, :, :), intent(out) :: x = 1

    r—   z/Got an unexpected Attribute argument as dim: %sN)ÚinÚoutÚinout)r›   rš   )rG   r   rY   r!   r‹   r—   Úlistr   r   r   r˜   r   rd   )ÚsymbolÚdimÚintentrš   r›   rœ   s         r'   Úarrayr¥   N  sÜ   € õ: �#•yÑ!Ô!ð ÝˆsŒx‰=Œ=˜KÒ'Ð'ÝÐNÕQTÐUXÑQYÔQYÑYÑZÔZÐZð (õ ˜ˆoˆå�‰KŒK˜3˜%Ñ€EØÐØ�)¥ZµÐ>Ð>Ð>Ý%­jÅ<ÐPÐPÐQWÔXˆFØ�Š�VÑÔÐØ€|ÝÔ ¨e¸5ÐAÑAÔAÐAå˜ ¨E¸Ð?Ñ?Ô?Ð?r*   c                 óh   — t          | t          ¦  «        rt          | ¦  «        nt          | ¦  «        S r$   )rG   rY   r   r   r=   s    r'   Ú
_printabler§   {  s'   € Ý$ S­#Ñ.Ô.Ð@�6�#‰;Œ;ˆ;µG¸C±L´LÐ@r*   c                 ó>   — t          dt          | ¦  «        g¦  «        S )a   Creates an AST node for a function call to Fortran's "allocated(...)"

    Examples
    ========

    >>> from sympy import fcode
    >>> from sympy.codegen.fnodes import allocated
    >>> alloc = allocated('x')
    >>> fcode(alloc, source_format='free')
    'allocated(x)'

    Ú	allocated©r   r§   )r¥   s    r'   r©   r©     s   € õ ˜¥j°Ñ&7Ô&7Ð%8Ñ9Ô9Ð9r*   c                 ó’   — t          dt          | ¦  «        g|rt          |¦  «        gng z   |rt          |¦  «        gng z   ¦  «        S )ap   Creates an AST node for a function call to Fortran's "lbound(...)"

    Parameters
    ==========

    array : Symbol or String
    dim : expr
    kind : expr

    Examples
    ========

    >>> from sympy import fcode
    >>> from sympy.codegen.fnodes import lbound
    >>> lb = lbound('arr', dim=2)
    >>> fcode(lb, source_format='free')
    'lbound(arr, 2)'

    Úlboundrª   ©r¥   r£   Úkinds      r'   r¬   r¬   �  s_   € õ( ØÝ	�EÑ	Ô	ÐØ!Ð	)�*�S‰/Œ/Ð	Ð	 rñ	+à#Ð	+�*�TÑ
Ô
Ð	Ð	¨ñ	-ñô ð r*   c                 ó’   — t          dt          | ¦  «        g|rt          |¦  «        gng z   |rt          |¦  «        gng z   ¦  «        S )NÚuboundrª   r­   s      r'   r°   r°   «  s]   € ÝØÝ	�EÑ	Ô	ÐØ!Ð	)�*�S‰/Œ/Ð	Ð	 rñ	+à#Ð	+�*�TÑ
Ô
Ð	Ð	¨ñ	-ñô ð r*   c                 óh   — t          dt          | ¦  «        g|rt          |¦  «        gng z   ¦  «        S )aR   Creates an AST node for a function call to Fortran's "shape(...)"

    Parameters
    ==========

    source : Symbol or String
    kind : expr

    Examples
    ========

    >>> from sympy import fcode
    >>> from sympy.codegen.fnodes import shape
    >>> shp = shape('x')
    >>> fcode(shp, source_format='free')
    'shape(x)'

    Úshaperª   )Úsourcer®   s     r'   r²   r²   ´  sD   € õ& ØÝ	�FÑ	Ô	ÐØ#Ð	+�*�TÑ
Ô
Ð	Ð	¨ñ	-ñô ð r*   c                 ó’   — t          dt          | ¦  «        g|rt          |¦  «        gng z   |rt          |¦  «        gng z   ¦  «        S )a…   Creates an AST node for a function call to Fortran's "size(...)"

    Examples
    ========

    >>> from sympy import fcode, Symbol
    >>> from sympy.codegen.ast import FunctionDefinition, real, Return
    >>> from sympy.codegen.fnodes import array, sum_, size
    >>> a = Symbol('a', real=True)
    >>> body = [Return((sum_(a**2)/size(a))**.5)]
    >>> arr = array(a, dim=[':'], intent='in')
    >>> fd = FunctionDefinition(real, 'rms', [arr], body)
    >>> print(fcode(fd, source_format='free', standard=2003))
    real*8 function rms(a)
    real*8, dimension(:), intent(in) :: a
    rms = sqrt(sum(a**2)*1d0/size(a))
    end function

    Úsizerª   r­   s      r'   rµ   rµ   Î  s_   € õ( ØÝ	�EÑ	Ô	ÐØ!Ð	)�*�S‰/Œ/Ð	Ð	 rñ	+à#Ð	+�*�TÑ
Ô
Ð	Ð	¨ñ	-ñô ð r*   c                 ó®   — t          dt          | ¦  «        t          |¦  «        g|rt          |¦  «        gng z   |rt          |¦  «        gng z   ¦  «        S )zž Creates an AST node for a function call to Fortran's "reshape(...)"

    Parameters
    ==========

    source : Symbol or String
    shape : ArrayExpr

    Úreshaperª   )r³   r²   ÚpadÚorders       r'   r·   r·   ê  si   € õ ØÝ	�FÑ	Ô	�Z¨Ñ.Ô.Ð/Ø!Ð	)�*�S‰/Œ/Ð	Ð	 rñ	+à #Ð	+�*�UÑ
Ô
Ð	Ð	¨ñ	-ñô ð r*   c                 óF   — t          d| rt          | ¦  «        gng ¦  «        S )aú   Creates an Attribute ``bind_C`` with a name.

    Parameters
    ==========

    name : str

    Examples
    ========

    >>> from sympy import fcode, Symbol
    >>> from sympy.codegen.ast import FunctionDefinition, real, Return
    >>> from sympy.codegen.fnodes import array, sum_, bind_C
    >>> a = Symbol('a', real=True)
    >>> s = Symbol('s', integer=True)
    >>> arr = array(a, dim=[s], intent='in')
    >>> body = [Return((sum_(a**2)/s)**.5)]
    >>> fd = FunctionDefinition(real, 'rms', [arr, s], body, attrs=[bind_C('rms')])
    >>> print(fcode(fd, source_format='free', standard=2003))
    real*8 function rms(a, s) bind(C, name="rms")
    real*8, dimension(s), intent(in) :: a
    integer*4 :: s
    rms = sqrt(sum(a**2)/s)
    end function

    Úbind_C)r   r   )r!   s    r'   r»   r»   ü  s%   € õ6 �X°Ð=¥ t¡¤˜~˜~¸2Ñ>Ô>Ð>r*   c                   óN   — e Zd ZdZdxZZdeiZ ee	¦  «        Z
 ee¦  «        ZdS )ÚGoToa    Represents a goto statement in Fortran

    Examples
    ========

    >>> from sympy.codegen.fnodes import GoTo
    >>> go = GoTo([10, 20, 30], 'i')
    >>> from sympy import fcode
    >>> fcode(go, source_format='free')
    'go to (10, 20, 30), i'

    )Úlabelsr‚   r‚   N)r+   r,   r-   r.   r/   r0   r   rO   r2   r
   Ú_construct_labelsr   rƒ   r4   r*   r'   r½   r½     sL   € € € € € ðð ð -Ð,€I�Ø˜ˆ~€HØ$˜ YÑ/Ô/ÐØ"�l 7Ñ+Ô+€O€O€Or*   r½   c                   ó8   — e Zd ZdZdxZZdeiZ ee	¦  «        Z
dS )ÚFortranReturnaK   AST node explicitly mapped to a fortran "return".

    Explanation
    ===========

    Because a return statement in fortran is different from C, and
    in order to aid reuse of our codegen ASTs the ordinary
    ``.codegen.ast.Return`` is interpreted as assignment to
    the result variable of the function. If one for some reason needs
    to generate a fortran RETURN statement, this node should be used.

    Examples
    ========

    >>> from sympy.codegen.fnodes import FortranReturn
    >>> from sympy import fcode
    >>> fcode(FortranReturn('x'))
    '       return x'

    )Úreturn_valuerÂ   N)r+   r,   r-   r.   r/   r0   r   rO   r2   r   Ú_construct_return_valuer4   r*   r'   rÁ   rÁ   ,  s@   € € € € € ðð ð( ,Ð+€I�Ø Ð%€HØ*˜l¨7Ñ3Ô3ÐÐÐr*   rÁ   c                   ó   — e Zd ZdZd„ ZdS )Ú	FFunctionéM   c           	      óú   — | j         j        }|j        d         | j        k     rt	          d|| j        fz  ¦  «        ‚d                     |d                     t          |j        | j	        ¦  «        ¦  «        ¦  «        S )NÚstandardz%s requires Fortran %d or newerz{}({})z, )
Ú	__class__r+   Ú	_settingsÚ_required_standardÚNotImplementedErrorÚformatr‘   rc   Ú_printrL   )r’   r“   r!   s      r'   Ú_fcodezFFunction._fcodeI  sy   € ØŒ~Ô&ˆØÔ˜ZÔ(¨4Ô+BÒBÐBÝ%Ð&GØ'+¨TÔ-DÐ&Eñ'Fñ Gô Gð Gà�Š˜t T§Y¢Y­s°7´>À4Ä9Ñ/MÔ/MÑ%NÔ%NÑOÔOÐOr*   N)r+   r,   r-   rË   rÏ   r4   r*   r'   rÅ   rÅ   F  s.   € € € € € ØÐðPð Pð Pð Pð Pr*   rÅ   c                   ó   — e Zd ZdZdS )ÚF95Functioné_   N)r+   r,   r-   rË   r4   r*   r'   rÑ   rÑ   Q  s   € € € € € ØÐÐÐr*   rÑ   c                   ó   — e Zd ZdZdZdS )Úisignz/ Fortran sign intrinsic for integer arguments. r‡   N©r+   r,   r-   r.   Únargsr4   r*   r'   rÔ   rÔ   U  s   € € € € € Ø9Ð9Ø€E€E€Er*   rÔ   c                   ó   — e Zd ZdZdZdS )Údsignz8 Fortran sign intrinsic for double precision arguments. r‡   NrÕ   r4   r*   r'   rØ   rØ   Z  s   € € € € € ØBÐBØ€E€E€Er*   rØ   c                   ó   — e Zd ZdZdZdS )Úcmplxz& Fortran complex conversion function. r‡   NrÕ   r4   r*   r'   rÚ   rÚ   _  s   € € € € € Ø0Ð0Ø€E€E€Er*   rÚ   c                   ó   — e Zd ZdZdZdS )r®   z Fortran kind function. rt   NrÕ   r4   r*   r'   r®   r®   d  ó   € € € € € Ø"Ð"Ø€E€E€Er*   r®   c                   ó   — e Zd ZdZdZdS )Úmergez Fortran merge function é   NrÕ   r4   r*   r'   rÞ   rÞ   i  rÜ   r*   rÞ   c                   ó   — e Zd ZdZdZd„ ZdS )Ú_literalNc                 ó>  — d                      | j        ¦  «        | z                       d¦  «        \  }}|                     d¦  «                             d¦  «        }|d         |dd …                              d¦  «        }}|dk    rdn|}|pd| j        z   |z   |pdz   S )	Nz%.{}eÚeÚ0ú.r   rt   ú+Ú )rÍ   Ú	_decimalsÚsplitÚstripÚrstripÚlstripÚ_token)r’   r“   rL   ÚkwargsÚmantissaÚsgnd_exÚex_sgnÚex_nums           r'   rÏ   z_literal._fcoder  sŸ   € Ø$Ÿ^š^¨D¬NÑ;Ô;¸dÑB×IÒIÈ#ÑNÔNÑˆ�'Ø—>’> #Ñ&Ô&×-Ò-¨cÑ2Ô2ˆØ  œ W¨Q¨R¨R¤[×%7Ò%7¸Ñ%<Ô%<�ˆØ ’}�}��¨&ˆØ�˜C 4¤;Ñ.°Ñ7¸6¸=ÀSÑIÐIr*   )r+   r,   r-   rí   rè   rÏ   r4   r*   r'   rá   rá   n  s2   € € € € € Ø€FØ€IðJð Jð Jð Jð Jr*   rá   c                   ó   — e Zd ZdZdZdZdS )Ú
literal_spz' Fortran single precision real literal rã   é	   N©r+   r,   r-   r.   rí   rè   r4   r*   r'   rô   rô   z  s   € € € € € Ø1Ð1Ø€FØ€I€I€Ir*   rô   c                   ó   — e Zd ZdZdZdZdS )Ú
literal_dpz' Fortran double precision real literal Údé   Nrö   r4   r*   r'   rø   rø   €  s   € € € € € Ø1Ð1Ø€FØ€I€I€Ir*   rø   c                   óL   — e Zd ZdxZZeedœZ ee¦  «        Z	 ee¦  «        Z
dS )Úsum_©r¥   r£   Úmask©r£   rþ   N©r+   r,   r-   r/   r0   r   rO   r2   r   Ú_construct_arrayÚ_construct_dimr4   r*   r'   rü   rü   †  óD   € € € € € Ø2Ð2€I�Ø TÐ*Ð*€HØ#�| GÑ,Ô,ÐØ!�\ 'Ñ*Ô*€N€N€Nr*   rü   c                   óL   — e Zd ZdxZZeedœZ ee¦  «        Z	 ee¦  «        Z
dS )Úproduct_rý   rÿ   Nr   r4   r*   r'   r  r  �  r  r*   r  r$   )NN)Jr.   Úsympy.codegen.astr   r   r   r   r   r   r	   r
   r   Úsympy.core.basicr   Úsympy.core.containersr   Úsympy.core.exprr   Úsympy.core.functionr   Úsympy.core.numbersr   r   Úsympy.core.symbolr   Úsympy.core.sympifyr   Úsympy.logicr   r   Úsympy.utilities.iterablesr   r   r   r   r   r   r   r    r6   r?   rA   rT   r`   rj   rn   r}   r�   r…   Úassumed_extentr—   Úassumed_sizer¥   r§   r©   r¬   r°   r²   rµ   r·   r»   r½   rÁ   rÅ   rÑ   rÔ   rØ   rÚ   r®   rÞ   rá   rô   rø   rü   r  r4   r*   r'   ú<module>r     s¸  ððð ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð #Ð "Ð "Ð "Ð "Ð "Ø 'Ð 'Ð 'Ð 'Ð 'Ð 'Ø  Ð  Ð  Ð  Ð  Ð  Ø (Ð (Ð (Ð (Ð (Ð (Ø -Ð -Ð -Ð -Ð -Ð -Ð -Ð -Ø !Ð !Ð !Ð !Ð !Ð !Ø &Ð &Ð &Ð &Ð &Ð &Ø #Ð #Ð #Ð #Ð #Ð #Ð #Ð #Ø .Ð .Ð .Ð .Ð .Ð .ð €y�ÑÔ€ØˆI�kÑ"Ô"€	àˆI�kÑ"Ô"€	ØˆY�|Ñ$Ô$€
Øˆy˜Ñ(Ô(€àˆi˜Ñ&Ô&€ðBð Bð Bð Bð Bˆeñ Bô Bð Bð*!ð !ð !ð !ð !�ñ !ô !ð !ð(ð ð ð~ð ~ð ~ð ~ð ~ˆ%ñ ~ô ~ð ~ð.Gð Gð Gð Gð GˆUñ Gô Gð Gð<#ð #ð #ð #ð #�ñ #ô #ð #ð>9ð 9ð 9ð 9ð 9�Uñ 9ô 9ð 9ð""Mð "Mð "Mð "Mð "Mˆñ "Mô "Mð "MðJ2ð 2ð 2ð 2ð 2�uñ 2ô 2ð 2ð&,ð ,ð ,ð ,ð ,�Eñ ,ô ,ð ,ð07ð 7ð 7ð 7ð 7ˆUñ 7ô 7ð 7ðB �‘”€ð .ð  .ð  .ðF ˆy˜‰~Œ~€ð+@¨R°tÀ$ð +@ð +@ð +@ð +@ð +@ðZAð Að Að:ð :ð :ð ð ð ð ð8ð ð ð ðð ð ð ð4ð ð ð ð8ð ð ð ð$?ð ?ð ?ð ?ð:,ð ,ð ,ð ,ð ,ˆ5ñ ,ô ,ð ,ð&4ð 4ð 4ð 4ð 4�Eñ 4ô 4ð 4ð4Pð Pð Pð Pð P�ñ Pô Pð Pðð ð ð ð �)ñ ô ð ðð ð ð ð ˆIñ ô ð ð
ð ð ð ð ˆIñ ô ð ð
ð ð ð ð ˆIñ ô ð ð
ð ð ð ð ˆ9ñ ô ð ð
ð ð ð ð ˆKñ ô ð ð
	Jð 	Jð 	Jð 	Jð 	Jˆuñ 	Jô 	Jð 	Jðð ð ð ð �ñ ô ð ðð ð ð ð �ñ ô ð ð+ð +ð +ð +ð +ˆ5�$ñ +ô +ð +ð+ð +ð +ð +ð +ˆu�dñ +ô +ð +ð +ð +r*   