megengine.functional.polar

polar(abs, angle)[源代码]

Constructs a complex tensor whose elements are Cartesian coordinates corresponding to the polar coordinates with absolute value abs and angle angle.

参数
  • abs (Tensor) – the absolute value the complex tensor. Must be float.

  • angle (Tensor) – the angle of the complex tensor. Must be float.

返回类型

Tensor

返回

the complex tensor

实际案例

>>> abs = Tensor([1, 2], dtype=np.float32)
>>> angle = Tensor([np.pi / 2, 5 * np.pi / 4], dtype=np.float32)
>>> z = F.polar(abs, angle)
>>> z
Tensor([-4.3711e-08+1.j     -1.4142e+00-1.4142j], dtype=complex64, device=xpux:0)