atan2¶

paddle. atan2 ( x, y, name=None ) [source]

Element-wise arctangent of x/y with consideration of the quadrant.

Equation:
$\begin{split}atan2(x,y)=\left\{\begin{matrix} & tan^{-1}(\frac{x}{y}) & y > 0 \\ & tan^{-1}(\frac{x}{y}) + \pi & x>=0, y < 0 \\ & tan^{-1}(\frac{x}{y}) - \pi & x<0, y < 0 \\ & +\frac{\pi}{2} & x>0, y = 0 \\ & -\frac{\pi}{2} & x<0, y = 0 \\ &\text{undefined} & x=0, y = 0 \end{matrix}\right.\end{split}$
Parameters
• x (Tensor) – An N-D Tensor, the data type is int32, int64, float16, float32, float64.

• y (Tensor) – An N-D Tensor, must have the same type as x.

• name (str, optional) – Name for the operation (optional, default is None). For more information, please refer to Name.

Returns

An N-D Tensor, the shape and data type is the same with input (The output data type is float64 when the input data type is int).

Return type

out (Tensor)

Examples

import paddle

x = paddle.to_tensor([-1, +1, +1, -1]).astype('float32')