NumPy numpy.inf and numpy.infty
1. numpy.inf
IEEE 754 floating point representation of (positive) infinity.
infinity /ɪnˈfɪnəti/:n. 无穷,无限大,无限距
aliase:n. 别名
1.1. Returns
y : float
A floating point representation of positive infinity.
正无穷大的浮点表示。
NumPy uses the IEEE Standard for Binary Floating-Point for Arithmetic (IEEE 754). This means that Not a Number is not equivalent to infinity. Also that positive infinity is not equivalent to negative infinity. But infinity is equivalent to positive infinity.
NumPy 使用 IEEE Standard for Binary Floating-Point for Arithmetic (IEEE 754)。这意味着 Not a Number 不等于无穷大。同样,正无穷大不等于负无穷大。但是无穷大等于正无穷大。
Inf
, Infinity
, PINF
and infty
are aliases for inf
.
1.2. Examples
(pt-1.4_py-3.6) yongqiang@yongqiang:~$ python
Python 3.6.10 |Anaconda, Inc.| (default, May 8 2020, 02:54:21)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> np.inf
inf
>>>
>>> -np.inf
-inf
>>>
>>> np.array([1]) / 0.
array([inf])
>>>
>>> exit()
(pt-1.4_py-3.6) yongqiang@yongqiang:~$
2. numpy.infty
IEEE 754 floating point representation of (positive) infinity.
IEEE 754 浮点表示 (正) 无穷大。
Use inf
because Inf
, Infinity
, PINF
and infty
are aliases for inf
.
使用 inf
是因为 Inf
,Infinity
,PINF
和 infty
是 inf
的别名。
References
[1] Yongqiang Cheng, https://yongqiang.blog.csdn.net/