On this page
torch.polar
torch.polar(abs, angle, *, out=None) → Tensor-
Constructs a complex tensor whose elements are Cartesian coordinates corresponding to the polar coordinates with absolute value
absand angleangle.Note
torch.polaris similar to std::polar and does not compute the polar decomposition of a complex tensor like Python’scmath.polarand SciPy’slinalg.polardo. The behavior of this function is undefined ifabsis negative or NaN, or ifangleis infinite.- Parameters
- Keyword Arguments
-
out (Tensor) – If the inputs are
torch.float32, must betorch.complex64. If the inputs aretorch.float64, must betorch.complex128.
Example:
>>> import numpy as np >>> 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) >>> z tensor([(0.0000+1.0000j), (-1.4142-1.4142j)], dtype=torch.complex128)
© 2024, PyTorch Contributors
PyTorch has a BSD-style license, as found in the LICENSE file.
https://pytorch.org/docs/2.1/generated/torch.polar.html