数学函数#

三角函数#

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])

通过对大增量取关于周期(period)的补集来解包裹(unwrap)。

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, ...])

反双曲正切,逐元素。

四舍五入#

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, ...])

沿给定轴返回数组元素的乘积,将 Not a Numbers (NaN) 视为 1。

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

沿给定轴返回数组元素的和,将 Not a Numbers (NaN) 视为 0。

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])

沿给定轴返回数组元素的累积乘积,将 Not a Numbers (NaN) 视为 1。

nancumsum(a[, axis, dtype, out])

沿给定轴返回数组元素的累积和,将 Not a Numbers (NaN) 视为 0。

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, ...])

返回输入数组加 1 的自然对数,逐元素。

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 与最近的相邻数字之间的距离。

有理数例程#

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])

返回数组的最大值或沿轴的最大值,忽略任何 NaN。

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])

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

杂项#

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, ...])

计算单位阶跃函数。

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

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

real_if_close(a[, tol])

如果输入是虚部接近零的复数,则返回实部。

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

一维线性插值,适用于单调递增的采样点。