
    h--                     n    S r S/rSSKJr  SSKJr  SSKJr   " S S5      r\	S:X  a  \
" \" 5       5        g	g	)
z
Machine arithmetic - determine the parameters of the
floating-point arithmetic system

Author: Pearu Peterson, September 2003

MachAr   )any)errstate   )
set_modulec                   :    \ rS rSrSr\\\S S4S jrS rS r	Sr
g	)
r      a;  
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                     SU -  $ )Nz%24.16e )vs    L/var/www/fran/franai/venv/lib/python3.13/site-packages/numpy/core/_machar.py<lambda>MachAr.<lambda>j   s    y1}    zPython floating point numberc                 p    [        SS9   U R                  XX4U5        SSS5        g! , (       d  f       g= f)z

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__MachAr.__init__h   s(     H%MM*eT &%%s   '
5c                 t   SnSnU" S5      nX-   n	X-
  n
Un[        U5       H&  nX-   nX-   nX-
  n[        X-
  U
:g  5      (       d  M&    O   [        UWUR                  4-  5      eUn[        U5       H*  nX-   nX-   nU" X-
  5      n[        US:g  5      (       d  M*    O   [        X|UR                  4-  5      eUnU" U5      nSnUn[        U5       H,  nUS-   nUU-  nX-   nX-
  n[        X-
  U
:g  5      (       d  M,    O   [        X|UR                  4-  5      eUU	-  nUn[        U5       H&  nX-   nX-   nX-
  n[        X-
  U
:g  5      (       d  M&    O   [        X|UR                  4-  5      eUU-   nSn[        X-
  U
:g  5      (       a  SnUU-   nUU-   nUS:X  a  [        UU-
  U
:g  5      (       a  SnUS-   nUU-  nUn[        U5       H  nUU-  nM
     Un[        U5       HD  nX-
  n[        X-
  U
:g  5      (       a    OCUU-  nUS-
  nUS:  d  M0  [        S[	        5       -  5      e   [        X|UR                  4-  5      eU* nUnU* S-
  nUn[        U5       H(  nX-   n[        X-
  U
:g  5      (       a    O'UU-  nUS-   nM*     [        X|UR                  4-  5      eUnSnUU-   nUS:X  a  [        X-  U-
  U
:g  5      (       a  SnSnSnUnUU-   n Sn![        U5       Hn  nUn"U"U"-  nUU-  nUU -  n[        X-   U
:H  5      (       d  [        [        U5      U":  5      (       a    ODUU-  n[        UU-  U:H  5      (       a    O'US-   nUU-   nMp     [        X|UR                  4-  5      eUS	:w  a  US-   n#UU-   n$O$Sn#Un%UU%:  a  U%U-  n%U#S-   n#UU%:  a  M  U%U%-   S-
  n$[        U5       H  nU"n&U"U-  n"U"U-  nU"U -  n[        X-   U
:g  5      (       aY  [        [        U"5      U&:  5      (       a=  US-   nUU-  n[        UU-  U":H  5      (       a  [        UU":g  5      (       a  Sn!U"n&  O!M  M    O   [        X|UR                  4-  5      eU* n'U$UU-   S-
  ::  a  US	:w  a
  U$U$-   n$U#S-   n#U$U'-   n(UU!-   nUS:  a  U(S-
  n(U(U'-   nUS:X  a  U(       d  U(S-
  n(US
:  a  U(S-
  n([        UU":g  5      (       a  U(S-
  n(UU-
  n)[        U)U-  U):g  5      (       a  UUU-  -
  n)U)U&U-  U-  U-  -  n)U(U'-   S-   n[        U5       H  n*US:X  a  U)U)-   n)M  U)U-  n)M     [        U&UU-  -  5      n+UU l        UU l        UU l        U" U5      U l	        U" U5      U l
        UU l        U" U5      U l        U" U5      U l        UU l        U#U l        U'U l        U" U&5      U l        U" U&5      U l        U(U l        U" U)5      U l        U" U)5      U l        UU l        XPl        U R                  U l        U R"                  U l        U R(                  U l        U R"                  U l        U" U R"                  5      U l        U" U+5      U l        U" U+5      U l        SS Kn,[A        U,RC                  U" U R                  5      5      * 5      U l"        X-   U	-   U	-   U	-   n-U-U RD                  * -  n.U" U.5      U l#        U" U.5      U l$        g )Ni'  z'Did not converge after %d tries with %sr       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)   betahr8   tempar*   betainir+   r-   r.   r0   kztnxresyr1   mxizr3   r2   r5   r6   jr>   r@   tenrD   s/                                                  r   r   MachAr._do_initz   s   	7miy y!AA7DHE5;$&'' " sa^344y!AA5DTV$E5A: " s^344%  y!AaBDA7DHE5;$&'' " s^344s
y!AA7DHE5;$&'' " s^3445ytv~DDu}19T%Z4/00D QtuAF
A y!A7D48t#$$DAAIEqy" $ADJH$N O O " s^344 y!A7D48t#$$DAaZF " s^344 Sy19TX^t344D #Iy!AA!A#AQ3D13$;3s1v{#3#36ME5:?##AAAA " s^344B;q5DQBDBr'%Zax r' b1B y!ADF
ACAq5DAEd?##CFTM(:(:EvuTzQ''C	NNED -;'
  " s^344 Q?u{bB!8Dfe|19aZFVOA:aaZFr6aZFqAv;;aZFV|tCx4  f$DtDy~d*+VOaqAzd{d{	  !!45

$V,'/!#&$S)		"4(	%d+"4(	%d+	
xxII	II	#yy$0$;!"01C"D'34F'G$djj)ABBCi#o#c)dnn_-
(4+J7r   c                 "    SnXR                   -  $ )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__MachAr.__str__S  s    	U 	 ]]""r   )r/   r,   rE   r=   r?   r7   r4   r.   r9   r+   r;   r(   r1   r8   r)   r-   r5   r2   r*   r0   rC   rD   r<   r>   r:   r   r6   r3   N)__name__
__module____qualname____firstlineno____doc__floatrA   r   r   rc   __static_attributes__r   r   r   r   r      s+    Tl #( %45U$W8r#r   __main__N)ri   __all__fromnumericr   _ufunc_configr   _utilsr   r   re   printr   r   r   <module>rr      sA    *  # 
O# O#d
 z	&(O r   