§
    Ëãßcb-  ã                   ó¦   — d Z dgZddlmZ ddlmZ ddlmZ  ed¦  «         G d„ d¦  «        ¦   «         Ze	dk    r e
 e¦   «         ¦  «         d	S d	S )
z€
Machine arithmetic - determine the parameters of the
floating-point arithmetic system

Author: Pearu Peterson, September 2003

ÚMachAré    )Úany)Úerrstate)Ú
set_moduleÚnumpyc                   ó2   — e Zd ZdZeeed„ dfd„Zd„ Zd„ ZdS )r   aw  
    Diagnosing machine parameters.

    Attributes
    ----------
    ibeta : int
        Radix in which numbers are represented.
    it : int
        Number of base-`ibeta` digits in the floating point mantissa M.
    machep : int
        Exponent of the smallest (most negative) power of `ibeta` that,
        added to 1.0, gives something different from 1.0
    eps : float
        Floating-point number ``beta**machep`` (floating point precision)
    negep : int
        Exponent of the smallest power of `ibeta` that, subtracted
        from 1.0, gives something different from 1.0.
    epsneg : float
        Floating-point number ``beta**negep``.
    iexp : int
        Number of bits in the exponent (including its sign and bias).
    minexp : int
        Smallest (most negative) power of `ibeta` consistent with there
        being no leading zeros in the mantissa.
    xmin : float
        Floating-point number ``beta**minexp`` (the smallest [in
        magnitude] positive floating point number with full precision).
    maxexp : int
        Smallest (positive) power of `ibeta` that causes overflow.
    xmax : float
        ``(1-epsneg) * beta**maxexp`` (the largest [in magnitude]
        usable floating value).
    irnd : int
        In ``range(6)``, information on what kind of rounding is done
        in addition, and on how underflow is handled.
    ngrd : int
        Number of 'guard digits' used when truncating the product
        of two mantissas to fit the representation.
    epsilon : float
        Same as `eps`.
    tiny : float
        An alias for `smallest_normal`, kept for backwards compatibility.
    huge : float
        Same as `xmax`.
    precision : float
        ``- int(-log10(eps))``
    resolution : float
        ``- 10**(-precision)``
    smallest_normal : float
        The smallest positive floating point number with 1 as leading bit in
        the mantissa following IEEE-754. Same as `xmin`.
    smallest_subnormal : float
        The smallest positive floating point number with 0 as leading bit in
        the mantissa following IEEE-754.

    Parameters
    ----------
    float_conv : function, optional
        Function that converts an integer or integer array to a float
        or float array. Default is `float`.
    int_conv : function, optional
        Function that converts a float or float array to an integer or
        integer array. Default is `int`.
    float_to_float : function, optional
        Function that converts a float array to float. Default is `float`.
        Note that this does not seem to do anything useful in the current
        implementation.
    float_to_str : function, optional
        Function that converts a single float to a string. Default is
        ``lambda v:'%24.16e' %v``.
    title : str, optional
        Title that is printed in the string representation of `MachAr`.

    See Also
    --------
    finfo : Machine limits for floating point types.
    iinfo : Machine limits for integer types.

    References
    ----------
    .. [1] Press, Teukolsky, Vetterling and Flannery,
           "Numerical Recipes in C++," 2nd ed,
           Cambridge University Press, 2002, p. 31.

    c                 ó   — d| z  S )Nz%24.16e© )Úvs    ú4/usr/lib/python3/dist-packages/numpy/core/_machar.pyú<lambda>zMachAr.<lambda>k   s
   €  y°1¡}€ ó    zPython floating point numberc                 óŠ   — t          d¬¦  «        5  |                      |||||¦  «         ddd¦  «         dS # 1 swxY w Y   dS )a!  

        float_conv - convert integer to float (array)
        int_conv   - convert float (array) to integer
        float_to_float - convert float array to float
        float_to_str - convert array float to str
        title        - description of used floating point numbers

        Úignore)ÚunderN)r   Ú_do_init)ÚselfÚ
float_convÚint_convÚfloat_to_floatÚfloat_to_strÚtitles         r   Ú__init__zMachAr.__init__i   s§   € õ ˜HÐ%Ñ%Ô%ð 	Uð 	UØ�MŠM˜* h°ÀÈeÑTÔTÐTð	Uð 	Uð 	Uñ 	Uô 	Uð 	Uð 	Uð 	Uð 	Uð 	Uð 	Uð 	Uøøøð 	Uð 	Uð 	Uð 	Uð 	Uð 	Us   ‘8¸<¿<c                 óì  — d}d} |d¦  «        }||z   }	||z
  }
|}t          |¦  «        D ])}||z   }||z   }||z
  }t          ||z
  |
k    ¦  «        r nŒ*t          |||j        fz  ¦  «        ‚|}t          |¦  «        D ]/}||z   }||z   } |||z
  ¦  «        }t          |dk    ¦  «        r nŒ0t          |||j        fz  ¦  «        ‚|} ||¦  «        }d}|}t          |¦  «        D ].}|dz   }||z  }||z   }||z
  }t          ||z
  |
k    ¦  «        r nŒ/t          |||j        fz  ¦  «        ‚||	z  }|}t          |¦  «        D ])}||z   }||z   }||z
  }t          ||z
  |
k    ¦  «        r nŒ*t          |||j        fz  ¦  «        ‚||z   }d}t          ||z
  |
k    ¦  «        rd}||z   }||z   }|dk    rt          ||z
  |
k    ¦  «        rd}|dz   }||z  }|}t          |¦  «        D ]}||z  }Œ|}t          |¦  «        D ]M}||z
  }t          ||z
  |
k    ¦  «        r nH||z  }|dz
  }|dk     rt          dt	          ¦   «         z  ¦  «        ‚ŒNt          |||j        fz  ¦  «        ‚| }|}| dz
  }|}t          |¦  «        D ])}||z   }t          ||z
  |
k    ¦  «        r n$||z  }|dz   }Œ*t          |||j        fz  ¦  «        ‚|}d}||z   }|dk    rt          ||z  |z
  |
k    ¦  «        rd}d}d}|}||z   } d}!t          |¦  «        D ]r}|}"|"|"z  }||z  }|| z  }t          ||z   |
k    ¦  «        s t          t          |¦  «        |"k    ¦  «        r nA||z  }t          ||z  |k    ¦  «        r n$|dz   }||z   }Œst          |||j        fz  ¦  «        ‚|d	k    r|dz   }#||z   }$n"d}#|}%||%k    r|%|z  }%|#dz   }#||%k    °|%|%z   dz
  }$t          |¦  «        D ]„}|"}&|"|z  }"|"|z  }|"| z  }t          ||z   |
k    ¦  «        rZt          t          |"¦  «        |&k     ¦  «        r:|dz   }||z  }t          ||z  |"k    ¦  «        rt          ||"k    ¦  «        rd}!|"}& nŒƒ nt          |||j        fz  ¦  «        ‚| }'|$||z   dz
  k    r|d	k    r
|$|$z   }$|#dz   }#|$|'z   }(||!z   }|dk    r|(dz
  }(|(|'z   }|dk    r|s|(dz
  }(|d
k    r|(dz
  }(t          ||"k    ¦  «        r|(dz
  }(||z
  })t          |)|z  |)k    ¦  «        r|||z  z
  })|)|&|z  |z  |z  z  })|(|'z   dz   }t          |¦  «        D ]}*|dk    r|)|)z   })Œ|)|z  })Œt          |&||z  z  ¦  «        }+|| _        || _        || _         ||¦  «        | _	         ||¦  «        | _
        || _         ||¦  «        | _         ||¦  «        | _        || _        |#| _        |'| _         ||&¦  «        | _         ||&¦  «        | _        |(| _         ||)¦  «        | _         ||)¦  «        | _        || _        || _        | j        | _        | j        | _        | j        | _        | j        | _         || j        ¦  «        | _         ||+¦  «        | _         ||+¦  «        | _        dd l},tA          |, !                     || j        ¦  «        ¦  «         ¦  «        | _"        |	|	z   |	z   |	z   |	z   }-|-| j"         z  }. ||.¦  «        | _#         ||.¦  «        | _$        d S )Ni'  z'Did not converge after %d tries with %sé   r   éÿÿÿÿé   é   zAcould not determine machine tolerance for 'negep', locals() -> %sé
   é   )%Úranger   ÚRuntimeErrorÚdtypeÚlocalsÚabsÚibetaÚitÚnegepÚepsnegÚ_str_epsnegÚmachepÚepsÚ_str_epsÚngrdÚiexpÚminexpÚxminÚ	_str_xminÚmaxexpÚxmaxÚ	_str_xmaxÚirndr   ÚepsilonÚtinyÚhugeÚsmallest_normalÚ_str_smallest_normalÚsmallest_subnormalÚ_str_smallest_subnormalÚmathÚintÚlog10Ú	precisionÚ
resolutionÚ_str_resolution)/r   r   r   r   r   r   Ú	max_iterNÚmsgÚoneÚtwoÚzeroÚaÚ_ÚtempÚtemp1ÚbÚitempr&   Úbetar'   Úbetahr6   Útempar(   ÚbetainÚir)   r+   r,   r.   ÚkÚzÚtÚnxresÚyr/   ÚmxÚizr1   r0   r3   r4   Újr<   r>   ÚtenrB   s/                                                  r   r   zMachAr._do_init{   s6	  € Øˆ	Ø7ˆØˆj˜‰mŒmˆØ�C‰iˆØ�S‰yˆð ˆÝ�yÑ!Ô!ð 	5ð 	5ˆAØ�A‘ˆAØ�s‘7ˆDØ˜1‘HˆEÝ�5˜3‘; $Ò&Ñ'Ô'ð Ø�ðõ ˜s a¨¬ ^Ñ3Ñ4Ô4Ð4ØˆÝ�yÑ!Ô!ð 	5ð 	5ˆAØ�A‘ˆAØ�q‘5ˆDØ�H˜T !™VÑ$Ô$ˆEÝ�5˜A’:‰Œð Ø�ðõ ˜s a¨¬ ^Ñ3Ñ4Ô4Ð4ØˆØˆz˜%Ñ Ô ˆð ˆØˆÝ�yÑ!Ô!ð 	5ð 	5ˆAØ�a‘ˆBØ�D‘ˆAØ�s‘7ˆDØ˜1‘HˆEÝ�5˜3‘; $Ò&Ñ'Ô'ð Ø�ðõ ˜s a¨¬ ^Ñ3Ñ4Ô4Ð4à�s‘
ˆØˆÝ�yÑ!Ô!ð 	5ð 	5ˆAØ�A‘ˆAØ�s‘7ˆDØ˜1‘HˆEÝ�5˜3‘; $Ò&Ñ'Ô'ð Ø�ðõ ˜s a¨¬ ^Ñ3Ñ4Ô4Ð4Ø�5‰yˆØˆÝˆt�A‰v˜Š~ÑÔð 	ØˆDØ�D‘ˆØ�u‰}ˆØ�1Š9ˆ9�˜T %™Z¨4Ò/Ñ0Ô0ˆ9ØˆDð �Q‘ˆØ�t‘ˆØˆÝ�u‘”ð 	ð 	ˆAØ�F‘
ˆAˆAØˆÝ�yÑ!Ô!ð 	5ð 	5ˆAØ˜‘7ˆDÝ�4˜‘8˜tÒ#Ñ$Ô$ð Ø�Ø�D‘ˆAØ˜A‘IˆEà�qŠyˆyÝ"ð $AÝDJÁHÄHñ$Nñ Oô Oð Oð õ ˜s a¨¬ ^Ñ3Ñ4Ô4Ð4Ø�ˆØˆð �˜‘ˆØˆå�yÑ!Ô!ð 	5ð 	5ˆAØ˜‘7ˆDÝ�4˜‘8˜tÒ#Ñ$Ô$ð Ø�Ø�D‘ˆAØ˜a‘ZˆFˆFå˜s a¨¬ ^Ñ3Ñ4Ô4Ð4Øˆð ˆØ�S‰yˆØ�1Š9ˆ9�˜T #™X¨™^¨tÒ3Ñ4Ô4ˆ9ØˆDð ˆØˆØˆØ�#‰IˆØˆÝ�yÑ!Ô!ð 	5ð 	5ˆAØˆAØ�!‘ˆAØ�#‘ˆAØ�Q‘3ˆDÝ�1�Q‘3˜$’;ÑÔð ¥3¥s¨1¡v¤v°¢{Ñ#3Ô#3ð Ø�Ø˜6‘MˆEÝ�5˜‘: ’?Ñ#Ô#ð Ø�Ø�A‘ˆAØ�A‘ˆAˆAå˜s a¨¬ ^Ñ3Ñ4Ô4Ð4Ø�BŠ;ˆ;Ø�q‘5ˆDØ�Q‘ˆBˆBàˆDØˆBØ�r’'�'Ø˜%‘Z�Ø˜a‘x�ð �r’'�'ð �b‘˜1‘ˆBõ �yÑ!Ô!ð 	5ð 	5ˆAØˆDØ�F‘
ˆAØ�C‘ˆAØ�q‘5ˆDÝ�A˜‘E˜d’?Ñ#Ô#ð ­­C°©F¬F°TªMÑ(:Ô(:ð Ø˜‘E�Ø˜v™�Ý�u˜T‘z Q’Ñ'Ô'ð ­C°¸²	©N¬Nð Ø�EØ�DØ�Eøà�å˜s a¨¬ ^Ñ3Ñ4Ô4Ð4Ø�ˆð ��Q‘˜‘Š?ˆ?˜u¨š{˜{Ø�b‘ˆBØ˜!‘8ˆDØ�f‘ˆØ�e‰|ˆØ�1Š9ˆ9Ø˜a‘ZˆFØ�V‰OˆØ�AŠ:ˆ:˜aˆ:Ø˜a‘ZˆFØˆrŠ6ˆ6Ø˜a‘ZˆFÝˆq�AŠv‰;Œ;ð 	 Ø˜a‘ZˆFØ�V‰|ˆÝˆt�C‰x˜4ÒÑ Ô ð 	%Ø˜˜f™Ñ$ˆDØ�t˜D‘y ‘~ dÑ*Ñ+ˆØ�V‰O˜aÑˆÝ�q‘”ð 	#ð 	#ˆAØ˜ŠzˆzØ˜d‘{��à˜d‘{��å  ¨°©Ñ!4Ñ5Ô5ÐàˆŒ
ØˆŒØˆŒ
Ø$�n VÑ,Ô,ˆŒØ'˜<¨Ñ/Ô/ˆÔØˆŒØ!�> #Ñ&Ô&ˆŒØ$˜ SÑ)Ô)ˆŒØˆŒ	ØˆŒ	ØˆŒØ"�N 4Ñ(Ô(ˆŒ	Ø%˜ dÑ+Ô+ˆŒØˆŒØ"�N 4Ñ(Ô(ˆŒ	Ø%˜ dÑ+Ô+ˆŒØˆŒ	àˆŒ
à”xˆŒØ”IˆŒ	Ø”IˆŒ	Ø#œyˆÔØ$0 L°´Ñ$;Ô$;ˆÔ!Ø"0 .Ð1CÑ"DÔ"DˆÔØ'3 |Ð4FÑ'GÔ'GˆÔ$àˆˆˆÝ˜dŸjšj¨¨¸¼Ñ)AÔ)AÑBÔBÐBÑCÔCˆŒØ�C‰i˜#‰o Ñ# cÑ)ˆØ˜dœn˜_Ñ-ˆ
Ø(˜.¨Ñ4Ô4ˆŒØ+˜|¨JÑ7Ô7ˆÔÐÐr   c                 ó   — d}|| j         z  S )NaC  Machine parameters for %(title)s
---------------------------------------------------------------------
ibeta=%(ibeta)s it=%(it)s iexp=%(iexp)s ngrd=%(ngrd)s irnd=%(irnd)s
machep=%(machep)s     eps=%(_str_eps)s (beta**machep == epsilon)
negep =%(negep)s  epsneg=%(_str_epsneg)s (beta**epsneg)
minexp=%(minexp)s   xmin=%(_str_xmin)s (beta**minexp == tiny)
maxexp=%(maxexp)s    xmax=%(_str_xmax)s ((1-epsneg)*beta**maxexp == huge)
smallest_normal=%(smallest_normal)s    smallest_subnormal=%(smallest_subnormal)s
---------------------------------------------------------------------
)Ú__dict__)r   Úfmts     r   Ú__str__zMachAr.__str__T  s   € ð	Uð 	ð �T”]Ñ"Ð"r   N)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úfloatr?   r   r   r`   r
   r   r   r   r      sn   € € € € € ðTð Tðl #(°Ø %Ø4Ð4Ø5ðUð Uð Uð Uð$W8ð W8ð W8ðr#ð #ð #ð #ð #r   Ú__main__N)rd   Ú__all__Únumpy.core.fromnumericr   Únumpy.core._ufunc_configr   Únumpy.core.overridesr   r   ra   Úprintr
   r   r   ú<module>rl      sÂ   ððð ð ˆ*€à &Ð &Ð &Ð &Ð &Ð &Ø -Ð -Ð -Ð -Ð -Ð -Ø +Ð +Ð +Ð +Ð +Ð +ð
 €ˆGÑÔðO#ð O#ð O#ð O#ð O#ñ O#ô O#ñ ÔðO#ðd
 ˆzÒÐØ	€Eˆ&ˆ&‰(Œ(�O„O€O€O€Oð Ðr   