Skip to content

数学函数(Mathematical functions)

三角函数

methoddescription
sin(x, /[, out, where, casting, order, …])正弦函数, element-wise.
cos(x, /[, out, where, casting, order, …])余弦函数 element-wise.
tan(x, /[, out, where, casting, order, …])正切函数, element-wise.
arcsin(x, /[, out, where, casting, order, …])反正弦函数, element-wise.
arccos(x, /[, out, where, casting, order, …])反余弦函数, element-wise.
arctan(x, /[, out, where, casting, order, …])反正切函数, element-wise.
hypot(x1, x2, /[, out, where, casting, …])传入直角三角形的“直角边”,返回其斜边。
arctan2(x1, x2, /[, out, where, casting, …])x1 / x2的 Element-wise 反正切线正确选择象限。
degrees(x, /[, out, where, casting, order, …])将角度从弧度转换为度。
radians(x, /[, out, where, casting, order, …])将角度从度转换为弧度。
unwrap(p[, discont, axis])通过将值之间的增量更改为2 * pi来展开。
deg2rad(x, /[, out, where, casting, order, …])将角度从度转换为弧度。
rad2deg(x, /[, out, where, casting, order, …])将角度从弧度转换为度。

双曲函数

methoddescription
sinh(x, /[, out, where, casting, order, …])双曲正弦, element-wise.
cosh(x, /[, out, where, casting, order, …])双曲余弦, element-wise.
tanh(x, /[, out, where, casting, order, …])计算双曲正切 element-wise.
arcsinh(x, /[, out, where, casting, order, …])反双曲正弦 element-wise.
arccosh(x, /[, out, where, casting, order, …])反双曲余弦, element-wise.
arctanh(x, /[, out, where, casting, order, …])反双曲正切 element-wise.

四舍五入

methoddescription
around(a[, decimals, out])平均舍入到给定的小数位数。
round_(a[, decimals, out])将数组舍入到给定的小数位数。
rint(x, /[, out, where, casting, order, …])将数组的元素四舍五入到最接近的整数。
fix(x[, out])四舍五入为零。
floor(x, /[, out, where, casting, order, …])返回输入的底限, element-wise.
ceil(x, /[, out, where, casting, order, …])返回输入的上限, element-wise.
trunc(x, /[, out, where, casting, order, …])返回输入的截断值, element-wise.

加法函数, 乘法函数, 减法函数

methoddescription
prod(a[, axis, dtype, out, keepdims, …])返回给定轴上数组元素的乘积。
sum(a[, axis, dtype, out, keepdims, …])给定轴上的数组元素的总和。
nanprod(a[, axis, dtype, out, keepdims])返回数组元素在给定轴上的乘积,将非数字(NaNs)视为一个。
nansum(a[, axis, dtype, out, keepdims])返回给定轴上的数组元素的总和,将非数字(NaNs)视为零。
cumprod(a[, axis, dtype, out])返回沿给定轴的元素的累加乘积。
cumsum(a[, axis, dtype, out])返回沿给定轴的元素的累加和。
nancumprod(a[, axis, dtype, out])返回数组元素在给定轴上的累积乘积,将非数字(NaNs)视为一个。
nancumsum(a[, axis, dtype, out])返回在给定轴上将非数字(NaNs)视为零的数组元素的累积总和。
diff(a[, n, axis, prepend, append])计算沿给定轴的第n个离散差。
ediff1d(ary[, to_end, to_begin])数组的连续元素之间的差值。
gradient(f, *varargs, **kwargs)返回N维数组的梯度。
cross(a, b[, axisa, axisb, axisc, axis])返回两个(数组)向量的叉积。
trapz(y[, x, dx, axis])使用复合梯形规则沿给定轴积分。

指数和对数

methoddescription
exp(x, /[, out, where, casting, order, …])计算输入数组中所有元素的指数。
expm1(x, /[, out, where, casting, order, …])为数组中的所有元素计算exp(x)-1。
exp2(x, /[, out, where, casting, order, …])为输入数组中的所有p计算2 ** p。
log(x, /[, out, where, casting, order, …])自然对数, element-wise.
log10(x, /[, out, where, casting, order, …])返回输入数组的以10为底的对数, element-wise.
log2(x, /[, out, where, casting, order, …])x的以2为底的对数。
log1p(x, /[, out, where, casting, order, …])返回元素加一个输入数组的自然对数。
logaddexp(x1, x2, /[, out, where, casting, …])输入取幂之和的对数。
logaddexp2(x1, x2, /[, out, where, casting, …])以2为底的输入的幂和的对数。

其他特殊函数

methoddescription
i0(x)第一种修改的Bessel函数,阶数为0。
sinc(x)返回sinc函数。

浮点例程

methoddescription
signbit(x, /[, out, where, casting, order, …])在设置了符号位(小于零)的情况下返回 element-wise True。
copysign(x1, x2, /[, out, where, casting, …])将x1的符号更改为x2的符号, element-wise.
frexp(x[, out1, out2], / [[, out, where, …])将x的元素分解为尾数和二进制指数。
ldexp(x1, x2, /[, out, where, casting, …])返回x1 * 2 ** x2, element-wise.
nextafter(x1, x2, /[, out, where, casting, …])向x2返回x1之后的下一个浮点值, element-wise.
spacing(x, /[, out, where, casting, order, …])返回x与最近的相邻数字之间的距离。

理性例程

methoddescription
lcm(x1, x2, /[, out, where, casting, order, …])返回1和x2的最小公倍数
gcd(x1, x2, /[, out, where, casting, order, …])返回x1和x2的最大公约数

算术运算

methoddescription
add(x1, x2, /[, out, where, casting, order, …])按元素添加参数。
reciprocal(x, /[, out, where, casting, …])以元素为单位返回参数的倒数。
positive(x, /[, out, where, casting, order, …])数值正, element-wise.
negative(x, /[, out, where, casting, order, …])数值负数, element-wise.
multiply(x1, x2, /[, out, where, casting, …])逐个乘以参数。
divide(x1, x2, /[, out, where, casting, …])返回输入的真实除法, element-wise.
power(x1, x2, /[, out, where, casting, …])第一阵列元素从第二阵列提升为幂, element-wise.
subtract(x1, x2, /[, out, where, casting, …])逐个元素地减去参数。
true_divide(x1, x2, /[, out, where, …])返回输入的真实除法, element-wise.
floor_divide(x1, x2, /[, out, where, …])返回小于或等于输入的除法的最大整数。
float_power(x1, x2, /[, out, where, …])第一阵列元素从第二阵列提升为幂, element-wise.
fmod(x1, x2, /[, out, where, casting, …])返回元素的除法 remainder
mod(x1, x2, /[, out, where, casting, order, …])返回元素的除法余数。
modf(x[, out1, out2], / [[, out, where, …])返回数组的分数和整数部分, element-wise.
remainder(x1, x2, /[, out, where, casting, …])返回元素的除法余数。
divmod(x1, x2[, out1, out2], / [[, out, …])同时返回按元素商和余数。

处理复数

methoddescription
angle(z[, deg])返回复杂参数的角度。
real(val)返回复杂参数的实部。
imag(val)返回复杂参数的虚部。
conj(x, /[, out, where, casting, order, …])返回 complex conjugate, element-wise.
conjugate(x, /[, out, where, casting, …])返回复共轭, element-wise.

杂项

methoddescription
convolve(a, v[, mode])返回两个一维序列的离散线性卷积。
clip(a, a_min, a_max[, out])裁剪(限制)数组中的值。
sqrt(x, /[, out, where, casting, order, …])返回数组的非负 平方根, element-wise.
cbrt(x, /[, out, where, casting, order, …])返回数组的立方根, element-wise.
square(x, /[, out, where, casting, order, …])返回输入的元素方平方。
absolute(x, /[, out, where, casting, order, …])计算绝对值 element-wise.
fabs(x, /[, out, where, casting, order, …])计算绝对值 element-wise.
sign(x, /[, out, where, casting, order, …])返回数字符号的逐元素指示。
heaviside(x1, x2, /[, out, where, casting, …])计算Heaviside阶跃函数。
maximum(x1, x2, /[, out, where, casting, …])数组元素的逐元素最大值。
minimum(x1, x2, /[, out, where, casting, …])数组元素的按元素最小值。
fmax(x1, x2, /[, out, where, casting, …])数组元素的逐元素最大值。
fmin(x1, x2, /[, out, where, casting, …])数组元素的按元素最小值。
nan_to_num(x[, copy, nan, posinf, neginf])用较大的有限数字(默认行为)或使用用户定义的nan,posinf和/或neginf关键字定义的数字将NaN替换为零和无穷大。
real_if_close(a[, tol])如果复杂输入接近实数,则返回复杂数组。
interp(x, xp, fp[, left, right, period])一维线性插值。

基于 MIT 许可发布 共建 共享 共管