complex
- paddle. complex ( real: Tensor, imag: Tensor, name: Optional[str] = None, *, out: Optional[Tensor] = None ) Tensor [source]
-
Return a complex tensor given the real and image component.
- Parameters
-
real (Tensor) – The real component. The data type should be ‘float32’ or ‘float64’.
imag (Tensor) – The image component. The data type should be the same as
real.name (str|None, optional) – For details, please refer to api_guide_Name. Generally, no setting is required. Default: None.
out (Tensor|None, optional) – The output tensor. Default: None.
- Returns
-
Tensor, The output tensor. The data type is ‘complex64’ or ‘complex128’, with the same precision as
realandimag.
Note
paddle.complexsupports broadcasting. If you want know more about broadcasting, please refer to Introduction to Tensor .Examples
>>> import paddle >>> x = paddle.arange(2, dtype=paddle.float32).unsqueeze(-1) >>> y = paddle.arange(3, dtype=paddle.float32) >>> z = paddle.complex(x, y) >>> print(z) Tensor(shape=[2, 3], dtype=complex64, place=Place(cpu), stop_gradient=True, [[0j , 1j , 2j ], [(1+0j), (1+1j), (1+2j)]])
