pointnet中train.py中引用的模块(二)

今天看了point net中train.py中引用的模块,有的以前了解过,有的也是刚了解,就都搜了一下。

python中math来提供很多特别的数学运算,math库中包含了数学公式,我们可以通过用math库求表达式的值 。

1.math简介

复制代码代码如下:

>>> import math
>>>dir(math)          #这句可查看所有函数名列表
>>>help(math)         #查看具体定义及函数0原型

2.常用函数

复制代码代码如下:

ceil(x) 取顶
floor(x) 取底
fabs(x) 取绝对值
factorial (x) 阶乘
hypot(x,y)  sqrt(x*x+y*y)
pow(x,y) x的y次方
sqrt(x) 开平方
log(x)
log10(x)
trunc(x)  截断取整数部分
isnan (x)  判断是否NaN(not a number)
degree (x) 弧度转角度
radians(x) 角度转弧度

首先导入math库(两种方法):

import math
  • 1
from math import x #x表示math库中方法
  • 1

然后通过math库调用库中的函数来打到我们预期的目的

π          #3.145926……
e           #2.72…..
ceil(x)     #对x向上取整
floor(x)    #对x向下取值整
pow(x,y)    #x的y次幂
log(x)      #自然对数
Log10(x)    #常用对数
squrt(x)    #x的算术平方根
exp(x)      #x的e次幂
degrees(x)  #将弧度值x转化成角度值
radians(x)  #将角度值转化成弧度值
sin(x)      #x的正弦值
cos(x)      #x的余弦值
tan(x)      #x的正切值
asin(x)     #x的反正弦值
acos(x)     #x的反余弦值
atan(x)     #x的反正切值

 函数  说明  实例
 math.e  自然常数e  >>> math.e
2.718281828459045
 math.pi  圆周率pi  >>> math.pi
3.141592653589793
 math.degrees(x)  弧度转度  >>> math.degrees(math.pi)
180.0
 math.radians(x)  度转弧度  >>> math.radians(45)
0.7853981633974483
 math.exp(x)  返回e的x次方  >>> math.exp(2)
7.38905609893065
 math.expm1(x)  返回e的x次方减1  >>> math.expm1(2)
6.38905609893065
 math.log(x[, base])  返回x的以base为底的对数,base默认为e  >>> math.log(math.e)
1.0
>>> math.log(2, 10)
0.30102999566398114
 math.log10(x)  返回x的以10为底的对数  >>> math.log10(2)
0.30102999566398114
 math.log1p(x)  返回1+x的自然对数(以e为底)  >>> math.log1p(math.e-1)
1.0
 math.pow(x, y)  返回x的y次方  >>> math.pow(5,3)
125.0
 math.sqrt(x)  返回x的平方根  >>> math.sqrt(3)
1.7320508075688772
 math.ceil(x)  返回不小于x的整数  >>> math.ceil(5.2)
6.0
 math.floor(x)  返回不大于x的整数  >>> math.floor(5.8)
5.0
 math.trunc(x)  返回x的整数部分  >>> math.trunc(5.8)
5
 math.modf(x)  返回x的小数和整数  >>> math.modf(5.2)
(0.20000000000000018, 5.0)
 math.fabs(x)  返回x的绝对值  >>> math.fabs(-5)
5.0
 math.fmod(x, y)  返回x%y(取余)  >>> math.fmod(5,2)
1.0
 math.fsum([x, y, ...])  返回无损精度的和  >>> 0.1+0.2+0.3
0.6000000000000001
>>> math.fsum([0.1, 0.2, 0.3])
0.6
 math.factorial(x)  返回x的阶乘  >>> math.factorial(5)
120
 math.isinf(x)  若x为无穷大,返回True;否则,返回False  >>> math.isinf(1.0e+308)
False
>>> math.isinf(1.0e+309)
True
 math.isnan(x)  若x不是数字,返回True;否则,返回False  >>> math.isnan(1.2e3)
False
 math.hypot(x, y)  返回以x和y为直角边的斜边长  >>> math.hypot(3,4)
5.0
 math.copysign(x, y)  若y<0,返回-1乘以x的绝对值;
 否则,返回x的绝对值
 >>> math.copysign(5.2, -1)
-5.2
 math.frexp(x)  返回m和i,满足m乘以2的i次方  >>> math.frexp(3)
(0.75, 2)
 math.ldexp(m, i)  返回m乘以2的i次方  >>> math.ldexp(0.75, 2)
3.0
 math.sin(x)  返回x(弧度)的三角正弦值  >>> math.sin(math.radians(30))
0.49999999999999994
 math.asin(x)  返回x的反三角正弦值  >>> math.asin(0.5)
0.5235987755982989
 math.cos(x)  返回x(弧度)的三角余弦值  >>> math.cos(math.radians(45))
0.7071067811865476
 math.acos(x)  返回x的反三角余弦值  >>> math.acos(math.sqrt(2)/2)
0.7853981633974483
 math.tan(x)  返回x(弧度)的三角正切值  >>> math.tan(math.radians(60))
1.7320508075688767
 math.atan(x)  返回x的反三角正切值  >>> math.atan(1.7320508075688767)
1.0471975511965976
 math.atan2(x, y)  返回x/y的反三角正切值  >>> math.atan2(2,1)
1.1071487177940904
 math.sinh(x)  返回x的双曲正弦函数  
 math.asinh(x)  返回x的反双曲正弦函数  
 math.cosh(x)  返回x的双曲余弦函数  
 math.acosh(x)  返回x的反双曲余弦函数  
 math.tanh(x)  返回x的双曲正切函数  
 math.atanh(x)  返回x的反双曲正切函数  
 math.erf(x)  返回x的误差函数  
 math.erfc(x)  返回x的余误差函数  
 math.gamma(x) 返回x的伽玛函数  
 math.lgamma(x)  返回x的绝对值的自然对数的伽玛函数

math模块的函数如下:
 
0,常量

math.pi         
π = 3.141592...
math.e          e = 2.718281...


1,数值计算函数
 
math.ceil(x)            返回≥x的最小整数

math.floor(x)           返回≤x的最大整数
math.copysign(x,y)      返回与y同号的x值
math.fabs(x)            返回x的绝对值
math.factorial(x)       返回x的阶乘,即x!,x必须为非负整数
math.fmod(x,y)          返回x对y取模的余数(x决定余数符号),与x%y不同(y决定余数符号)
   例:   math.fmod(100, -3)   -->  1.0
         math.fmod(-100, 3)   --> -1.0
         100 % -3    -->    -2
        -100 %  3    -->     2
math.frexp(x)           返回元组(m,e),根据 x = m*(2**e)
math.fsum(iterable)     返回数组的和,比内置函数sum要精确
math.isfinite(x)        若x是有限数,返回True
math.isinf(x)           若x是无穷大,返回True
math.isnan(x)           若x非数,返回True
math.ldexp(x,i)         返回x*(2**i)的结果
math.modf(x)            返回元组(fractional,integer),分别为x的小数部分和整数部分
math.trunc(x)           返回x的整数部分

2,乘方/对数函数
 
math.exp(x)             返回e**x
math.expm1(x)           返回e**x - 1
math.log(x[,base])      返回x的对数,base默认的是e
math.log1p(x)           返回x+1的对数,base是e
math.log2(x)            返回x关于2的对数
math.log10(x)           返回x关于10的对数
math.pow(x,y)           返回x**y
math.sqrt(x)            返回x的平方根

3,三角函数


math.sin(x)             返回x的正弦,x用弧度制表示
math.cos(x)             返回x的余弦
math.tan(x)             返回x的正切
math.asin(x)            返回x的反正弦,结果用弧度制表示
math.acos(x)            返回x的反余弦
math.atan(x)            返回x的反正切
math.atan2(y,x)         返回atan(y/x)
math.hypot(x,y)         返回sqrt(x*x + y*y)

4,角度,弧度转换函数


math.degrees(x)         弧度 –> 角度
math.radians(x)         角度 -> 弧度

5,双曲线函数
 
math.acosh(x)           返回x的反双曲余弦
math.asinh(x)           返回x的反双曲正弦
math.atanh(x)           返回x的反双曲正切
math.cosh(x)            返回x的双曲余弦
math.sinh(x)            返回x的双曲正弦
math.tanh(x)            返回x的双曲正切
 
6,特殊函数

math.erf(x)           # 返回x的误差函数
math.erfc(x)          #  返回x的余误差函数
math.gamma(x)         # 返回x的伽玛函数
math.lgamma(x)        # 返回x的绝对值的自然对数的伽玛函数


下面是原文,有其很好的解释,里面还有一些例子:

https://blog.csdn.net/u011225629/article/details/78458724

https://blog.csdn.net/calling_wisdom/article/details/41750023

https://blog.csdn.net/zkzbhh/article/details/78384180

https://blog.csdn.net/waitfou/article/details/61614400

https://blog.csdn.net/godiness/article/details/48474027

https://blog.csdn.net/lijiahong2012/article/details/52416400

https://docs.python.org/3.6/library/math.html和https://blog.csdn.net/chengye200503/article/details/79040719可以对号

https://blog.csdn.net/iamaiearner/article/details/9381347

猜你喜欢

转载自blog.csdn.net/wangweiijia/article/details/80024277