Your IP : 216.73.216.213
(��^%* � @ s~ d Z d d l m Z m Z m Z d g Z d d l m Z d d l m Z Gd d � d e
� Z e d k rz e
e � � d S) z�
Machine arithmetics - determine the parameters of the
floating-point arithmetic system
Author: Pearu Peterson, September 2003
� )�division�absolute_import�print_function�MachAr)�any)�errstatec @ sO e Z d Z d Z e e e d d � d d d � Z d d � Z d d
� Z d S)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] usable floating value).
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
Same as `xmin`.
huge : float
Same as `xmax`.
precision : float
``- int(-log10(eps))``
resolution : float
``- 10**(-precision)``
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 C s d | S)Nz%24.16e� )�vr r �D/opt/alt/python35/lib64/python3.5/site-packages/numpy/core/machar.py�<lambda>d s zMachAr.<lambda>zPython floating point numberc
C s4 t d d � � | j | | | | | � Wd QRXd 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
Zunder�ignoreN)r �_do_init)�self�
float_conv�int_conv�float_to_float�float_to_str�titler r r
�__init__b s zMachAr.__init__c . C s� d } d } | d � } | | } | | }
| } xb t | � D]; } | | } | | }
|
| } t | | |
k � r? Pq? Wt | | | j f � � | } xd t | � D]= } | | } | | }
| |
| � } t | d k � r� Pq� Wt | | | j f � � | } | | � } d
} | } xl t | � D]E } | d } | | } | | }
|
| } t | | |
k � r/Pq/Wt | | | j f � � | | } | } xb t | � D]; } | | } | | }
|
| } t | | |
k � r�Pq�Wt | | | j f � � | | }
d } t |
| |
k � r2d } | | } | | }
| d k rnt |
| |
k � rnd } | d } | | } | } x t | � D] } | | } q�W| } x� t | � D]Z } | | }
t |
| |
k � r�P| | } | d } | d k r�t d t � � � q�Wt | | | j f � � | } | } | d } | } xb t | � D]; } | | }
t |
| |
k � r�P| | } | d } q^Wt | | | j f � � | } d } | | }
| d k r�t |
| | |
k � r�d } d } d } | } | | } d }! x� t | � D]� } | }"