数学函数#

三角函数#

sin(x, /[, out, casting, dtype])

逐元素的正弦函数。

cos(x, /[, out, casting, dtype])

逐元素的余弦函数。

tan(x, /[, out, casting, dtype])

逐元素的正切函数。

arcsin(x, /[, out, casting, dtype])

逐元素的反正弦函数(即

arccos(x, /[, out, casting, dtype])

逐元素的反余弦函数(即

arctan(x, /[, out, casting, dtype])

逐元素的反正切函数(即

hypot(x1, x2, /[, out, casting, dtype])

计算给定长度的正交向量的斜边长。

arctan2(x1, x2, /[, out, casting, dtype])

逐元素计算两个数组之比的反正切。

rad2deg(x, /, out=None, *, casting='same_kind', dtype=None)

radians(x, /[, out, casting, dtype])

逐元素将角度从度转换为弧度。

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

通过取大增量的补数来解缠,相对于

度转弧度

radians(x, /, out=None, *, casting='same_kind', dtype=None)

rad2deg(x, /[, out, casting, dtype])

逐元素将角度从弧度转换为度。

双曲函数#

sinh(x, /[, out, casting, dtype])

逐元素的双曲正弦函数。

cosh(x, /[, out, casting, dtype])

逐元素的双曲余弦函数。

tanh(x, /[, out, casting, dtype])

逐元素的双曲正切函数。

arcsinh(x, /[, out, casting, dtype])

逐元素的双曲反正弦函数。

arccosh(x, /[, out, casting, dtype])

逐元素的双曲反余弦函数。

arctanh(x, /[, out, casting, dtype])

逐元素的双曲反正切函数。

取整#

around(a[, decimals, out])

四舍五入到指定的小数位数。

round_(a[, decimals, out])

rint(x, /[, out, casting, dtype])

将数组的每个元素四舍五入到最接近的整数。

fix(x, /[, out, casting, dtype])

如果给定值 x 为正,则返回 floor(x)。

floor(x, /[, out, casting, dtype])

将数组的每个元素四舍五入到其向下取整的整数。

ceil(x, /[, out, casting, dtype])

将数组的每个元素四舍五入到其向上取整的整数。

trunc(x, /[, out, casting, dtype])

将数组的每个元素向零方向取整。

求和、乘积、差分#

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

返回数组沿给定轴的乘积。

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

返回数组沿给定轴的和。

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

返回数组沿给定轴的乘积,将非数字(NaN)视为零。

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

返回数组沿给定轴的和,将非数字(NaN)视为零。

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

返回数组沿给定轴的累积乘积。

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

返回数组沿给定轴的累积和。

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

返回数组沿给定轴的累积乘积,将非数字(NaN)视为一。

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

返回数组沿给定轴的累积和,将非数字(NaN)视为零。

diff(a[, n, axis, prepend, append])

计算数组沿给定轴的第 n 阶离散差分。

gradient(f, *varargs[, axis, edge_order])

返回 N 维数组的梯度。

ediff1d(arr[, to_end, to_begin])

计算数组中相邻元素之间的差分。

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

返回两个向量的叉积。

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

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

指数和对数#

exp(x, /[, out, casting, dtype])

逐元素的指数函数。

expm1(x, /[, out, casting, dtype])

逐元素计算 exp(x) - 1

exp2(x, /[, out, casting, dtype])

逐元素的以 2 为底的幂运算。

log(x, /[, out, casting, dtype])

逐元素的自然对数函数。

log10(x, /[, out, casting, dtype])

逐元素的常用对数函数。

log2(x, /[, out, casting, dtype])

逐元素的二进制对数函数。

log1p(x, /[, out, casting, dtype])

逐元素计算 log(1 + x)

logaddexp(x1, x2, /[, out, casting, dtype])

逐元素计算 log(exp(x1) + exp(x2))

logaddexp2(x1, x2, /[, out, casting, dtype])

逐元素计算 log2(exp2(x1) + exp2(x2))

其他特殊函数#

i0(x, /[, out, casting, dtype])

第一类修正贝塞尔函数,零阶。

sinc(x, /[, out, casting, dtype])

逐元素的 sinc 函数。

浮点数例程#

signbit(x, /[, out, casting, dtype])

逐元素测试符号位是否设置(即

copysign(x1, x2, /[, out, casting, dtype])

逐元素返回第一个参数,其符号位取自第二个参数。

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

将每个元素分解为尾数和以 2 为底的指数。

ldexp(x1, x2, /[, out, casting, dtype])

逐元素计算 x1 * 2 ** x2

nextafter(x1, x2, /[, out, casting, dtype])

计算朝向第二个参数的最近邻浮点数值。

有理数例程#

lcm(x1, x2, /[, out, casting, dtype])

逐元素计算 x1x2 的最小公倍数。

gcd(x1, x2, /[, out, casting, dtype])

逐元素计算 x1x2 的最大公约数。

算术运算#

add(x1, x2, /[, out, casting, dtype])

逐元素相加两个数组。

reciprocal(x, /[, out, casting, dtype])

逐元素计算 1 / x

positive(x, /[, out, casting, dtype])

逐元素取数值的正。

negative(x, /[, out, casting, dtype])

逐元素取数值的负。

multiply(x1, x2, /[, out, casting, dtype])

逐元素相乘两个数组。

true_divide(x1, x2, /, out=None, *, casting='same_kind', dtype=None)

power(x1, x2, /[, out, casting, dtype])

逐元素计算 x1 ** x2

subtract(x1, x2, /[, out, casting, dtype])

逐元素相减参数。

true_divide(x1, x2, /[, out, casting, dtype])

逐元素的真除法(即

floor_divide(x1, x2, /[, out, casting, dtype])

逐元素的整除法(即

float_power(x1, x2, /[, out, casting, dtype])

逐元素将第一个数组的元素按第二个数组的幂进行计算。

fmod(x1, x2, /[, out, casting, dtype])

逐元素计算 C 语言除法的余数。

mod(x1, x2, /[, out, casting, dtype])

逐元素计算 Python 除法的余数。

modf(x[, out1, out2], / [[, out, casting, dtype])

逐元素提取数组的小数部分和整数部分。

余数

mod(x1, x2, /, out=None, *, casting='same_kind', dtype=None)

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

处理复数#

angle(z[, deg])

返回复数参数的角度。

real(val)

返回数组元素的实部。

imag(val)

返回数组元素的虚部。

conj

conjugate(x, /, out=None, *, casting='same_kind', dtype=None)

conjugate(x, /[, out, casting, dtype])

逐元素返回复共轭。

杂项#

convolve(a, v[, mode])

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

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

将数组的值裁剪到给定区间。

sqrt(x, /[, out, casting, dtype])

逐元素的平方根函数。

cbrt(x, /[, out, casting, dtype])

逐元素的立方根函数。

square(x, /[, out, casting, dtype])

逐元素的平方函数。

absolute(x, /[, out, casting, dtype])

逐元素的绝对值函数。

fabs(x, /[, out, casting, dtype])

逐元素计算绝对值。

sign(x, /[, out, casting, dtype])

逐元素的符号函数。

maximum(x1, x2, /[, out, casting, dtype])

逐元素取两个数组的最大值。

minimum(x1, x2, /[, out, casting, dtype])

逐元素取两个数组的最小值。

fmax(x1, x2, /[, out, casting, dtype])

逐元素取两个数组的最大值。

fmin(x1, x2, /[, out, casting, dtype])

逐元素取两个数组的最小值。

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

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

heaviside(x1, x2, /[, out, casting, dtype])

计算 Heaviside 阶跃函数。

real_if_close(a[, tol])

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

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

一维线性插值。