PyTorch torch.polar function
PyTorch torch reference manual
torch.polar is a function in PyTorch used to create a complex tensor from polar coordinates.
Function definition
torch.polar(abs, angle)
Usage examples
Example
import
torch
Create the absolute value (magnitude) tensor
abs_val
=
torch.
tensor
(
[
1.0
,
2.0
,
3.0
]
)
Create the angle (in radians) tensor
angle
=
torch.
tensor
(
[
0.0
,
torch.
pi
/
2
,
torch.
pi
]
)
Create a complex tensor from polar coordinates
x
=
torch.
polar
(
abs_val
,
angle
)
(
x
)
(
"Absolute value:"
,
x.
abs
(
)
)
(
"Angle:"
,
x.
angle
(
)
)