maxframe.tensor.tan#
- maxframe.tensor.tan(x, out=None, where=None, **kwargs)[源代码]#
逐元素计算正切值。
等价于逐元素计算
mt.sin(x)/mt.cos(x)。- 参数:
x (array_like) -- 输入张量。
out (Tensor, None, or tuple of Tensor and None, optional) -- 用于存储结果的位置。如果提供,其形状必须可以广播到输入形状。如果未提供或为 None,则返回一个新分配的张量。元组(只能作为关键字参数)的长度必须等于输出数量。
where (array_like, optional) -- 为 True 的值表示在该位置计算 ufunc,为 False 的值表示保留输出中的原始值。
**kwargs
- 返回:
y -- 对应的正切值。
- 返回类型:
Tensor
备注
如果提供了 out,函数会将结果写入其中并返回对 out 的引用。(参见示例)
引用
M. Abramowitz and I. A. Stegun, Handbook of Mathematical Functions. New York, NY: Dover, 1972.
示例
>>> from math import pi >>> import maxframe.tensor as mt >>> mt.tan(mt.array([-pi,pi/2,pi])).execute() array([ 1.22460635e-16, 1.63317787e+16, -1.22460635e-16]) >>> >>> # Example of providing the optional output parameter illustrating >>> # that what is returned is a reference to said parameter >>> out1 = mt.zeros(1) >>> out2 = mt.cos([0.1], out1) >>> out2 is out1 True >>> >>> # Example of ValueError due to provision of shape mis-matched `out` >>> mt.cos(mt.zeros((3,3)),mt.zeros((2,2))) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: invalid return array shape