관리-도구
편집 파일: _machar.cpython-311.pyc
� �܋f-- � � � d Z dgZddlmZ ddlmZ ddlmZ G d� d� � Ze dk 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_modulec �2 � e Zd ZdZeeed� dfd�Zd� Zd� ZdS )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 �I/opt/cloudlinux/venv/lib64/python3.11/site-packages/numpy/core/_machar.py�<lambda>zMachAr.<lambda>j s � �y�1�}� � zPython floating point numberc � � t d�� � 5 | � |||||� � ddd� � dS # 1 swxY w Y dS )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__h 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� Us �8�<�<c �� � d}d} |d� � }||z } ||z } |}t |� � D ])}||z }||z } | |z }t ||z | k � � r n�*t |||j fz � � �|}t |� � D ]/}||z }||z } || |z � � }t |dk � � r n�0t |||j fz � � �|} ||� � }d}|}t |� � D ].}|dz }||z }||z } | |z }t ||z | k � � r n�/t |||j fz � � �|| z }|}t |� � D ])}||z }||z } | |z }t ||z | k � � r n�*t |||j fz � � �||z } d}t | |z | k � � rd}||z }||z } |dk rt | |z | k � � rd}|dz }||z }|}t |� � D ]}||z }�|}t |� � D ]M}||z } t | |z | k � � r nH||z }|dz }|dk rt dt � � z � � ��Nt |||j fz � � �| }|}| dz }|}t |� � D ])}||z } t | |z | k � � r n$||z }|dz }�*t |||j fz � � �|}d}||z } |dk rt | |z |z | k � � rd}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$|dz }||z }�st |||j fz � � �|d k r|dz }#||z }$n"d}#|}%||%k r|%|z }%|#dz }#||%k �|%|%z dz }$t |� � D ]�}|"}&|"|z }"|"|z }|"| z } t ||z | k � � rZt t |"� � |&k � � r:|dz }| |z }t ||z |"k � � rt | |"k � � rd}!|"}& n�� nt |||j fz � � �| }'|$||z dz k r|d k r |$|$z }$|#dz }#|$|'z }(||!z }|dk r|(dz }(|(|'z }|dk r|s|(dz }(|d k r|(dz }(t ||"k � � r|(dz }(||z })t |)|z |)k � � r|||z z })|)|&|z |z |z z })|(|'z dz }t |� � D ]}*|dk r|)|)z })�|)|z })�t |&||z z � � }+|| _ || _ || _ ||� � | _ ||� � | _ || _ ||� � | _ ||� � | _ || _ |#| _ |'| _ ||&� � | _ ||&� � | _ |(| _ ||)� � | _ ||)� � | _ || _ || _ | j | _ | j | _ | j | _ | j | _ || j � � | _ ||+� � | _ ||+� � | _ dd l},tA |,�! || j � � � � � � | _"