mindspore.ops.atan2

mindspore.ops.atan2(input, other)[source]

Returns arctangent of input/other element-wise.

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

Note

  • Arg input and other 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 relatively the highest precision data type.

  • The inputs must be two tensors or one tensor and one scalar.

  • When the inputs are one tensor and one scalar, the scalar could only be a constant.

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

  • other (Tensor, Number.number) – The input tensor or scalar. It has the same shape with input.

Note

At least one of the input args should be Tensor.

Returns

Tensor or scalar, the shape is the same as the one after broadcasting,and the data type is same as input.

Raises
  • TypeError – If input or other is not a Tensor or scalar.

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

Supported Platforms:

Ascend GPU CPU

Examples

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