通用函数(ufunc)¶
Mars tensor 提供通用函数(也被称为 ufunc)来支持各种元素操作。Mars tensor 的通用函数支持 Numpy 的以下功能:
广播
确定输出类型
类型转换规则
Mars 张量通用函数目前不支持包括方法有 accumulate
、reduceat
、outer
和 at
。
可用的通用函数¶
数学运算¶
按元素相加 |
|
按元素相减 |
|
按元素相乘 |
|
按元素相除 |
|
按元素计算以e为底的两个输入指数值之和的对数值 |
|
按元素计算以2为底的两个输入指数值之和的对数值 |
|
按元素计算实数除法 |
|
按元素计算除法并向下取整 |
|
按元素求相反数 |
|
按元素求幂,前一个张量中的数值作为底数,后一个张量的数值作为指数 |
|
按元素返回整数除法的余数 |
|
按元素返回整数除法的余数 |
|
按元素返回整数除法的余数 |
|
按元素计算绝对值 |
|
按元素将张量中的值取整到最接近的整数 |
|
按元素取符号 |
|
计算所有元素的指数值 |
|
计算所有元素以2为底的指数值 |
|
按元素求自然对数 |
|
计算所有元素以2为底的对数值 |
|
计算所有元素以10为底的对数值 |
|
对张量中的所有元素计算 |
|
对张量中的所有元素计算 |
|
返回按元素求平方根的结果 |
|
返回按元素求平方的结果 |
|
返回按元素求倒数的结果 |
三角函数和双曲函数¶
Trigonometric sine, element-wise. |
|
Cosine element-wise. |
|
Compute tangent element-wise. |
|
Inverse sine, element-wise. |
|
Trigonometric inverse cosine, element-wise. |
|
Trigonometric inverse tangent, element-wise. |
|
Element-wise arc tangent of |
|
Given the "legs" of a right triangle, return its hypotenuse. |
|
Hyperbolic sine, element-wise. |
|
Hyperbolic cosine, element-wise. |
|
Compute hyperbolic tangent element-wise. |
|
Inverse hyperbolic sine element-wise. |
|
Inverse hyperbolic cosine, element-wise. |
|
Inverse hyperbolic tangent element-wise. |
|
Convert angles from degrees to radians. |
|
Convert angles from radians to degrees. |
位运算函数¶
Compute the bit-wise AND of two tensors element-wise. |
|
Compute the bit-wise OR of two tensors element-wise. |
|
Compute the bit-wise XOR of two arrays element-wise. |
|
Compute bit-wise inversion, or bit-wise NOT, element-wise. |
|
Shift the bits of an integer to the left. |
|
Shift the bits of an integer to the right. |
比较函数¶
Return the truth value of (x1 > x2) element-wise. |
|
Return the truth value of (x1 >= x2) element-wise. |
|
Return the truth value of (x1 < x2) element-wise. |
|
Return the truth value of (x1 =< x2) element-wise. |
|
Return (x1 != x2) element-wise. |
|
Return (x1 == x2) element-wise. |
|
Compute the truth value of x1 AND x2 element-wise. |
|
Compute the truth value of x1 OR x2 element-wise. |
|
Compute the truth value of x1 XOR x2, element-wise. |
|
Compute the truth value of NOT x element-wise. |
|
Element-wise maximum of tensor elements. |
|
Element-wise minimum of tensor elements. |
|
Element-wise maximum of array elements. |
|
Element-wise minimum of array elements. |
浮点数取值¶
Test element-wise for finiteness (not infinity or not Not a Number). |
|
Test element-wise for positive or negative infinity. |
|
Test element-wise for NaN and return result as a boolean tensor. |
|
Returns element-wise True where signbit is set (less than zero). |
|
Change the sign of x1 to that of x2, element-wise. |
|
Return the next floating-point value after x1 towards x2, element-wise. |
|
Return the fractional and integral parts of a tensor, element-wise. |
|
Returns x1 * 2**x2, element-wise. |
|
Decompose the elements of x into mantissa and twos exponent. |
|
按元素返回整数除法的余数 |
|
Return the floor of the input, element-wise. |
|
Return the ceiling of the input, element-wise. |
|
Return the truncated value of the input, element-wise. |