fn

angle

Tensor
angle(input: Tensor)
source

Phase angle (argument) of a complex tensor.

Computes the polar-coordinate angle of each complex element: arg(z)=arctan2((z),(z))\arg(z) = \arctan2(\Im(z), \Re(z)). The output is a real F32 tensor in radians on the interval [π,π][-\pi, \pi].

Parameters

inputTensor
Complex-valued tensor (dtype must be complex64).

Returns

Tensor

Real F32 tensor with the same shape as input; each element contains the phase of the corresponding complex entry.

Notes

Mathematical definition:

outi=arg(zi)=arctan2((zi),(zi))\text{out}_i = \arg(z_i) = \arctan2(\Im(z_i), \Re(z_i))

Uses quadrant-correct lucid.atan2 internally — unlike a naive arctan(imag / real), this returns the proper four-quadrant angle. Zero complex inputs yield 0.0 (not NaN).

Examples

>>> import lucid
>>> z = lucid.tensor([1+0j, 1+1j, 0+1j, -1+0j])
>>> lucid.angle(z)
Tensor([0.0000, 0.7854, 1.5708, 3.1416])