mindspore.ops.Complex

class mindspore.ops.Complex[source]

Returns a complex Tensor from the real part and the imag part.

Inputs:
  • real (Tensor) - The real input tensor. types: float32, float64.

  • imag (Tensor) - The imag input tensor. types: float32, float64.

Outputs:

Tensor, has the complex type.

Raises
  • TypeError – If the dtype of input is not one of: float32, float64.

  • TypeError – If the dtypes of two inputs are not same.

Supported Platforms:

GPU CPU

Examples

>>> real = Tensor(np.array([1]), mindspore.float32)
>>> imag = Tensor(np.array([2]), mindspore.float32)
>>> complex = ops.Complex()
>>> output = complex(real, imag)
>>> print(output)
[1.+2.j]