数学函数#

三角函数#

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

三角正弦, element-wise.

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

双曲正弦, element-wise.

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

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

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

返回给定轴上数组元素的总和,并将Not a Numbers (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])

返回给定轴上数组元素的累积积,并将非数字 (NaN) 视为 1.

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

返回给定轴上数组元素的累积和,并将非数字 (NaN) 视为零.

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

计算输入数组中所有 p2p .

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

如果 signbit 被设置 (小于零),则返回 element-wise True.

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

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

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

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

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

返回 x1 * 2x2,逐个元素.

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

计算 Heaviside 阶跃函数.

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

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

real_if_close (a[, tol])

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

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

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