Skip to content
fn

atan2_op

→TensorImplPtr
int atan2_op(const int & y, const int & x)

Python wrappers

Public Python APIs implemented by this engine symbol.

Quadrant-aware arctangent: y=atan2(yin,xin)y = \mathrm{atan2}(y_\text{in}, x_\text{in}).

Composite over arctan_op plus where_op branches that patch the result with ±π\pm \pi / ±π/2\pm \pi/2 / 00 corrections based on the signs of the operands. The divide y/xy / x is guarded by substituting 11 for x=0x = 0 so the safe branch is always defined. Gradient flows through the underlying primitives.

Math

atan2(y,x)={arctan⁡(y/x)x>0arctan⁡(y/x)+πx<0, y≥0arctan⁡(y/x)−πx<0, y<0+π/2x=0, y>0−π/2x=0, y<00x=0, y=0 \mathrm{atan2}(y, x) = \begin{cases} \arctan(y/x) & x > 0 \\ \arctan(y/x) + \pi & x < 0,\ y \ge 0 \\ \arctan(y/x) - \pi & x < 0,\ y < 0 \\ +\pi/2 & x = 0,\ y > 0 \\ -\pi/2 & x = 0,\ y < 0 \\ 0 & x = 0,\ y = 0 \end{cases}

See Also

arctan_op.

Parameters

yTensorImplPtr
Numerator (sine-like) operand.
xTensorImplPtr
Denominator (cosine-like) operand. Broadcastable with y.

Returns

TensorImplPtr

Angles in [−π,π][-\pi, \pi] on the broadcast shape of y and x.