数学函数#

三角函数#

sin(x, /[, out, where, casting, order, ...])

三角正弦,逐元素计算.

cos(x, /[, out, where, casting, order, ...])

余弦逐元素计算.

tan(x, /[, out, where, casting, order, ...])

逐元素计算切线.

arcsin(x, /[, out, where, casting, order, ...])

逐元素计算反正弦.

asin(x, /[, out, where, casting, order, ...])

逐元素计算反正弦.

arccos(x, /[, out, where, casting, order, ...])

逐元素计算三角反余弦.

acos(x, /[, out, where, casting, order, ...])

逐元素计算三角反余弦.

arctan(x, /[, out, where, casting, order, ...])

逐元素计算三角反切.

atan(x, /[, out, where, casting, order, ...])

逐元素计算三角反切.

hypot(x1, x2, /[, out, where, casting, ...])

给定一个直角三角形的"边”,返回其斜边.

arctan2(x1, x2, /[, out, where, casting, ...])

逐元素计算 x1/x2 的反正切值,并正确选择象限.

atan2(x1, x2, /[, out, where, casting, ...])

逐元素计算 x1/x2 的反正切值,并正确选择象限.

degrees(x, /[, out, where, casting, order, ...])

将角度从弧度转换为度数.

radians(x, /[, out, where, casting, order, ...])

将角度从度转换为弧度.

unwrap(p[, discont, axis, period])

通过取大增量相对于周期的补码来解包.

deg2rad(x, /[, out, where, casting, order, ...])

将角度从度转换为弧度.

rad2deg(x, /[, out, where, casting, order, ...])

将角度从弧度转换为度数.

双曲函数#

sinh(x, /[, out, where, casting, order, ...])

双曲正弦,逐元素计算.

cosh(x, /[, out, where, casting, order, ...])

双曲余弦,逐元素计算.

tanh(x, /[, out, where, casting, order, ...])

逐元素计算双曲正切.

arcsinh(x, /[, out, where, casting, order, ...])

逐元素计算反双曲正弦.

asinh(x, /[, out, where, casting, order, ...])

逐元素计算反双曲正弦.

arccosh(x, /[, out, where, casting, order, ...])

逐元素计算反双曲余弦.

acosh(x, /[, out, where, casting, order, ...])

逐元素计算反双曲余弦.

arctanh(x, /[, out, where, casting, order, ...])

逐元素计算反双曲正切.

atanh(x, /[, out, where, casting, order, ...])

逐元素计算反双曲正切.

Rounding#

round(a[, decimals, out])

均匀地四舍五入到给定的位数.

around(a[, decimals, out])

将数组四舍五入到给定的小数位数.

rint(x, /[, out, where, casting, order, ...])

将数组的元素四舍五入到最近的整数.

fix(x[, out])

向零取整到最近的整数.

floor(x, /[, out, where, casting, order, ...])

返回输入的向下取整值,逐元素进行.

ceil(x, /[, out, where, casting, order, ...])

返回输入的上限,逐元素.

trunc(x, /[, out, where, casting, order, ...])

返回输入的截断值,逐元素进行.

和、积、差#

prod(a[, axis, dtype, out, keepdims, ...])

返回给定轴上数组元素的乘积.

sum(a[, axis, dtype, out, keepdims, ...])

在给定轴上数组元素的总和.

nanprod(a[, axis, dtype, out, keepdims, ...])

返回在给定轴上数组元素的乘积,将非数字 (NaNs) 视为 1.

nansum(a[, axis, dtype, out, keepdims, ...])

返回在给定轴上数组元素的和,将非数字 (NaNs) 视为零.

cumulative_sum(x, /, *[, axis, dtype, out, ...])

返回沿给定轴的元素的累积和.

cumulative_prod(x, /, *[, axis, dtype, out, ...])

返回沿给定轴的元素累积乘积.

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[, axis, edge_order])

返回一个 N 维数组的梯度.

cross(a, b[, axisa, axisb, axisc, axis])

返回两个(数组)向量的叉积.

trapezoid(y[, x, dx, axis])

沿给定轴使用复合梯形法则进行积分.

指数和对数#

exp(x, /[, out, where, casting, order, ...])

计算输入数组中所有元素的指数.

expm1(x, /[, out, where, casting, order, ...])

计算数组中所有元素的 exp(x) - 1.

exp2(x, /[, out, where, casting, order, ...])

计算输入数组中所有 p2**p.

log(x, /[, out, where, casting, order, ...])

逐元素的自然对数.

log10(x, /[, out, where, casting, order, ...])

返回输入数组元素的以10为底的对数.

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为底的输入的指数和的对数.

其他特殊功能#

i0(x)

第一类修正贝塞尔函数,阶数为0.

sinc(x)

返回归一化的sinc函数.

浮点例程#

signbit(x, /[, out, where, casting, order, ...])

返回元素级 True,其中符号位已设置(小于零).

copysign(x1, x2, /[, out, where, casting, ...])

逐元素地将 x1 的符号改为 x2 的符号.

frexp(x[, out1, out2], / [[, out, where, ...])

将 x 的元素分解为尾数和二的指数.

ldexp(x1, x2, /[, out, where, casting, ...])

返回 x1 * 2**x2,逐元素计算.

nextafter(x1, x2, /[, out, where, casting, ...])

返回 x1 到 x2 方向上的下一个浮点值,逐元素进行.

spacing(x, /[, out, where, casting, order, ...])

返回 x 与其最近的相邻数之间的距离.

Rational 例程#

lcm(x1, x2, /[, out, where, casting, order, ...])

返回 |x1||x2| 的最小公倍数

gcd(x1, x2, /[, out, where, casting, order, ...])

返回 |x1||x2| 的最大公约数

算术运算#

add(x1, x2, /[, out, where, casting, order, ...])

逐元素添加参数.

reciprocal(x, /[, out, where, casting, ...])

返回参数的倒数,逐元素进行.

positive(x, /[, out, where, casting, order, ...])

逐元素取数值正值.

negative(x, /[, out, where, casting, order, ...])

逐元素取负数.

multiply(x1, x2, /[, out, where, casting, ...])

逐元素相乘.

divide(x1, x2, /[, out, where, casting, ...])

逐元素分割参数.

power(x1, x2, /[, out, where, casting, ...])

第一个数组的元素按元素依次提升到第二个数组的幂.

pow(x1, x2, /[, out, where, casting, order, ...])

第一个数组的元素按元素依次提升到第二个数组的幂.

subtract(x1, x2, /[, out, where, casting, ...])

逐元素减去参数.

true_divide(x1, x2, /[, out, where, ...])

逐元素分割参数.

floor_divide(x1, x2, /[, out, where, ...])

返回小于或等于输入除法的最大整数.

float_power(x1, x2, /[, out, where, ...])

第一个数组的元素按元素依次提升到第二个数组的幂.

fmod(x1, x2, /[, out, where, casting, ...])

返回逐元素的除法余数.

mod(x1, x2, /[, out, where, casting, order, ...])

返回逐元素的除法余数.

modf(x[, out1, out2], / [[, out, where, ...])

返回数组的分数部分和整数部分,逐元素进行.

remainder(x1, x2, /[, out, where, casting, ...])

返回逐元素的除法余数.

divmod(x1, x2[, out1, out2], / [[, out, ...])

同时返回元素级的商和余数.

处理复数#

angle(z[, deg])

返回复数参数的角度.

real(val)

返回复数参数的实部.

imag(val)

返回复数参数的虚部.

conj(x, /[, out, where, casting, order, ...])

返回逐元素的复共轭.

conjugate(x, /[, out, where, casting, ...])

返回逐元素的复共轭.

极值查找#

maximum(x1, x2, /[, out, where, casting, ...])

数组元素的逐元素最大值.

max(a[, axis, out, keepdims, initial, where])

返回数组中的最大值或沿轴的最大值.

amax(a[, axis, out, keepdims, initial, where])

返回数组中的最大值或沿轴的最大值.

fmax(x1, x2, /[, out, where, casting, ...])

数组元素的逐元素最大值.

nanmax(a[, axis, out, keepdims, initial, where])

返回数组中的最大值或沿某个轴的最大值,忽略任何 NaNs.

minimum(x1, x2, /[, out, where, casting, ...])

数组元素的逐元素最小值.

min(a[, axis, out, keepdims, initial, where])

返回数组中的最小值或沿轴的最小值.

amin(a[, axis, out, keepdims, initial, where])

返回数组中的最小值或沿轴的最小值.

fmin(x1, x2, /[, out, where, casting, ...])

数组元素的逐元素最小值.

nanmin(a[, axis, out, keepdims, initial, where])

返回数组的最小值或沿轴的最小值,忽略任何 NaNs.

杂项#

convolve(a, v[, mode])

返回两个一维序列的离散线性卷积.

clip(a[, a_min, a_max, out, min, max])

剪辑(限制)数组中的值.

sqrt(x, /[, out, where, casting, order, ...])

返回数组的非负平方根,逐元素进行.

cbrt(x, /[, out, where, casting, order, ...])

返回数组的立方根,逐元素进行.

square(x, /[, out, where, casting, order, ...])

返回输入的元素级平方.

absolute(x, /[, out, where, casting, order, ...])

计算绝对值元素逐个地.

fabs(x, /[, out, where, casting, order, ...])

计算逐元素的绝对值.

sign(x, /[, out, where, casting, order, ...])

返回一个数字的元素方向的符号指示.

heaviside(x1, x2, /[, out, where, casting, ...])

计算 Heaviside 阶跃函数.

nan_to_num(x[, copy, nan, posinf, neginf])

将 NaN 替换为零,将无穷大替换为大的有限数(默认行为),或者使用 nanposinf 和/或 neginf 关键字定义的数字替换.

real_if_close(a[, tol])

如果输入是复杂的,且所有虚部接近零,则返回实部.

interp(x, xp, fp[, left, right, period])

一维线性插值用于单调递增的样本点.

bitwise_count(x, /[, out, where, casting, ...])

计算 x 绝对值中 1 位的数量.