Rate this Page

torch.polar#

torch.polar(abs,angle,*,out=None)Tensor#

Constructs a complex tensor whose elements are Cartesian coordinatescorresponding to the polar coordinates with absolute valueabs and angleangle.

out=abscos(angle)+abssin(angle)j\text{out} = \text{abs} \cdot \cos(\text{angle}) + \text{abs} \cdot \sin(\text{angle}) \cdot j

Note

torch.polar is similar tostd::polarand does not compute the polar decompositionof a complex tensor like Python’scmath.polar and SciPy’slinalg.polar do.The behavior of this function is undefined ifabs is negative or NaN, or ifangle isinfinite.

Parameters
  • abs (Tensor) – The absolute value the complex tensor. Must be float or double.

  • angle (Tensor) – The angle of the complex tensor. Must be same dtype asabs.

Keyword Arguments

out (Tensor) – If the inputs aretorch.float32, must betorch.complex64. If the inputs aretorch.float64, must betorch.complex128.

Example:

>>>importnumpyasnp>>>abs=torch.tensor([1,2],dtype=torch.float64)>>>angle=torch.tensor([np.pi/2,5*np.pi/4],dtype=torch.float64)>>>z=torch.polar(abs,angle)>>>ztensor([(0.0000+1.0000j), (-1.4142-1.4142j)], dtype=torch.complex128)