mindspore.mint.atan2

View Source On AtomGit
mindspore.mint.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

Arguments 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 the highest precision data type.

Parameters
  • input (Tensor, Number.number) – The input tensor or scalar.

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

Returns

Tensor, the shape is the same as the one after broadcasting. The dtype of output is float32 when dtype of input is in [bool, int8, uint8, int16, int32, int64]. Otherwise output has the same dtype as input.

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

  • RuntimeError – If data type conversion of Parameter is required for input or other, but such conversion is not supported.

Supported Platforms:

Ascend

Examples

>>> import mindspore
>>> import numpy as np
>>> from mindspore import Tensor, mint
>>> input = Tensor(np.array([0, 1]), mindspore.float32)
>>> other = Tensor(np.array([1, 1]), mindspore.float32)
>>> output = mint.atan2(input, other)
>>> print(output)
[0.        0.7853982]