fn

polar

Tensor
polar(abs: Tensor, angle: Tensor)
source

Build a complex tensor from polar coordinates (magnitude, phase).

Constructs each complex output entry as z=reiθ=rcosθ+irsinθz = r e^{i\theta} = r\cos\theta + i\,r\sin\theta, where r comes from abs and θ\theta from angle. Both inputs are real-valued and follow standard broadcasting rules.

Parameters

absTensor
Real F32 tensor of magnitudes (non-negative values are typical but not enforced — a negative magnitude simply rotates the phase by π\pi).
angleTensor
Real F32 tensor of phase angles, in radians. Must broadcast with abs.

Returns

Tensor

complex64 tensor whose shape is the broadcast shape of the two inputs.

Notes

Mathematical definition:

z=reiθ=rcosθ+irsinθ.z = r\,e^{i\theta} = r\cos\theta + i\,r\sin\theta.

Inverse of the pair lucid.abs / angle for complex tensors: polar(abs(z), angle(z)) reconstructs z up to floating-point round-off.

Examples

>>> import lucid
>>> import math
>>> r = lucid.tensor([1.0, 2.0])
>>> th = lucid.tensor([0.0, math.pi / 2])
>>> lucid.polar(r, th)
Tensor([1.+0.j, 0.+2.j])