数学函数#

三角函数#

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

逐元素反双曲正切.

舍入#

round (a[, decimals, out])

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

around (a[, decimals, out])

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

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

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

fix (x[, out])

向零方向舍入到最近的整数.

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

返回输入的 floor,逐个元素计算.

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

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

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

逐元素地返回输入数组加 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 * 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, ...])

返回除法的 element-wise 余数.

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

返回除法的 element-wise 余数.

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

返回数组的 fractional 和 integral 部分,逐元素.

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

返回除法的 element-wise 余数.

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

数组元素的 Element-wise 最大值.

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

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

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

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

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

数组元素的 Element-wise 最大值.

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

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

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

数组元素的 Element-wise 最小值.

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

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

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

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

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

数组元素的 Element-wise 最小值.

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

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