mars.tensor.tan#

mars.tensor.tan(x, out=None, where=None, **kwargs)[来源]#

逐元素计算正切。

等价于 mt.sin(x)/mt.cos(x) 元素级。

Parameters
  • x (array_like) – 输入张量。

  • out (Tensor, None, 或 tupleTensor 和 None, 可选) – 结果存储的位置。如果提供,它必须具有和输入相同的广播形状。如果未提供或None,将返回一个新分配的张量。元组(仅作为关键字参数可能)必须具有与输出数量相等的长度。

  • where (array_like, 可选) – 值为 True 表示在该位置计算 ufunc,值为 False 表示保持输出中的该值不变。

  • **kwargs

Returns

y – 对应的切线值。

Return type

张量

备注

如果 out 被提供,函数将结果写入其中,并返回对 out 的引用。 (参见示例)

参考文献

M. Abramowitz 和 I. A. Stegun, 数学函数手册。纽约, NY: Dover, 1972.

示例

>>> from math import pi
>>> import mars.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