数学函数#

三角函数#

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

两个数组比值的逐元素反正切。

degrees

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

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

将角度从度数转换为弧度,逐元素进行。

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

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

deg2rad

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

逐元素的 sinc 函数。

浮点例程#

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

测试每个元素的符号位是否被设置(即

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

返回第一个参数,其符号位逐元素地由第二个参数决定。

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

将每个元素分解为尾数和二的指数。

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

计算 x1 * 2 ** x2 的逐元素值。

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

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

Rational routines#

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

对两个数组进行逐元素相乘。

divide

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

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

remainder

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_to_num(x[, copy, nan, posinf, neginf])

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

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

计算 Heaviside 阶跃函数。

real_if_close(a[, tol])

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

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

一维线性插值。