complex

paddle. complex ( real, imag, name=None ) [source]

Return a compelx 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, optional) – Name for the operation (optional, default is None). For more information, please refer to Name.

Returns

The output tensor. The data type is ‘complex64’ or ‘complex128’, with the same precision as real and imag.

Return type

Tensor

Note:

paddle.complex supports broadcasting. If you want know more about broadcasting, please refer to user_guide_broadcasting .

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.numpy())

# [[0.+0.j 0.+1.j 0.+2.j]
#  [1.+0.j 1.+1.j 1.+2.j]]