mindspore.ops.atan2

mindspore.ops.atan2(x, y)[source]

Returns arctangent of x/y element-wise.

It returns \(\theta\ \in\ [-\pi, \pi]\) such that \(x = r*\sin(\theta), y = r*\cos(\theta)\), where \(r = \sqrt{x^2 + y^2}\).

Args of x and y comply with the implicit type conversion rules to make the data types consistent. If they have different data types, the lower precision data type will be converted to the relatively highest precision data type.

Parameters
  • x (Tensor) – The input tensor. \((N,*)\) where \(*\) means, any number of additional dimensions. The data type should be one of the following types: float16, float32, float64

  • y (Tensor) – The input tensor. It has the same shape with x.

Returns

Tensor, the shape is the same as the one after broadcasting,and the data type is same as x.

Raises
  • TypeError – If x or y is not a Tensor.

  • RuntimeError – If the data type of x and y conversion of Parameter is required when data type conversion of Parameter is not supported.

Supported Platforms:

Ascend CPU GPU

Examples

>>> x = Tensor(np.array([0, 1]), mindspore.float32)
>>> y = Tensor(np.array([1, 1]), mindspore.float32)
>>> output = ops.atan2(x, y)
>>> print(output)
[0.        0.7853982]