Viewing File: /opt/cloudlinux/venv/lib/python3.11/site-packages/numpy/core/__pycache__/_machar.cpython-311.pyc

�

�|oi--���dZdgZddlmZddlmZddlmZGd�d��Ze	dkre
e����d	Sd	S)
z�
Machine arithmetic - determine the parameters of the
floating-point arithmetic system

Author: Pearu Peterson, September 2003

�MachAr�)�any)�errstate�)�
set_modulec�2�eZdZdZeeed�dfd�Zd�Zd�ZdS)raw
    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|zS)Nz%24.16e�)�vs �I/opt/cloudlinux/venv/lib64/python3.11/site-packages/numpy/core/_machar.py�<lambda>zMachAr.<lambda>js
��y�1�}��zPython floating point numberc��td���5|�|||||��ddd��dS#1swxYwYdS)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__zMachAr.__init__hs����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�	Us�8�<�<c��
�d}d}|d��}||z}	||z
}
|}t|��D])}||z}||z}
|
|z
}t||z
|
k��rn�*t|||jfz���|}t|��D]/}||z}||z}
||
|z
��}t|dk��rn�0t|||jfz���|}||��}d}|}t|��D].}|dz}||z}||z}
|
|z
}t||z
|
k��rn�/t|||jfz���||	z}|}t|��D])}||z}||z}
|
|z
}t||z
|
k��rn�*t|||jfz���||z}
d}t|
|z
|
k��rd}||z}||z}
|dkrt|
|z
|
k��rd}|dz}||z}|}t|��D]}||z}�|}t|��D]M}||z
}
t|
|z
|
k��rnH||z}|dz
}|dkrtdt	��z����Nt|||jfz���|}|}|dz
}|}t|��D])}||z}
t|
|z
|
k��rn$||z}|dz}�*t|||jfz���|}d}||z}
|dkrt|
|z|z
|
k��rd}d}d}|}||z} d}!t|��D]r}|}"|"|"z}||z}|| z}
t||z|
k��s tt|��|"k��rnA|
|z}t||z|k��rn$|dz}||z}�st|||jfz���|d	kr|dz}#||z}$n"d}#|}%||%kr|%|z}%|#dz}#||%k�|%|%zdz
}$t|��D]�}|"}&|"|z}"|"|z}|"| z}
t||z|
k��rZtt|"��|&k��r:|dz}|
|z}t||z|"k��rt|
|"k��rd}!|"}&n��nt|||jfz���|}'|$||zdz
kr|d	kr
|$|$z}$|#dz}#|$|'z}(||!z}|dkr|(dz
}(|(|'z}|dkr|s|(dz
}(|d
kr|(dz
}(t||"k��r|(dz
}(||z
})t|)|z|)k��r|||zz
})|)|&|z|z|zz})|(|'zdz}t|��D]}*|dkr|)|)z})�|)|z})�t|&||zz��}+||_||_||_||��|_	||��|_
||_||��|_||��|_
||_|#|_|'|_||&��|_||&��|_|(|_||)��|_||)��|_||_||_|j|_|j|_|j|_|j|_||j��|_||+��|_||+��|_ddl},tA|,�!||j������|_"|	|	z|	z|	z|	z}-|-|j"z}.||.��|_#||.��|_$dS)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)/rrrrrr�	max_iterN�msg�one�two�zero�a�_�temp�temp1�b�itempr%�betar&�betahr5�tempar'�betain�ir(r*r+r-�k�z�t�nxres�yr.�mx�izr0r/r2r3�jr;r=�tenrAs/                                               rrzMachAr._do_initzs6	���	�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����rc��d}||jzS)NaCMachine 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__zMachAr.__str__Ss��	U�	��T�]�"�"rN)	�__name__�
__module__�__qualname__�__doc__�floatr>rrr_r
rrrrsn������T�T�l#(�� %�4�4�5�U�U�U�U�$W8�W8�W8�r
#�
#�
#�
#�
#r�__main__N)rc�__all__�fromnumericr�
_ufunc_configr�_utilsrrr`�printr
rr�<module>rks������*��������#�#�#�#�#�#�������
O#�O#�O#�O#�O#�O#�O#�O#�d
�z���	�E�&�&�(�(�O�O�O�O�O��r
Back to Directory File Manager